国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Andriod arcgis保存Mapview為圖片的實例代碼

2020-01-02 07:01:44
字體:
來源:轉載
供稿:網友

廢話不多說了,直接給大家貼代碼了,具體代碼如下所述:

/*** 把一個View的對象轉換成bitmap*/private Bitmap getViewBitmap(MapView v) {v.clearFocus();v.setPressed(false);//能畫緩存就返回falseboolean 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 viewv.destroyDrawingCache();v.setWillNotCacheDrawing(willNotCache);v.setDrawingCacheBackgroundColor(color);return bitmap;}public void saveMyBitmap(String bitName,Bitmap mBitmap){String FileName=this.getInnerSDCardPath() + "/" + bitName + ".png";ShowMessage(FileName);File f = new File(FileName);try {f.createNewFile();} catch (IOException e) {// TODO Auto-generated catch blockLog.e("在保存"+FileName+"圖片時出錯:" + e.toString(),"在保存"+FileName+"圖片時出錯:" + e.toString());}FileOutputStream fOut = null;try {fOut = new FileOutputStream(f);} catch (FileNotFoundException e) {e.printStackTrace();}mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);try {fOut.flush();} catch (IOException e) {e.printStackTrace();}try {fOut.close();} catch (IOException e) {e.printStackTrace();}}//縮小private class ButtonNexitClickListener implements View.OnClickListener {public void onClick(View v) {//ShowMessage("ok1");Bitmap bitmap=getViewBitmap(mapView);//ShowMessage("ok2");saveMyBitmap("yl",bitmap);//ShowMessage("ok3");bitmap.recycle();ShowMessage("保存成功");}}

以上所述是小編給大家介紹的Andriod arcgis保存Mapview為圖片的實例代碼,希望對大家有所幫助!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赣州市| 响水县| 巢湖市| 罗定市| 逊克县| 巫溪县| 龙南县| 四会市| 香河县| 海丰县| 潞城市| 仁怀市| 秦皇岛市| 博湖县| 河北区| 古交市| 称多县| 泽库县| 浪卡子县| 噶尔县| 上林县| 收藏| 名山县| 冕宁县| 文登市| 五莲县| 丰都县| 图木舒克市| 黄梅县| 太谷县| 蒙阴县| 慈利县| 泽州县| 满城县| 来安县| 建湖县| 衡山县| 宝坻区| 含山县| 荆门市| 安新县|