I am very new to multi device programming in XE10 Firemonkey and wonder if someone can help me with a problem reading the pixel colour from a bitmap.
What I want to do is sample a colour from a bitmap in a Timage control (like the way an eyedropper colour sampler works). I am showing the colour under the cursor in a TRectangle control.
This is my code in an onmousemove event over the image
procedure TMountboardForm.imagemountboardMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Single);
var
vBitMapData : TBitmapData;
ASelectionColor : TAlphaColor;
begin
if imagemountboard.bitmap.Map (TMapAccess.maread, vBitMapData) then
begin
try
ASelectionColor := vBitmapData.GetPixel (round(X), round(Y));
finally
imagemountboard.bitmap.Unmap(vBitMapData);
end;
rectangle1.Fill.Color := ASelectionColor;
end;
end;
This 'sort-of' works but the X & Y coordinates appear to be wrong. It picks up a colour some way away from the cursor rather than the colour under the cursor itself
Can someone tell me where I am going wrong?