How to take a screen shot programmatically on mapview

559 views
Skip to first unread message

inggo...@gmail.com

unread,
Jan 23, 2015, 9:04:18 PM1/23/15
to nutit...@googlegroups.com
Dear nutiteq,

is possible capture programmatically screenshot on mapview, not entire of layout ?
from my experience mapview keep blank than other view when i try to capture.


warm regards
inggo

Jaak Laineste (Nutiteq)

unread,
Jan 24, 2015, 3:08:29 AM1/24/15
to nutit...@googlegroups.com
Hi,

Right, Android general view snapshot methods do not capture OpenGL surfaces. In Nutiteq SDK 2.4 you need to use special method, see https://github.com/nutiteq/hellomap3d/wiki/Capture-map-image . For 3.0 similar is in near roadmap.

Jaak

--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

inggo...@gmail.com

unread,
Jan 26, 2015, 6:28:55 PM1/26/15
to nutit...@googlegroups.com
hi jaak,
Thx for fast response, now solved

thanks & regards
inggo

Jaak L

unread,
Jul 16, 2015, 10:46:42 AM7/16/15
to nutit...@googlegroups.com, inggo...@gmail.com

An update: Nutiteq SDK 3 has method for that also, code sample which saves screenshot to a folder as PNG file. It can be useful for automatic testing for example.

    private void captureMapScreen(MapView _mapView, final String captureName) {
        _mapView.captureRendering(new MapRenderListener(){

            @Override
            public void onMapRendered(com.nutiteq.graphics.Bitmap mapBitmap) {
                Bitmap bmp = com.nutiteq.utils.BitmapUtils.createAndroidBitmapFromBitmap(mapBitmap);
                FileOutputStream out = null;
                String dir = Environment.getExternalStorageDirectory().toString() + "/test-screenshots/";
                if(!new File(dir).exists()){
                    new File(dir).mkdirs();
                }
                String filename = dir + captureName ;
                System.out.println("will try to capture map to  "+filename);

                try {
                    out = new FileOutputStream(filename);
                    // Note: compress is a VERY SLOW operation, it would be much better to do this in a background thread!
                    bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
                    System.out.println("captured map to  "+filename);

                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } finally {
                    try {
                        if (out != null) {
                            out.close();
                        }
                    } catch (IOException e) {
                    }
                }           
            }
           
       
        }, false);
    }
Reply all
Reply to author
Forward
0 new messages