uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, Spin, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Rot: TEdit;
Gruen: TEdit;
Blau: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Hoehe: TSpinEdit;
Breite: TSpinEdit;
Label4: TLabel;
Label5: TLabel;
OpenPictureDialog1: TOpenPictureDialog;
BmpHoehe: TEdit;
BmpBreite: TEdit;
Label6: TLabel;
Label7: TLabel;
Button1: TButton;
Count: TEdit;
Memo1: TMemo;
PGImage1: TImage;
Anzeigen: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure HoeheChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure AnzeigenClick(Sender: TObject);
procedure Zeichnen;
private
{ Private-Deklarationen }
BitMap : TBitmap;
public
{ Public-Deklarationen }
Resultat :
array [0..350,0..1]
of Integer;
counter :Integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
BitMap:= TBitmap.Create;
BitMap.LoadFromFile('
C:\Grafik1.bmp');
BmpHoehe.Text := IntToStr(BitMap.Height);
BmpBreite.Text := IntToStr(BitMap.Width);
end;
procedure TForm1.HoeheChange(Sender: TObject);
var
X,Y : Integer;
S1 : PByteArray;
begin
X := Hoehe.Value;
Y := Breite.Value;
S1 := BitMap.ScanLine[X];
Blau.Text := IntToStr((PByte(Integer(S1) + Y * 3)^));
//Blau
Gruen.Text :=IntToStr((trunc(PByte(Integer(S1) + Y * 3 + 1)^)));
// Grün
Rot.Text := IntToStr((trunc(PByte(Integer(S1) + Y * 3 + 2)^)));
//Rot
end;
procedure TForm1.Button1Click(Sender: TObject);
var
X,Y : Integer;
S1 : PByteArray;
i,j : Integer;
counter :Integer;
schwarz :
string;
begin
Counter := 0;
Y := StrToInt(BmpHoehe.text);
X := StrToInt(BmpBreite.text);
schwarz:= '
';
for i := 0
to Y -1
do
begin
S1 := BitMap.ScanLine[i];
j:= 0;
repeat
Blau.Text := IntToStr((PByte(Integer(S1) + j * 3)^));
//Blau
Gruen.Text :=IntToStr((PByte(Integer(S1) + j * 3 + 1)^));
// Grün
Rot.Text := IntToStr((PByte(Integer(S1) + j * 3 + 2)^));
//Rot
if ((PByte(Integer(S1) + j * 3)^) = 0)
and
((PByte(Integer(S1) + j * 3 + 1)^)= 0)
and
((PByte(Integer(S1) + j * 3 + 2)^)= 0)
then begin
Inc(Counter);
Resultat[Counter,0] := i;
// X Werte
Resultat[Counter,1] := j;
// Y Werte
schwarz := schwarz + IntToStr(j) + '
' + IntToStr(i) + '
; ';
end;
j := j+ 12;
until j> X-1;
Count.Text := IntToStr(Counter);
end;
Memo1.Text := schwarz;
end;
procedure TForm1.AnzeigenClick(Sender: TObject);
var
dc : TCanvas;
i : Integer;
hClip : HRGN;
a,b : Integer;
rcClip : TRect;
penMode : TPenMode;
penColor: TColor;
penWidth: Integer;
penStyle: TPenStyle;
begin
//Zeichnen;
dc := PGImage1.Canvas;
penMode :=
dc.Pen.Mode;
penColor :=
dc.Pen.Color;
penWidth :=
dc.Pen.Width;
penStyle :=
dc.Pen.Style;
rcClip :=
dc.ClipRect;
dc.Pen.Mode := pmCopy;
dc.Pen.Color := $00F572B0;
dc.Pen.Width := 2;
dc.Pen.Style := psSolid;
hClip :=CreateRectRgn(0,0,350,890);
SelectClipRgn(
dc.Handle,hClip);
dc.MoveTo(Resultat[0,0],Resultat[0,1]);
a := Resultat [0,0];
b := Resultat [0,1];
edit1.text := inttostr(a);
edit2.text := inttostr(b);
for i := 1
to counter-1
do
begin
dc.Pixels[Resultat[i,0], Resultat[i,1]] := 0;
end;
dc.Pen.Mode := pmCopy;
dc.Pen.Color := penColor;
dc.Pen.Width := penWidth;
dc.Pen.Style := penStyle;
hClip := CreateRectRgn(0,0,350,890);
SelectClipRgn(
dc.Handle,hClip); }
end;