Quipex icon

Untitled

Quipex | PRO | 01/28/16 10:08:43 PM UTC | 0 ⭐ | 10242 👁️ | Never ⏰ | []
Delphi |

1.88 KB

|

None

|

0 👍

/

0 👎

unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Button1: TButton;
    Image1: TImage;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
 
begin
  if timer1.Enabled=true then
    timer1.Enabled:=false
  else
    timer1.Enabled:=true;
end;
 
procedure TForm1.Timer1Timer(Sender: TObject);
var
  bmp:TBitmap;
  scrn, space:TImage;
begin
  bmp:=Tbitmap.Create;
  bmp.Width:=150;
  bmp.Height:=64;
  BitBlt(bmp.Canvas.Handle, 0, 0, screen.width, screen.Height, GetDC(0), (screen.width div 2)-73, 225, SRCCOPY);
  image1.picture.Assign(bmp);
  bmp.SaveToFile('1.png');
  scrn.LoadFromFile('1.png');
  space.LoadFromFile('space.png');
  CompareImages(scrn, space);
end;
 
 
procedure CompareImages(Image1, Image2: TImage);
var x, y: integer;
   differences: LongInt;
   line1, line2: PByteArray;
   procent: single;
const  porog=5;
begin
   differences:=0;
   for y:=0 to Image1.Picture.Bitmap.Height - 1 do begin
     line1:=Image1.Picture.Bitmap.ScanLine[y];
     line2:=Image2.Picture.Bitmap.ScanLine[y];
     for x:=0 to Image1.Picture.Bitmap.Width - 1 do
       if abs(line1[x] - line2[x]) > porog then
         inc(differences);
     if Image1.Picture.Bitmap.Height*Image1.Picture.Bitmap.Width>0 then
       procent:=100*(differences/(Image1.Picture.Bitmap.Height*
       Image1.Picture.Bitmap.Width))
     else
       procent:=0;
     if procent>50 then
     begin
      showmessage('rabotaet');
      Ttimer1.enable:=false;
     end;
   end;
end;
 
end.

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎