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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,I mage1);
For LoopX := 0 To 10 Do
For LoopY := 0 To 10 Do
Begin
MyColour:=(GetRValue(Image 1.Canvas.P ixels[Loop X,LoopY])* 65536) +(GetGValue(Image1.Canvas. Pixels[Loo pX,LoopY]) *256)+GetB Value(Imag e1.Canvas. Pixels[Loo pX,LoopY]) ;
TotalColour :=TotalColour + MyColour;
Counter:=Counter+1;
End;
If Round(TotalColour / Counter) = 9979744 Then
Begin
CheckResult := True;
End;
MsgBox(FloatToStr(TotalCol our/Counte r),'Awesom e',Flag);
IsButton:=CheckResult;
End;
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,I
For LoopX := 0 To 10 Do
For LoopY := 0 To 10 Do
Begin
MyColour:=(GetRValue(Image
TotalColour :=TotalColour + MyColour;
Counter:=Counter+1;
End;
If Round(TotalColour / Counter) = 9979744 Then
Begin
CheckResult := True;
End;
MsgBox(FloatToStr(TotalCol
IsButton:=CheckResult;
End;
ASKER
Nevermind! I was being dumb and not initialising the image... neede the line Image1 := TBitMap.Create;
Thanks for your help everyone!
Thanks for your help everyone!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See http://edn.embarcadero.com/article/29173