Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Menus, Buttons, ExtDlgs, Grids,
ValEdit, ToolWin, Gauges, Mask;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
PageControl1: TPageControl;
Addb: TButton;
delb: TButton;
adds: TButton;
dels: TButton;
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
Help1: TMenuItem;
Howtouse1: TMenuItem;
About1: TMenuItem;
New1: TMenuItem;
Reset1: TMenuItem;
Dtms1: TMenuItem;
Makedtm1: TMenuItem;
MakeDDTM1: TMenuItem;
BitBtn1: TBitBtn;
Edit1: TEdit;
Label1: TLabel;
OpenPictureDialog1: TOpenPictureDialog;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Button2: TButton;
CheckDTM1: TMenuItem;
Checkcolor1: TMenuItem;
GenerarteDTM1: TMenuItem;
Credits1: TMenuItem;
ValueListEditor1: TValueListEditor;
Button4: TButton;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
ValueListEditor2: TValueListEditor;
ValueListEditor3: TValueListEditor;
Button6: TButton;
StaticText1: TStaticText;
BitBtn2: TBitBtn;
Edit14: TEdit;
Gauge1: TGauge;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
Button7: TButton;
Button8: TButton;
Button3: TButton;
Button5: TButton;
Label7: TLabel;
procedure AddbClick(Sender: TObject);
procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure delbClick(Sender: TObject);
procedure OpenPictureDialog1SelectionChange(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Credits1Click(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Mouseup(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x : integer;
im:boolean;
tabSheetw : array[0..10] of TTabSheet;
selec1x,selec1y,selec2x,selec2y : array[0..12] of integer;
selec: array[0..12] of Tshape;
img: array[0..10] of TImage;
pixelsy, pixelsx: integer;
scro: array[0..10] of TScrollBox;
temparr , temparr2:array of integer;
kleur1,kleur2,kleur3:integer;
kleur1p,kleur2p,kleur3p:integer;
kleur1g,kleur2g,kleur3g:integer;
implementation
uses Unit2, Unit3, Unit4, Math, Unit5, Unit6;
var
forma: array of TShape; //Array to create
formaUtil: Integer; // Kind of shape
Numforma: Integer; //Number of shapes
Izq, Arr, Ancho, alto, x1, x2, y1, y2: Integer; //Position and size of shape
activar: Boolean; //Tells when you are creating and sizing the shape
{$R *.dfm}
procedure TForm1.Image1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
xt:integer;
begin
formaUtil := 1;
if formaUtil < 1 then Exit;
activar := True;
xt:=Form1.PageControl1.TabIndex+1;
//starting draw the shape
x1 := x+ img[xt].left;
Edit10.text:= inttostr(x1);
//ShowMessage(inttostr(x1));
y1 := y+ img[xt].Top;
Edit11.text:= inttostr(y1);
//ShowMessage(inttostr(y1));
numforma := numforma + 1;
setlength(forma, numforma);
forma[numforma - 1] := TShape.Create(TabSheetw[xt]);
forma[numforma - 1].Pen.Mode:=pmNot;
forma[numforma - 1].Pen.Width:=1;
forma[numforma - 1].Pen.Color:=clBlack;
if formaUtil = 1 then
forma[numforma - 1].Shape :=stRectangle
else
forma[numforma - 1].Shape := stCircle;
forma[numforma - 1].Left := x1;
forma[numforma - 1].Top := y1;
forma[numforma - 1].Parent := scro[xt];
forma[numforma - 1].Width := 0;
forma[numforma - 1].Height := 0;
forma[numforma - 1].BringToFront;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
xt:integer;
begin
xt:=Form1.PageControl1.TabIndex+1;
Edit8.Text:= inttostr(x);
Edit9.Text:= inttostr(y);
Edit7.Color := img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top];
Edit6.Text := inttostr(img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top]);
if (formaUtil = 0) then Exit;
if (numforma = 0) then Exit;
if not activar then Exit;
x2 := x+img[xt].left;
Edit12.text:= inttostr(x2);
y2 := y+img[xt].Top;
Edit13.text:= inttostr(y2);
forma[numforma - 1].Width := x2 - x1;
forma[numforma - 1].Height := y2 - y1;
StaticText1.Caption := IntToStr(numforma);
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xt:integer;
begin
xt:=Form1.PageControl1.TabIndex+1;
x2 := x+img[xt].left;
//ShowMessage(inttostr(x2));
y2 := y+img[xt].Top;
//ShowMessage(inttostr(y2));
forma[numforma - 1].Width := x2 - x1;
forma[numforma - 1].Height := y2 - y1;
formaUtil := 1;
activar := False;
//form5.show;
Form5.MaskEdit1.text := inttostr(forma[0].left);
Form5.MaskEdit2.text := inttostr(forma[0].top);
Form5.MaskEdit3.text := inttostr(forma[0].height);
Form5.MaskEdit4.text := inttostr(forma[0].width);
end;
procedure TForm1.AddbClick(Sender: TObject);
begin
x:= pageControl1.PageCount+1;
tabSheetw[x] := TTabSheet.Create(PageControl1) ;
tabSheetw[x].PageControl := PageControl1;
tabSheetw[x].Caption:= inttostr(pageControl1.PageCount);
scro[x] := TScrollBox.Create(tabSheetw[x]);
scro[x].Align := alClient;
scro[x].Parent:= tabSheetw[x];
scro[x].BorderStyle:=bsSingle;
img[x] := TImage.Create(scro[x]);
img[x].Parent := scro[x];
img[x].OnMouseUp := Image1MouseUp;
img[x].OnMouseDown := Image1MouseDown;
img[x].OnMouseMove := Image1MouseMove;
end;
procedure setrechts();
var
x : integer;
tabSheetw : array[0..10] of TTabSheet;
begin
end;
procedure sorter();
var i,j,temp, temp2,minIndex:integer;
sortedstring:string;
begin
setlength(temparr2,high(temparr));
for i:= low(temparr) to high(temparr) do
begin
temparr2[i] := strtoint(Form1.ValueListEditor2.Values[inttostr(temparr[i])]);
end;
for i:= 0 to length(temparr)-1 do
begin
// zoek kleinste in de rest van de array
minIndex := i;
for j:=i to length(temparr2)do
begin
if (temparr2[j] < temparr2[minIndex]) then
begin
minIndex := j;
end;
end;
// verwissel waarden
temp := temparr[i];
temparr[i] := temparr[minIndex];
temparr[minIndex] := temp;
temp := temparr2[i];
temparr2[i] := temparr2[minIndex];
temparr2[minIndex] := temp;
//ShowMessage(inttostr(temparr[i]));
end;
end;
procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
//setrechts();
end;
procedure TForm1.delbClick(Sender: TObject);
begin
x:= pageControl1.PageCount;
tabSheetw[x].Destroy;
end;
procedure TForm1.OpenPictureDialog1SelectionChange(Sender: TObject);
begin
//Self.get
//Self.Parent.image1.picture := Self.
end;
procedure TForm1.Button4Click(Sender: TObject);
var
Bitmap: TBitmap;
x:integer;
begin
Bitmap := TBitmap.Create;
if OpenPictureDialog1.Execute then
begin
x:= PageControl1.TabIndex+1;
Bitmap.LoadFromFile(OpenPictureDialog1.FileName);
img[x].Picture.LoadFromFile(OpenPictureDialog1.FileName);
img[x].Width:= Bitmap.Width ;
img[x].Height:= Bitmap.Height;
end;
Bitmap.Free;
end;
procedure TForm1.About1Click(Sender: TObject);
begin
About.show;
end;
procedure TForm1.Credits1Click(Sender: TObject);
begin
Credits.show;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
formaUtil := 1;
Numforma := 0;
activar := False;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form4.ShowModal;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
myFile : TextFile;
text : string;
gkleur, fkleur: array[0..2550] of integer;
rowcount: integer;
xt:integer;
startpixelcolor,pixel2color:integer;
startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
zoeky,zoekx,zoekx2,zoeky2:integer;
tempprocent,tempprocent2,procent: variant;
tempje,color: integer;
color2: array[0..10000] of integer;
startpixx,startpixy,startpixcol : integer;
directory : string;
selecs,tempje2,i, error:integer;
bestaat: Boolean;
begin
xt:=Form1.PageControl1.TabIndex+1;
tempje2:= 0;
for zoeky2 := forma[0].top to forma[0].top+forma[0].Height-1 do
begin
for zoekx2 := forma[0].left to forma[0].left+forma[0].Width-1 do
begin
color2[tempje2] := img[xt].Canvas.Pixels[zoekx2, zoeky2];
for i:=0 to tempje2-1 do
begin
if(color2[i] = color2[tempje2])then tempje2:= tempje2-1;
end;
tempje2:= tempje2+1;
end;
end;
//tempje2:= 0;
ShowMessage(inttostr(tempje2));
for zoeky := img[xt].top to img[xt].top+img[xt].Height-1 do
begin
for zoekx := img[xt].left to img[xt].left+img[xt].width-1 do
begin
Gauge1.Progress:= floor((zoeky*img[xt].width+zoekx)/(img[xt].Height*img[xt].Width)*100);
color:= img[xt].Canvas.Pixels[zoekx, zoeky];
bestaat := false;
for i:=0 to tempje2-1 do
begin
if(color2[i] = color)then bestaat:= true;
end;
if(bestaat)then begin
CreateDir('C:\tmp\fout');
ChDir('C:\tmp\fout');
for selecs:=0 to numforma-1 do
begin
if(zoekx >= forma[selecs].left) AND (zoekx <= forma[selecs].left+forma[selecs].width) AND (zoeky >= forma[selecs].top) AND (zoeky <= forma[selecs].top+forma[selecs].height)then
begin
CreateDir('C:\tmp\goed'+inttostr(selecs));
ChDir('C:\tmp\goed'+inttostr(selecs));
end;
end;
AssignFile(myFile, inttostr(color)+'.txt');
if FileExists(inttostr(color)+'.txt') then
Append(myFile)
else
begin
Rewrite(myFile);
WriteLn(myFile, color);
WriteLn(myFile, '1');
end;
WriteLn(myFile, '['+inttostr(zoekx)+', '+inttostr(zoeky)+']');
// Close the file
CloseFile(myFile);
end;
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
myFile : TextFile;
text : string;
rowcount: integer;
temp,temp2,temp3: integer;
xt:integer;
startpixelcolor,pixel2color:integer;
startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
zoeky,zoekx:integer;
tempprocent,tempprocent2,procent: variant;
tempje,color: integer;
startpixx,startpixy,startpixcol,regel,fout : integer;
directory : string;
selecs, selecs2:integer;
verwijder:Boolean;
begin
kleur1:= 0;
kleur2:= 0;
kleur3:= 0;
xt:=Form1.PageControl1.TabIndex+1;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
for zoeky := forma[0].top to forma[0].top+forma[0].Height-1 do
begin
for zoekx := forma[0].left to forma[0].left+forma[0].Width-1 do
begin
Gauge1.Progress:= floor((zoeky*forma[0].width+zoekx)/(forma[0].Height*forma[0].Width)*100);
color:= img[xt].Canvas.Pixels[zoekx, zoeky];
verwijder:= false;
for selecs:=0 to numforma-1 do
begin
ChDir('C:\tmp\goed'+inttostr(selecs));
if not FileExists(inttostr(color)+'.txt') then
begin
for selecs2:=0 to numforma-1 do
begin
ChDir('C:\tmp\goed'+inttostr(selecs2));
If(FileExists(inttostr(color)+'.txt'))then
DeleteFile(inttostr(color)+'.txt');
end;
ChDir('C:\tmp\berekend');
If(FileExists(inttostr(color)+'.txt'))then
DeleteFile(inttostr(color)+'.txt');
verwijder:= true;
end;
end;
if(verwijder = false)then
begin
ChDir('C:\tmp\berekend');
if not FileExists(inttostr(color)+'.txt') then
begin
CreateDir('C:\tmp\fout');
ChDir('C:\tmp\fout');
if FileExists(inttostr(color)+'.txt') then
begin
AssignFile(myFile, inttostr(color)+'.txt');
Reset(myFile);
regel:= 0;
fout:= 0;
while not Eof(myFile) do
begin
fout:= fout+1;
ReadLn(myFile, text);
end;
CloseFile(myFile);
end;
//000000
temp:= 99999999;
//bestaat := 1;
for selecs:=0 to numforma-1 do
begin
ChDir('C:\tmp\goed'+inttostr(selecs));
if FileExists(inttostr(color)+'.txt') then
begin
AssignFile(myFile, inttostr(color)+'.txt');
Reset(myFile);
regel:= 0;
while not Eof(myFile) do
begin
regel:= regel+1;
ReadLn(myFile, text);
end;
CloseFile(myFile);
if(temp > regel)then temp:= regel;
end;
regel:= temp;
//000000
end;
if(regel = 99999999)then regel:= 0;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
AssignFile(myFile, inttostr(color)+'.txt');
Rewrite(myFile);
if(regel >2)then
begin
regel:= regel-2;
if(fout >=0)AND(fout < 3)then
fout:=0 else
fout:= fout -2;
end;
if(regel > 5)AND(regel+fout <> 0)then //5 staat voor minimaal aantal
procent:= floor(regel/(regel+fout)*100) else procent:= 0;
WriteLn(myFile, inttostr(regel));
WriteLn(myFile, inttostr(fout));
WriteLn(myFile, inttostr(procent));
if(procent > kleur3p)then
begin
if(kleur3 = 0)then
begin
if(kleur2 = 0)then
begin
if(kleur1 = 0)then
begin
kleur1 := color;
kleur1p := procent;
kleur1g := regel;
end else
begin
kleur2 := color;
kleur2p := procent;
kleur2g := regel;
end;
end else
begin
kleur1 := color;
kleur1p := procent;
kleur1g := regel;
end;
end;
end;
if(procent > kleur3p)then
begin
kleur3 := color;
kleur3p:= procent;
kleur3g:= regel;
end;
if(procent = kleur3p)then
begin
if(regel > kleur3g)then
begin
kleur3 := color;
kleur3p:= procent;
kleur3g:= regel;
end;
end;
if(kleur3p > kleur2p)then
begin
temp:= kleur3;
temp2:= kleur3p;
temp3:= kleur3g;
kleur3 := kleur2;
kleur3p:= kleur2p;
kleur3g:= kleur2g;
kleur2 := temp;
kleur2p:= temp2;
kleur2g:= temp3;
end;
if(kleur3p = kleur2p)then
begin
if(kleur3g > kleur2g)then
begin
temp:= kleur3;
temp2:= kleur3p;
temp3:= kleur3g;
kleur3 := kleur2;
kleur3p:= kleur2p;
kleur3g:= kleur2g;
kleur2 := temp;
kleur2p:= temp2;
kleur2g:= temp3;
end;
end;
if(kleur2p > kleur1p)then
begin
temp:= kleur2;
temp2:= kleur2p;
temp3:= kleur2g;
kleur2 := kleur1;
kleur2p:= kleur1p;
kleur2g:= kleur1g;
kleur1 := temp;
kleur1p:= temp2;
kleur1g:= temp3;
end;
if(kleur2p = kleur1p)then
begin
if(kleur2g > kleur1g)then
begin
temp:= kleur2;
temp2:= kleur2p;
temp3:= kleur2g;
kleur2 := kleur1;
kleur2p:= kleur1p;
kleur2g:= kleur1g;
kleur1 := temp;
kleur1p:= temp2;
kleur1g:= temp3;
end;
end;
CloseFile(myFile);
end;
end;
end;
end;
ShowMessage(inttostr(kleur1p)+'/'+inttostr(kleur1));
ShowMessage(inttostr(kleur2p)+'/'+inttostr(kleur2));
ShowMessage(inttostr(kleur3p)+'/'+inttostr(kleur3));
end;
procedure TForm1.Button5Click(Sender: TObject);
var
myFile,myFile2 : TextFile;
text : string;
master1, master2, delimiter, found1, found2 : string;
i, j, K : integer; //operating variables
pixelkleur, pixelx, pixely: array[0..1000] of integer;
aantal,regel, aantal2, aantal3: integer;
selecs:integer;
firstcolor, secondcolor:integer;
firstx, secondx:integer;
firsty, secondy:integer;
gfirstcolor, gsecondcolor:integer;
gfirstx, gsecondx:integer;
gfirsty, gsecondy:integer;
verschilx, verschily:integer;
xt:integer;
goed:integer;
goedvorig,goedvorig2:integer;
begin
for selecs:=0 to numforma-1 do
begin
aantal:= 0;
aantal2:= 0;
aantal3:= 0;
ChDir('C:\tmp\goed'+inttostr(selecs));
AssignFile(myFile, inttostr(kleur1)+'.txt');
Reset(myFile);
regel:= 0;
while not Eof(myFile) do
begin
ReadLn(myFile, text);
regel:= regel+1;
if(regel > 2)then
begin
delimiter :='[';
master1:= text;
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ',';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found1 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
delimiter :=',';
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ']';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found2 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
pixelkleur[aantal] := kleur1;
pixelx[aantal] := strtoint(found1);
pixely[aantal] := strtoint(found2);
aantal := aantal+1;
end;
end;
CloseFile(myFile);
AssignFile(myFile2, inttostr(kleur2)+'.txt');
Reset(myFile2);
regel:= 0;
while not Eof(myFile2) do
begin
ReadLn(myFile2, text);
regel:= regel+1;
if(regel > 2)then
begin
delimiter :='[';
master1:= text;
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ',';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found1 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
delimiter :=',';
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ']';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found2 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
pixelkleur[aantal] := kleur2;
pixelx[aantal] := strtoint(found1);
pixely[aantal] := strtoint(found2);
aantal := aantal+1;
end;
end;
CloseFile(myFile2);
AssignFile(myFile, inttostr(kleur3)+'.txt');
Reset(myFile);
regel:= 0;
while not Eof(myFile) do
begin
ReadLn(myFile, text);
regel:= regel+1;
if(regel > 2)then
begin
delimiter :='[';
master1:= text;
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ',';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found1 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
delimiter :=',';
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
delimiter := ']';
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found2 := copy(master1,(i+1),(j-i-1)); //Step 5
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
pixelkleur[aantal] := kleur3;
pixelx[aantal] := strtoint(found1);
pixely[aantal] := strtoint(found2);
aantal := aantal+1;
end;
end;
CloseFile(myFile);
if(selecs= 0)then
begin
for i:=0 to aantal-1 do
begin
Form6.StringGrid1.RowCount:= aantal;
Form6.StringGrid1.Cells[1,i] := inttostr(pixelkleur[i]);
Form6.StringGrid1.Cells[2,i] := inttostr(pixelx[i]);
Form6.StringGrid1.Cells[3,i] := inttostr(pixely[i]);
end;
end;
if(selecs= 1)then
begin
for i:=0 to aantal-1 do
begin
Form6.StringGrid2.RowCount:= aantal;
Form6.StringGrid2.Cells[1,i] := inttostr(pixelkleur[i]);
Form6.StringGrid2.Cells[2,i] := inttostr(pixelx[i]);
Form6.StringGrid2.Cells[3,i] := inttostr(pixely[i]);
end;
end;
if(selecs= 2)then
begin
for i:=0 to aantal-1 do
begin
Form6.StringGrid3.RowCount:= aantal+aantal2+aantal3;
Form6.StringGrid3.Cells[1,i] := inttostr(pixelkleur[i]);
Form6.StringGrid3.Cells[2,i] := inttostr(pixelx[i]);
Form6.StringGrid3.Cells[3,i] := inttostr(pixely[i]);
end;
end;
end;
for i:=0 to Form6.StringGrid1.RowCount-2 do
begin
for J:=i+1 to Form6.StringGrid1.RowCount-1 do
begin
firstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
secondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
firstx:= strtoint(Form6.StringGrid1.cells[2,i]);
firsty:= strtoint(Form6.StringGrid1.cells[3,i]);
secondx:= strtoint(Form6.StringGrid1.cells[2,j]);
secondy:= strtoint(Form6.StringGrid1.cells[3,j]);
verschilx:= secondx-firstx;
verschily:= secondy-firsty;
xt:=Form1.PageControl1.TabIndex+1;
goed:= 0;
for K:=0 to Form6.StringGrid1.RowCount-1 do
begin
if(strtoint(Form6.StringGrid1.cells[1,K]) = firstcolor)then
begin
//kleur 1 is goed
if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid1.cells[2,K]), strtoint(Form6.StringGrid1.cells[3,K])])then
begin
goed:= goed+1;
end;
end;
end;
goedvorig2:= goed;
goed:= 0;
for K:=0 to Form6.StringGrid2.RowCount-1 do
begin
if(strtoint(Form6.StringGrid2.cells[1,K]) = firstcolor)then
begin
//kleur 1 is goed
if(strtoint(Form6.StringGrid2.cells[2,K])+verschilx > 0)AND(strtoint(Form6.StringGrid2.cells[2,K])+verschilx < img[xt].Width)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily > 0)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily < img[xt].Height)then
begin
if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid2.cells[2,K])+verschilx, strtoint(Form6.StringGrid2.cells[3,K])+verschily])then
begin
goed:= goed+1;
end;
end;
end;
end;
if(goedvorig2<goed)then goed:= goedvorig2;
if(goed > goedvorig)then
begin
goedvorig:= goed;
gfirstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
gsecondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
gfirstx:= strtoint(Form6.StringGrid1.cells[2,i]);
gfirsty:= strtoint(Form6.StringGrid1.cells[3,i]);
gsecondx:= strtoint(Form6.StringGrid1.cells[2,j]);
gsecondy:= strtoint(Form6.StringGrid1.cells[3,j]);
//ShowMessage('gelukt');
end;
end;
end;
ShowMessage(inttostr(goedvorig));
Form6.StaticText1.Caption:= inttostr(gfirstcolor);
Form6.StaticText2.Caption:= inttostr(gfirstx);
Form6.StaticText3.Caption:= inttostr(gfirsty);
Form6.StaticText4.Caption:= inttostr(gsecondx);
Form6.StaticText5.Caption:= inttostr(gsecondy);
Form6.StaticText6.Caption:= inttostr(gsecondcolor);
end;
end.
i removed the other algoritmes.