view bitmap 截图

引用:http://www.oschina.net/code/snippet_12_698

[代码] java代码

01 ImageView iv = (ImageView) findViewById(R.id.ImageView01);
02 ImageView iv2 = (ImageView) findViewById(R.id.ImageView02);
03 ImageView iv3 = (ImageView) findViewById(R.id.ImageView03);
04  
05 //draw的方式对整屏截取,但信息栏为黑色
06 View cv = getWindow().getDecorView(); 
07 Bitmap b = Bitmap.createBitmap(200200, Bitmap.Config.RGB_565); 
08 cv.draw(new Canvas(b));
09 iv.setImageBitmap(b);
10  
11 //对隐藏的未画过的对象,截出的是黑色
12 Bitmap image = Bitmap.createBitmap(200200, Bitmap.Config.RGB_565);
13 bt3.draw(new Canvas(image));
14 iv2.setImageBitmap(image);
15  
16 //get drawable cache , bitmap to drawable
17 bt4.setDrawingCacheEnabled(true);
18 Bitmap bitmap = bt4.getDrawingCache();
19 Drawable drawable = (Drawable) new BitmapDrawable(bitmap);
20 iv3.setBackgroundDrawable(drawable);

[图片] android-bitmap.jpg

posted @ 2011-09-23 16:46  镇水古月  阅读(285)  评论(0编辑  收藏  举报