您的位置:首页 > 移动开发 > Android开发

ArcGIS for Android 中MapView截图实现方法

2012-06-20 14:48 826 查看
/**

* 把一个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;

}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: