Hello im using this code to get the screen on a canvas
procedure GetScreen(var vBitmap : TBitmap);
var vDC : hdc;
vCanvas : TCanvas;
begin
vDC := GetDC(0);
vCanvas := TCanvas.Create;
vCanvas.Handle := vDC;
vBitmap.Canvas.CopyRect(Rect(0, 0, Screen.Width, Screen.Height),
vCanvas,
Rect(0, 0, Screen.Width, Screen.Height));
vCanvas.Free;
ReleaseDC(0, vDC);
end;
which takes about 20 ms to execute, having that i run in each pixel and compare with a given color using this function
function CompareColor(Color1, Color2 : TRGBTriple): Double;
var vR, vG, vB : Byte;
begin
vR := abs(Color1.rgbtRed - Color2.rgbtRed);
vG := abs(Color1.rgbtGreen - Color2.rgbtGreen);
vB := abs(Color1.rgbtBlue - Color2.rgbtBlue);
Result := (((vR + vG + vB) / 3) / 255);
end;
but since i need to convert each TColor to a TRGBTriple
vCorCmp.rgbtRed := GetRValue(vBitmap.Canvas.Pixels[nX, nY]);
vCorCmp.rgbtGreen := GetGValue(vBitmap.Canvas.Pixels[nX, nY]);
vCorCmp.rgbtBlue := GetBValue(vBitmap.Canvas.Pixels[nX, nY]);
i lose more than a second to convert the entire TCanvas, my question is, how can i get an TRGBTriple array of the screen instead of a TColor array?