gpt4 book ai didi

Andriod arcgis保存Mapview为图片的实例代码

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 31 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章Andriod arcgis保存Mapview为图片的实例代码由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

废话不多说了,直接给大家贴代码了,具体代码如下所述:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* 把一个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;
}
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 block
log.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为图片的实例代码,希望对大家有所帮助! 。

最后此篇关于Andriod arcgis保存Mapview为图片的实例代码的文章就讲到这里了,如果你想了解更多关于Andriod arcgis保存Mapview为图片的实例代码的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com