Link to home
Start Free TrialLog in
Avatar of cr38
cr38

asked on

Does anyone know how to do a fast Delphi Getpixel anywhere on the screen?

I am busy doing some delphi coding. I am doing a block getpixel (about 50x50 pixels). It is really slow and I need to speed up the process. I am running Windows 7 64 Bit ultimate but in my mind it is currently way slower than it should be. Could someone please help?
Avatar of ebob42
ebob42
Flag of Netherlands image

Check out the ScanLine function

See http://edn.embarcadero.com/article/29173
ASKER CERTIFIED SOLUTION
Avatar of ThievingSix
ThievingSix
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cr38
cr38

ASKER

Thanks guys...but "ThievingSix" I have a question...If I screenshot the pixel I assume I set the width and height to 1 in that procedure and x and y are the co-ordinates. But now it puts the information in the TBitMap handle. Is that the same as TColor because I called a single pixel? Sorry a bit of a noob at this...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cr38

ASKER

Here is my code and its breaking...

Function IsButton : Boolean;

Var
 LoopX,LoopY : Integer;
 TotalColour,MyColour : Real;
 Counter : Integer;
 ImageCanvas : TCanvas;
 CheckResult : Boolean;
 Image1 : TBitMap;
 Flag : DWord;

Begin
 CheckResult :=False;
 TotalColour:=0;
 Counter :=0;


 ScreenShot(580,540,11,11,Image1);
 For LoopX := 0 To 10 Do
  For LoopY := 0 To 10 Do
  Begin
   MyColour:=(GetRValue(Image1.Canvas.Pixels[LoopX,LoopY])*65536) +(GetGValue(Image1.Canvas.Pixels[LoopX,LoopY])*256)+GetBValue(Image1.Canvas.Pixels[LoopX,LoopY]);
   TotalColour :=TotalColour + MyColour;
   Counter:=Counter+1;
  End;
 If Round(TotalColour / Counter) = 9979744 Then
 Begin
  CheckResult := True;
 End;
 MsgBox(FloatToStr(TotalColour/Counter),'Awesome',Flag);
 IsButton:=CheckResult;
End;
Avatar of cr38

ASKER

Nevermind! I was being dumb and not initialising the image... neede the line Image1 := TBitMap.Create;

Thanks for your help everyone!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial