Mapview - MakeScreenshot

Hi !

I'm trying to save a screenshot from the Mapview (MakeScreenshot).

For some reason i can;t get this to work.

Any examples in how to make a screenshot and save this locally or load this in an image ?

For instance, this ain't working :

Image3.Bitmap := iMapx.MakeScreenshot;

Cheers,

Paul

Hi,



MakeScreenShot is a FireMonkey feature en takes a picture of the canvas, the MapView is a real control

and doesn't have anything related to the FireMonkey canvas. MakeScreenShot is a feature from TControl which TTMSFMXNativeMKMapView inherits from.


Kind Regards,

Scheldeman Pieter
Pieter Scheldeman2013-07-15 02:35:15

Hi Pieter,

Ah, oke.

Thanks,

Cheers,

Paul

What you can try is the following


Implement the following code in your project:

function TForm1.renderToImage: UIImage;
begin
  UIGraphicsBeginImageContextWithOptions(TMSFMXNativeMKMapView1.MapView.frame.size, False, 0);
  TMSFMXNativeMKMapView1.MapView.layer.renderInContext(UIGraphicsGetCurrentContext);
  Result :=  TUIImage.Wrap(UIGraphicsGetImageFromCurrentImageContext);
  UIGraphicsEndImageContext;
end;

which returns a screenshot in UImage format from the TMSFMXNativeMKMapView

Hi Pieter,

Thanks for the snippet.

When i add this, i get an error, when i remove it, it compiles again.

Do i need to add some unit ?

And could you give me an example how to use it ?

Where can i find an UIImage to display it in / work with it for saving?

Thanks for the effort !

Cheers,

Paul

Hi,



Yes you will need to include some iOSApi units

You can show it directly in an TMSFMXNativeUIImageView with:

TMSFMXNativeUIImageView.ImageView.setImage



To save it you can use this code snippet in objectivec and translate it to

Delphi code after adding and finding the correct units.



http://iosdevelopertips.com/data-file-management/save-uiimage-object-as-a-png-or-jpeg-file.htmlPieter Scheldeman2013-07-16 01:14:11