ArcGIS for Android 中MapView截图实现方法

来源:互联网 发布:下载gif软件 编辑:程序博客网 时间:2024/04/28 12:35
/**
     * 把一个View的对象转换成bitmap
     */
    private Bitmap getViewBitmap(MapView v) {
     
        v.clearFocus();
        v.setPressed(false);


        //能画缓存就返回false
        boolean willNotCache = v.willNotCacheDrawing();
        v.setWillNotCacheDrawing(false); 
        int color = v.getDrawingCacheBackgroundColor();
        v.setDrawingCacheBackgroundColor(0);
        if (color != 0) {
            v.destroyDrawingCache();
        }
        v.buildDrawingCache();
        Bitmap cacheBitmap = null;
        while(cacheBitmap == null){
         cacheBitmap = v.getDrawingMapCache(0, 0, v.getWidth(), v.getHeight());
        }
        Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
        // Restore the view
        v.destroyDrawingCache();
        v.setWillNotCacheDrawing(willNotCache);
        v.setDrawingCacheBackgroundColor(color);
        return bitmap;
    }
	
				
		
原创粉丝点击