AbsoluteToLocal does not work on Android as on Windows

  

I’m trying to get coordinates inside of a control 1 by using another control 2 that’s in front of it. To simplify, Control 1 is used as a background, and control 2 is a small rectangle that can be moved above control 1. When the user presses a button, I want to get the part of the background (control 1) that the rectangle (control 2) is over, and to achieve that I’m using AbsoluteToLocal and LocalToAbsolute. Furthermore, I want to save the selection into a 125×125 bitmap, no matter how big the user’s selection actually is. Here’s the code:
function TForm1.CropImage: TBitmap;
var
LSourceBitmap: TBitmap;
LDestinationBitmap: TBitmap;
LSourceRect: TRectF;
LDestRect: TRectF;
begin
LSourceBitmap := Control1.MakeScreenshot;
LSourceRect.TopLeft := Control1.AbsoluteToLocal(Circle1.LocalToAbsolute(TPointF.Create(0, 0)));
LSourceRect.BottomRight := Control1.AbsoluteToLocal(Circle1.LocalToAbsolute(TPointF.Create(Circle1.Width, Circle1.Height)));

LDestRect := TRectF.Create(0, 0, 125, 125);
LDestinationBitmap := TBitmap.Create;
LDestinationBitmap.Width := 125;
LDestinationBitmap.Height := 125;
LDestinationBitmap.Canvas.BeginScene;
LDestinationBitmap.Canvas.DrawBitmap(LSourceBitmap, LSourceRect, LDestRect, 1);
LDestinationBitmap.Canvas.EndScene;
LSourceBitmap.Free;
Result := LDestinationBitmap;
end;

This function works just as it should on Windows, but when tried on Android, it gets a totally different part of the control 1. Problem is that I cannot debug the values since they depend on the screen’s resolution.
Maybe I’m using the functions incorrectly, but I can’t see the problem in code here. Any ideas?

Comments are closed.