android - FireMonkey TControl.MakeScreenshot generates an undersized bitmap on Mobile platforms -


i trying generate bitmap tlayout control. i'm using tcontrol.makescreenshot function. when testing application on windows, works expected:

windows

however, when running application on ios, android (both emulators , real devices), result looks (the red border around image drawn inside border of bitmap):

ios screenshot

in mobile version image half size , border cropped.

here's code used:

(.pas)

unit unit15;  interface  uses   system.sysutils, system.types, system.uitypes, system.classes, system.variants,   fmx.types, fmx.controls, fmx.forms, fmx.graphics, fmx.dialogs, fmx.stdctrls,   fmx.objects, fmx.layouts, fmx.edit;  type   tform15 = class(tform)     layout1: tlayout;     image1: timage;     button1: tbutton;     checkbox1: tcheckbox;     label1: tlabel;     switch1: tswitch;     arcdial1: tarcdial;     edit1: tedit;     edit2: tedit;     procedure button1click(sender: tobject);     procedure formresize(sender: tobject);   private     { private declarations }   public     { public declarations }   end;  var   form15: tform15;  implementation  {$r *.fmx}  procedure tform15.button1click(sender: tobject); begin   image1.bitmap := layout1.makescreenshot;   image1.bitmap.canvas.beginscene;   try     image1.bitmap.canvas.stroke.color := talphacolorrec.red;     image1.bitmap.canvas.drawrect(rectf(1, 1, image1.bitmap.width - 1, image1.bitmap.height - 2), 0, 0, [], 1);       image1.bitmap.canvas.endscene;   end;    edit1.text := format('image = width: %d - height: %d', [image1.bitmap.width, image1.bitmap.height]);   edit2.text := format('original = width: %d - height: %d', [round(layout1.width), round(layout1.height)]); end;  procedure tform15.formresize(sender: tobject); begin   layout1.height := clientheight div 2; end;  end. 

(.fmx)

object form15: tform15   left = 0   top = 0   caption = 'form15'   clientheight = 460   clientwidth = 320   formfactor.width = 320   formfactor.height = 480   formfactor.devices = [dkdesktop]   onresize = formresize   designermobile = true   designerwidth = 320   designerheight = 480   designerdevicename = 'iphone'   designerorientation = 0   designerosversion = '6'   object layout1: tlayout     align = altop     clipchildren = true     height = 233.000000000000000000     width = 320.000000000000000000     object button1: tbutton       height = 44.000000000000000000       position.x = 8.000000000000000000       position.y = 8.000000000000000000       taborder = 0       text = 'click create bitmap'       trimming = ttcharacter       width = 201.000000000000000000       onclick = button1click     end     object checkbox1: tcheckbox       height = 23.000000000000000000       position.x = 24.000000000000000000       position.y = 56.000000000000000000       taborder = 1       text = 'checkbox1'       width = 120.000000000000000000     end     object label1: tlabel       height = 23.000000000000000000       position.x = 24.000000000000000000       position.y = 88.000000000000000000       text = 'label1'       width = 82.000000000000000000       trimming = ttcharacter     end     object switch1: tswitch       height = 27.000000000000000000       ischecked = false       position.x = 24.000000000000000000       position.y = 120.000000000000000000       taborder = 3       width = 78.000000000000000000     end     object arcdial1: tarcdial       height = 81.000000000000000000       position.x = 216.000000000000000000       position.y = 16.000000000000000000       taborder = 4       width = 97.000000000000000000     end     object edit1: tedit       touch.interactivegestures = [iglongtap, igdoubletap]       taborder = 5       position.x = 8.000000000000000000       position.y = 192.000000000000000000       width = 305.000000000000000000       height = 31.000000000000000000       killfocusbyreturn = false     end     object edit2: tedit       touch.interactivegestures = [iglongtap, igdoubletap]       taborder = 6       position.x = 8.000000000000000000       position.y = 152.000000000000000000       width = 305.000000000000000000       height = 31.000000000000000000       killfocusbyreturn = false     end   end   object image1: timage     multiresbitmap = <       item       end>     align = alclient     height = 227.000000000000000000     marginwrapmode = iworiginal     width = 320.000000000000000000     wrapmode = iworiginal   end end 

is problem pixel density or firemonkey bug?

firemonkey has special property tbitmap, allow said canvas, bitmap should draw different sacle. example scale = 2. please, use next approach:

  1. make bitmap physical size (for example on scale=2 screen, physicalwidth = logicalwidth * scale)
  2. (bitmap ibitmapaccess).bitmapscale = 2

after tcanvas draw bitmap increased quality.

please, @ article: http://fire-monkey.ru/page/articles/_/articles/graphics/graphics-screenshot

it on russia, code on english :-) , use code article suggestion above ((bitmap ibitmapaccess).bitmapscale = 2)

thank you


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -