3
votes

I'am building a Firmonkey mobile application.

I have a phone (Galaxy S3). the absolute resolution of this device is 1280 x 720. When I ask for canvas.width i get 640x360. I know that Scale, is the connection between absolute resolute, and what canvas size is.

My problem. When I draw a line on the canvas, with thickness := 1, then i want the line to be as thin as possible.

If I do this:

if Self.Canvas.BeginScene then
    try
      Self.Canvas.Stroke.Thickness := 1;
      Self.Canvas.Stroke.Kind := TBrushKind.Solid;
      Self.Canvas.Fill.Color := TAlphaColorRec.Black;
      Self.Canvas.Fill.Kind := TBrushKind.Solid;
      for I := 1 to 20 do
        Self.Canvas.DrawLine(PointF((I * 30), 0), PointF((I * 20), ClientHeight), 1);
    finally
      Self.Canvas.Canvas.EndScene;
    end;

These lines will not be equaly "thin" on my display. If compiled to windows, it works as it should.

Further more: If i want to display a picture that has dimensions which exactly matches my device absolute resolution (1280x780), then this picture is not showed perfect, but resized to some lower resolution (equal to the canvas)...

So how on earth can I make my canvas to access EVERY pixels on my device, so I can control every pixels myself???

I've been to the page: http://www.fmxexpress.com/perfect-line-thickness-using-tcanvas-drawline-with-delphi-xe5-firemonkey-on-android-and-ios/ But this is a wok around (that does not work). I does not help getting/using the absolute resolution.

1
On Z1 its FullHD... and you can't even create fullhd form... wth?Flash Thunder
Dont understand your question. I want to have to the resoultion a device has, not just the lower resolutoin the Firemonkeycanvas give me. If a draw a line with thickness := 1, then on my android device, it is not as thin as the device could draw. Prehaps it's 2 or 3 pixels...user3628465
It seeems to be basically unpossible... you can set form with and height to fullhd but then there may be a problem with downsizing...Flash Thunder

1 Answers

1
votes

In your case Canvas.Scale is 2. Because Canvas.Scale can not be set, drawing with native device resolution can be done inverting scaling with Canvas.SetMatrix.

Canvas.SetMatrix(TMatrix.CreateScaling(1 / Canvas.Scale, 1 / Canvas.Scale) * Canvas.Matrix);

After this you will draw at native device resolution.