// Get the source image's dimensions BitmapFactory.Options options = new BitmapFactory.Options(); // This does not download the actual image, just downloads headers. options.inJustDecodeBounds = true; BitmapFactory.decodeFile(IMAGE_FILE_URL, options); // The actual width of the image. int srcWidth = options.outWidth; // The actual height of the image. int srcHeight = options.outHeight; // Only scale if the source is bigger than the width of the destination view. if(desiredWidth > srcWidth) desiredWidth = srcWidth; // Calculate the correct inSampleSize/scale value. This helps reduce memory use. It should be a power of 2. int inSampleSize = 1; while(srcWidth / 2 > desiredWidth){ srcWidth /= 2; srcHeight /= 2; inSampleSize *= 2; } float desiredScale = (float) desiredWidth / srcWidth; // Decode with inSampleSize options.inJustDecodeBounds = false; options.inDither = false; options.inSampleSize = inSampleSize; options.inScaled = false; // Ensures the image stays as a 32-bit ARGB_8888 image. // This preserves image quality. options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(IMAGE_FILE_URL, options); // Resize Matrix matrix = new Matrix(); matrix.postScale(desiredScale, desiredScale); Bitmap scaledBitmap = Bitmap.createBitmap(sampledSrcBitmap, 0, 0, sampledSrcBitmap.getWidth(), sampledSrcBitmap.getHeight(), matrix, true); sampledSrcBitmap = null; // Save FileOutputStream out = new FileOutputStream(LOCAL_PATH_TO_STORE_IMAGE); scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); scaledBitmap = null;
相关推荐
listview获取网络图片缓存优化
listview获取网络图片缓存优化.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
Android--从系统Camera和Gallery获取图片优化http://www.cnblogs.com/plokmju/p/android_BitmapRecycle.html
listview获取网络图片缓存优化.rar
安卓Android源码——listview获取网络图片缓存优化.zip
Android listview获取网络图片缓存优化源码.zip
Android高级应用源码-listview获取网络图片缓存优化.zip
Android应用源码之listview获取网络图片缓存优化_网络
Android应用源码之listview获取网络图片缓存优化.rar
Android应用源码之listview获取网络图片缓存优化.zip
安卓Andriod源码——listview获取网络图片缓存优化.zip
安卓Android源码——listview获取网络图片缓存优化.rar
安卓开发-listview获取网络图片缓存优化.zip
本地图片查看 本地图片上传 本地图片加载优化 适合Android前端本地图片加载,实现QQ空间上传多种图片的效果
图片ALT属性的本意主要是当图片因某些原因不能正常显示的时候,网页访问者也能够通过属性文本判断该图片的内容,其原本意义是为了用户正确了解网页信息而不是为了搜索引擎。 网站优化与ALT标签 网站优化从根本上...
listview获取网络图片缓存优化.zip项目安卓应用源码下载listview获取网络图片缓存优化.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
listview获取网络图片缓存优化.zip安卓程序源码资源下载listview获取网络图片缓存优化.zip安卓程序源码资源下载 1.学生做毕业设计用 2.程序员学习研究用 3.小公司换皮做新项目用
图片处理软件源代码(打开图片带预览功能,获取图像的属性,虑镜功能,锐化,模糊,浮雕,缩放,优化图片。能处理gif,bmp,jpg,png图片.zip