![]() |
|
#5
|
||||
|
||||
![]() Возможно вам этот код знаком (вариант как предложил poli-smen )
Код:
... type FRes = record found: boolean; x,y: integer; end; ... TBuf = array of array of integer; var ... FindResult: FRes; buf1, buf2: TBuf; ... procedure ReadIMG(var buffer: TBuf; img: TImage); var x,y,c: integer; p: pByteArray; begin img.Picture.Bitmap.PixelFormat:=pf24Bit; // pf8Bit; SetLength(buffer, img.Height, img.Width); for y:=0 to img.Height-1 do begin p:=img.Picture.Bitmap.ScanLine[y]; for x:=0 to img.Width-1 do begin c:=((p[x*3+0] shl 8+p[x*3+1]) shl 8)+p[x*3+2]; buffer[y,x]:=c; end; end; end; function CompareIMGS(Im1:TImage; Im2:TImage): FRes; var y, x, yy, xx: integer; begin ReadIMG(buf2, Im2); y:=0; repeat x:=0; repeat Result.found:=true; yy:=0; repeat xx:=0; repeat if buf1[y+yy, x+xx]<>buf2[yy,xx] then Result.found:=false; inc(xx); until (xx>=Im2.Width) or (Not Result.found); inc(yy); until (yy>=Im2.Height) or (Not Result.found); inc(x); until (x>Im1.Width-Im2.Width) or (Result.found); inc(y); until (y>Im1.Height-Im2.Height) or (Result.found); if Result.found then begin Result.x:=x-1; Result.y:=y-1; end; end; Код:
procedure TForm1.Timer1Timer(Sender: TObject); begin FindResult:= CompareIMGS(Image1, Image2); // сравниваемые скрины if FindResult.found then ... // различий нет else ... // есть несовпадения end; Я не понял Вашего вопроса, но всё же Вам на него отвечу! |