Android关于Bitmap的几个方法
2015-01-30 22:01
344 查看
1.保存Bitmap到SD卡
2.缩小Bitmap
3.View转换成Bitmap
private String ALBUM_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/"; private void saveFile(Bitmap bm) throws IOException { File dirFile = new File(ALBUM_PATH); if (!dirFile.exists()) { dirFile.mkdir(); } File myCaptureFile = new File(ALBUM_PATH + "bitmap.jpeg"); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile)); bm.compress(Bitmap.CompressFormat.JPEG, 80, bos); bos.flush(); bos.close(); }
2.缩小Bitmap
private Bitmap smallBitmap(Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.postScale(0.33f, 0.33f); // 长和宽放大缩小的比例 Bitmap resizeBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return resizeBmp; }
3.View转换成Bitmap
private Bitmap convertViewToBitmap(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); view.draw(new Canvas(bitmap)); return bitmap; }
相关文章推荐
- 关于android 画图机制中几个方法的说明
- 关于android中bitmap使用时的oom的一些解决方法
- Android-Activity关于“菜单(Menu)”的几个方法
- 关于android程序中使用bitmap放大功能时的OOM问题解决方法
- Android关于百度地图开发的几个常用方法
- Android中的关于MDM中的几个方法举例
- Android几个bitmap相关的方法
- Android 将Bitmap转换成圆形图片的几个方法总结
- Android关于looper的几个方法的个人理解
- 关于Android开发保存bitmap获取图片到本地方法
- Android关于图片处理及Bitmap处理的几种方法
- Android中的关于MDM中的几个方法举例
- [Android Pro] 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法
- android中关于bitmap造成的OOM内存溢出防止方法
- 关于Android虚拟器无法联网的解决方法
- 关于入侵最多的几个端口的系统关闭方法
- 关于编译android时出现Error 41的解决方法
- Android Adapter 接口中几个方法的研究
- android 获取Bitmap 的两种方法
- 关于IIS服务器的不能开ASP的几个解决方法