mewindy 0 Posted February 13, 2019 (edited) HI I am wanting to capture to a bitmap the contents of a paintbox after doing a paintto that on FMX (sample code is for VCL. eg using copyrect) 🙂 Thanks! Brian  edit I got it to work 🙂 using this code on the onpaint event on the paintbox (I create formimage bitmap first)  var  aRect: TRectF; begin   aRect := RectF(0,0,formimage.Width,formimage.Height);  Canvas.DrawBitmap(formimage, aRect, PaintBox1.ClipRect, 1, False); end;  edit that works ok on windows for copying the contents of a form (i.e form1.paintto) but that only ends up with a blank image when run on OSX (Mac) I know you can use a tlayout and use makescreenshot but that does not always capture all the elements on the form  is there a way to capture the contents of a tlayout some other way ? (on OSX/FMX) Edited February 13, 2019 by mewindy Share this post Link to post
Remy Lebeau 1393 Posted February 14, 2019 (edited) 6 hours ago, mewindy said: I am wanting to capture to a bitmap the contents of a paintbox You can't, as TPaintBox is painted dynamically on an as-needed basis, so there is no persistent image to "capture". You need to change your drawing code to draw onto a TBitmap (or any arbitrary TCanvas) instead, and wrap that code into a function that you can call whenever needed. That way, when the TPaintBox needs to be painted, create a temp TBitmap, have the function draw onto it, and then draw that TBitmap onto the TPaintBox. When you want to do the "capture", create another temp TBitmap, have the function draw onto it, and then use the TBitmap as needed.  This applies to both VCL and FMX, BTW. Edited February 14, 2019 by Remy Lebeau Share this post Link to post