我处理图片的方法如下:
public static Bitmap getPicture(String fileName) {
Bitmap bm = null;
if (fileName != null) {
File file = new File(fileName);
if (file.exists()) {
try {
long size = file.length();
Log.i("picturePath",fileName);
if (size <= 3 * 102 * 1024) {
bm = BitmapFactory.decodeFile(fileName);
} else if (size <= 5 * 1024 * 1024) {
bm = BitmapFactory.decodeFile(fileName,
BitmapTool.getTempStorage((int) file.length()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return bm;
}
public static BitmapFactory.Options getTempStorage(int size){
BitmapFactory.Options option = new BitmapFactory.Options();
option.inTempStorage = new byte[size];
return option;
}
图片大于1m后得到的bitmap就老是为null 请高手帮忙解决。
public static Bitmap getPicture(String fileName) {
Bitmap bm = null;
if (fileName != null) {
File file = new File(fileName);
if (file.exists()) {
try {
long size = file.length();
Log.i("picturePath",fileName);
if (size <= 3 * 102 * 1024) {
bm = BitmapFactory.decodeFile(fileName);
} else if (size <= 5 * 1024 * 1024) {
bm = BitmapFactory.decodeFile(fileName,
BitmapTool.getTempStorage((int) file.length()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return bm;
}
public static BitmapFactory.Options getTempStorage(int size){
BitmapFactory.Options option = new BitmapFactory.Options();
option.inTempStorage = new byte[size];
return option;
}
图片大于1m后得到的bitmap就老是为null 请高手帮忙解决。
解决方案 »
- strings.xml 文件中使用占位符修改键值对失败??
- 怎么实现当点击通知栏的推送时不产生任何动作
- prepareAsync called in state 1
- jni中2个.c文件数值传导问题
- android从数据库(MSDB)读取图片并显示
- bitmap.createbitmap 下标越界
- 跪求CTS高手指导
- 关于Email同步,请高手指教
- OnCreate中 setTheme(R.style.xxx)为什么不行?
- 请教一些android gallery的问题!!!!!求牛人的解答。。。。
- android状态栏中的3G、信号等图标怎么从右边弄到左边?
- Android的java程序如何调用init.rc中注册服务?
你查下哪有设置内存的地方
ByteArrayOutputStream out = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 50, out);
return out;
}
此方法可将原有Bitmap压缩50%质量,这样图片就小很多