unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Image1: TImage;
OpenPictureDialog1: TOpenPictureDialog;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (OpenPictureDialog1.Execute ) then
begin
image1.Picture.LoadFromFile(OpenPictureDialog1.FileName )
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
pc:pbyteArray;
r,g,b:byte;
begin
if (image1.Picture.Bitmap.PixelFormat =pf24bit) then
begin
pc:=image1.Picture.Bitmap.ScanLine [y];
r:=pc[3*x+2];
g:=pc[3*x+1];
b:=pc[3*x];
label4.Caption:='posisi('+inttostr(x)+','+inttostr(y)+')';
edit1.Text := inttostr(r);
edit2.Text :=inttostr(g);
edit3.Text:=inttostr(b);
end;
end;
end.
repernsi dari buku pemograman delphi untuk aplikasi mesin visi menggunakan webcam
penulis: balza achmad
website:www.gavamedia.net
0 Comments