
<pre lang="syntak">
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ExtDlgs, StdCtrls;
type
TForm6 = class(TForm)
Button1: TButton;
opd: TOpenPictureDialog;
Button2: TButton;
Panel1: TPanel;
Panel2: TPanel;
Button3: TButton;
Button4: TButton;
Image1: TImage;
Image2: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
gambar1,gambar2 : TBitmap;
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.Button1Click(Sender: TObject);
begin
if not opd.Execute then
exit
else
begin
gambar1 := Tbitmap.Create;
gambar1.LoadFromFile(opd.FileName);
image1.Picture.Bitmap.Assign(gambar1);
end;
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
if not opd.Execute then
exit
else
begin
gambar2 := Tbitmap.Create;
gambar2.LoadFromFile(opd.FileName);
image2.Picture.Bitmap.Assign(gambar2);
end;
end;
procedure TForm6.Button3Click(Sender: TObject);
var pixel1,pixel2 : PByteArray;
baris,kolom :integer;
cek : boolean;
begin
if ((gambar1.Height=gambar2.Height)and
(gambar1.Width=gambar2.Width)) then
begin
if (gambar1.PixelFormat=gambar2.PixelFormat) then
begin
for baris:=0 to gambar1.Height-1 do
begin
pixel1:=gambar1.ScanLine[baris];
pixel2:=gambar2.ScanLine[baris];
for kolom:=0to gambar1.Width-1do
begin
if (gambar1.PixelFormat=pf8bit) then
begin
if(pixel1[kolom]=pixel2[kolom]) then
cek:=true
else
begin
showmessage('Citra Tidak Sama');
exit;
end;
end else
if (gambar1.PixelFormat=pf24bit) then
begin
if ((pixel1[3*kolom]=pixel2[3*kolom]) and
(pixel1[3*kolom+1]=pixel2[3*kolom+1])and
(pixel1[3*kolom+2]=pixel2[3*kolom+2]))then
cek:=true
else
begin
showmessage ('Citra Tidak Sama');
exit;
end;
end;
end;
end;
if cek=true then
showmessage('citra sama');
end else
showmessage('Citra Tidak sama');
end else
begin
showmessage('Citra Tidak sama');
end;
end;
procedure TForm6.Button4Click(Sender: TObject);
begin
//ini di isi apa gan ? biar ketika di klik gambar ny bisa sama
end;
end.
</pre>
procedure TForm1.Button4Click(Sender: TObject); |
IF gambar2.Canvas.Pixels[i,j] <> gambar1.Canvas.Pixels[i,j] |
It looks like you're new here. If you want to get involved, click one of these buttons!