Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Draw Bitmap on Canvas ignoring Canvas scale?


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Oct 26, 2017 6:21 PM Last Post By: Dmitry Kirkinsky
Dmitry Kirkinsky

Posts: 10
Registered: 11/12/02
Draw Bitmap on Canvas ignoring Canvas scale?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2017 4:07 AM
Hello,

In case of complex drawing we use a classical scheme with a bitmap buffer: first draw to the buffer, and then draw the buffer on a Canvas inside the Paint method. Works perfect if current scale (Canvas.Scale) is 1, but results blurry picture if scale <> 1. We can consider the scale on the first step (increase object dimentions when drawing to the buffer), but how to put a bitmap on a canvas pixel-to-pixel, regardless of current scale?

Thanks.

-Dmitry

Edited by: Dmitry Kirkinsky on Oct 23, 2017 10:42 PM
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Draw Bitmap on Canvas ignoring Canvas scale?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 24, 2017 6:03 AM   in response to: Dmitry Kirkinsky in response to: Dmitry Kirkinsky
In the past you would get the screen scale and multiply your values by it so they would match with the scale of the canvas. Whether that is still the case for Tokyo I'm not sure.

function TImageCacheLayout.GetScreenScale: Single;
var
   ScreenService: IFMXScreenService;
begin
   Result := 1;
   if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then
   begin
      Result := ScreenService.GetScreenScale;
   end;
end;
Douglas Rudd

Posts: 314
Registered: 5/16/97
Re: Draw Bitmap on Canvas ignoring Canvas scale?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 25, 2017 12:48 PM   in response to: Dmitry Kirkinsky in response to: Dmitry Kirkinsky
"Canvas.Scale" doesn't add more pixels, does it? If it doesn't add more pixels then it makes sense that it would be blurry if you blow it up with Canvas.Scale.

Are you just changing the scale of a bitmap, or are you talking about changing the display scale like in Windows Display settings?
Dmitry Kirkinsky

Posts: 10
Registered: 11/12/02
Re: Draw Bitmap on Canvas ignoring Canvas scale?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 26, 2017 6:21 PM   in response to: Dmitry Kirkinsky in response to: Dmitry Kirkinsky
Thank you!
Found a simple solution: increase by ScreenScale the source area in Canvas.DrawBitmap.

-Dmitry
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02