Android中图片转化为bitmap
来源:互联网 发布:mac下制作dmg到u盘 编辑:程序博客网 时间:2024/05/26 02:54
图片文件和Bitmap之间的转换
图片文件转为Bitmap对象
String filePath="c:/01.jpg";
Bitmap bitmap=BitmapFactory.decodeFile(filePath);
如果图片过大,可能导致Bitmap对象装不下图片
解决办法:
String filePath="c:/01.jpg";
Bitmap bitmap=BitmapFactory.decodeFile(filePath,getBitmapOption(2)); //将图片的长和宽缩小味原来的1/2
private BitmapFactory. Options getBitmapOption(int inSampleSize){
System.gc();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
options.inSampleSize = inSampleSize;
return options;
}
Bitmap对象保存味图片文件
public void saveBitmapFile(Bitmap bitmap){
File file=new File("/mnt/sdcard/pic/01.jpg");//将要保存图片的路径
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String filePath="c:/01.jpg";
Bitmap bitmap=BitmapFactory.decodeFile(filePath);
如果图片过大,可能导致Bitmap对象装不下图片
解决办法:
String filePath="c:/01.jpg";
Bitmap bitmap=BitmapFactory.decodeFile(filePath,getBitmapOption(2)); //将图片的长和宽缩小味原来的1/2
private BitmapFactory. Options getBitmapOption(int inSampleSize){
System.gc();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
options.inSampleSize = inSampleSize;
return options;
}
Bitmap对象保存味图片文件
public void saveBitmapFile(Bitmap bitmap){
File file=new File("/mnt/sdcard/pic/01.jpg");//将要保存图片的路径
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
0 0
- Android中图片转化为bitmap
- Android图片 将Drawable转化为Bitmap
- Android 将View 转化为bitmap 图片
- Android中Bitmap和Drawable Bitmap → byte[] byte[] → Bitmap Bitmap缩放 将Drawable转化为Bitmap 获得圆角图片
- Android图片操作-将Drawable转化为Bitmap
- Android图片的压缩和Bitmap转化为String传输
- Android Drawable 转化为 Bitmap
- 读取图片资源转化为bitmap对象
- 将图片网址url转化为bitmap
- Android将BitMap转化为圆形
- Android把drawable转化为bitmap
- Android中几种图像特效处理的小技巧,比如圆角,倒影,还有就是图片缩放,Drawable转化为Bitmap,Bitmap转化为Drawable等等
- 分享的是Android图像特效处理的小技巧,比如圆角、倒影、还有就是图片缩放、Drawable转化为Bitmap、Bitmap转化为Drawable等等
- Android中把View转化为图片的方法
- 图片(bitmap)转化为byte[],并上传到服务器
- 用HttpURLConnection下载图片并转化为Bitmap
- 将图片资源转化为Bitmap的多种方法
- 将图片的BitMap类转化为File文件
- 自定义View,画折线图
- memcached过时了吗
- Android 界面ListView使用
- ios 验证码倒计时
- yii的优点
- Android中图片转化为bitmap
- iOS发布app到App Store教程
- batch bat文件是dos下的批处理文件
- #学习笔记#(26)CSS3总结-慕课教程(部分)
- 繁华与落寞不过是过眼烟云
- linux常见基本命令之十八dd
- iOS开发笔记--cell最右边显示箭头,字符,自定义分割线
- 本人在安卓程序开发时用到的各种小功能(一) 屏幕截图
- iOS开发笔记--使用blend改变图片颜色