fresco 加载本地路径图片,并修改图片尺寸
2017-11-28 10:14
573 查看
mark
int width =100;//目标宽度 Postprocessor postprocessor = new Postprocessor() { @Override public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) { int sw = sourceBitmap.getWidth(); int sh = sourceBitmap.getHeight(); float scale = (float) width / (float) sw; int mscale = sw / width; float heigh = scale * (float) sh; int nscale = sh / (int) heigh; CloseableReference<Bitmap> bitmapRef = bitmapFactory.createBitmap( width, (int) heigh); try { Bitmap destBitmap = bitmapRef.get(); for (int x = 0, m = 0; x < destBitmap.getWidth() && m < sw; x++, m += mscale) { for (int y = 0, n = 0; y < destBitmap.getHeight() && n < sh; y++, n += nscale) { destBitmap.setPixel(x, y, sourceBitmap.getPixel(m, n)); } } return CloseableReference.cloneOrNull(bitmapRef); } finally { CloseableReference.closeSafely(bitmapRef); } } @Override public String getName() { return null; } @Override public CacheKey getPostprocessorCacheKey() { return null; }}; ImageRequest request = //此处是加载本地图片路径的图片 ImageRequestBuilder.newBuilderWithSource(Uri.parse("file://" + MyBimp.tempSelectBitmap.get(position).path)) .setPostprocessor(postprocessor) .build(); PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(holder.mainView.getController()) // other setters as you need .build(); mainView.setController(controller);
相关文章推荐
- fresco 加载本地路径图片,并修改图片尺寸
- fresco加载本地图片
- Android不加载获取网络、本地图片的尺寸
- jQuery在页面加载时动态修改图片尺寸的方法
- spring boot 本地图片不能加载(图片路径)的问题及解决方法
- 初学者---Android Fresco加载本地图片
- Mac 小技巧 - 批量修改本地图片尺寸
- android 加载图片本地有缓存,如何实时更新服务器上修改的图片
- fresco加载本地图片
- spring boot之本地图片不能加载(图片路径)的问题
- Fresco 加载本地图片
- 强大的 Fresco(加载网络和本地图片)简单使用
- fresco 加载本地gif图片
- ios的webView加载本地html图片路径显示及webview适配
- fresco 加载本地图片失败
- VS2008 VC 如何把图片等资源文件通过本地路径加载方式加载
- 使用Fresco加载本地图片,resource资源
- jsp页面加载本地路径图片显示
- 强大的 Fresco(加载网络和本地图片)简单使用
- Glide加载网络图片与本地图片尺寸不一致