简体   繁体   中英

Firemonkey XE6:How to use the full resolution on my adroiddevice?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM