急求android系统图库的图片放大操作的实现啊 楼主要的是不是这种功能http://blog.csdn.net/guolin_blog/article/details/11100327 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 图片的局部解析不是很难,网上也有很多例子。还有,我不记得系统图片都有什么功能,但是我知道android系统图库是有源代码的,如果有你要的功能可以参考一下源代码。 这篇文章的功能基本实现了,主要是要实现放大图片,保证图片质量并不能OOM的功能 你把图片放到一个固定大小的layout里。设置图片的模式为fix:imageView.setScaleType(ImageView.ScaleType.FIT_XY); 这篇文章的功能基本实现了,主要是要实现放大图片,保证图片质量并不能OOM的功能楼主仔细看看,他那个缩放不是decode的,所以不会oom的 这篇文章的功能基本实现了,主要是要实现放大图片,保证图片质量并不能OOM的功能楼主仔细看看,他那个缩放不是decode的,所以不会oom的我用了一张近4000*4000分辨率的图片还是内存溢出了 那肯定不行,4000 * 4000 decode出来有多少m了很大很大了。4000 * 4000 要先进行缩放处理才行 对啊,就是要缩放,但是我就是想放大的时候能够保证质量,不知道怎么实现了。另外,如果放大到原图大小,那不还是会OOM吗? public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) { // 第一次解析将inJustDecodeBounds设置为true,来获取图片大小 final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(res, resId, options); // 调用上面定义的方法计算inSampleSize值 options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); // 使用获取到的inSampleSize值再次解析图片 options.inJustDecodeBounds = false; return BitmapFactory.decodeResource(res, resId, options); } public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { // 源图片的高度和宽度 final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { // 计算出实际宽高和目标宽高的比率 final int heightRatio = Math.round((float) height / (float) reqHeight); final int widthRatio = Math.round((float) width / (float) reqWidth); // 选择宽和高中最小的比率作为inSampleSize的值,这样可以保证最终图片的宽和高 // 一定都会大于等于目标的宽和高。 inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; } return inSampleSize; } 只能先缩放变小,要不然decode只能是oom,然后放大再用那个方法 android back mp3播放器后台运行的问题 怎样才能学好java,让编程的路走的更远? android 从SD卡导入vCard文件到通讯录 号码带"-" 如何把横线去除 android dialog source not found 如何获取内存使用情况、手机号码等系统信息? 自定义的静态广播没有作用怎么办? Android项目打包成jar在另一个项目中使用报错。 求教游戏框架学习方向 安卓空指针问题,实在找不到,求大佬指点 (求助)本地Android源码与网上他人文章所述不一样 ViewPaper实现滑屏切换页面及动画效果(仿优酷客户端)
我用了一张近4000*4000分辨率的图片还是内存溢出了
很大很大了。4000 * 4000 要先进行缩放处理才行
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// 第一次解析将inJustDecodeBounds设置为true,来获取图片大小
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// 调用上面定义的方法计算inSampleSize值
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// 使用获取到的inSampleSize值再次解析图片
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
} public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
// 源图片的高度和宽度
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// 计算出实际宽高和目标宽高的比率
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// 选择宽和高中最小的比率作为inSampleSize的值,这样可以保证最终图片的宽和高
// 一定都会大于等于目标的宽和高。
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
只能先缩放变小,要不然decode只能是oom,然后放大再用那个方法