Android捏缩放大图,内存高效不丢失细节

Android pinch zoom large image, memory efficient without losing detail(Android捏缩放大图,内存高效不丢失细节)

本文介绍了Android捏缩放大图,内存高效不丢失细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用要显示多张高分辨率图片(约 1900*2200 像素),支持捏合缩放.为了避免内存不足错误,我计划使用解码图像以显示全屏

My app has to display a number of high resolution images (about 1900*2200 px), support pinch zoom. To avoid Out of memory error I plan to decode image to show full screen by using

options.inSampleSize = scale (scale was calculated as Power of 2 as Document)

(我使用的视图是 TouchImageView 扩展了 ImageView)

(My view i used is TouchImageView extends of ImageView)

所以我可以快速加载图像并在屏幕(图像)之间平滑滑动.但是,当我捏​​缩放时,我的应用会因为缩放图像而丢失细节.如果我加载完整图像,我无法快速加载或平滑滑动,在捏缩放后拖动.然后我尝试仅在用户开始捏缩放时加载完整图像,但由于图像非常大,我仍然无法平滑拖动图像.即使是 8Mpx 的图片,Android 库也能做到完美.

So i can quickly load image and swipe smoothly between screens(images). However, when i pinch zoom, my app loses detail because of scaled image. If i load full image, i can't load quickly or smoothly swipe, drag after pinch zoom. Then i try to only load full image when user begin pinch-zooming, but i still can't drag smoothly image because of very large image. Android gallery can do it perfectly even 8Mpx images.

任何人都可以帮助我.提前致谢

Anyone can help me. Thanks in advance

推荐答案

很抱歉回答了一个老问题,但我刚刚完成了一个图像视图,它显示了来自资产或外部存储的图像,带有二次采样,并加载了更高分辨率的图块捏放大时从图像中提取.由于未加载屏幕区域的高分辨率图像数据,因此应避免内存不足异常.

Sorry to answer an old question, but I've just completed an image view that shows an image from assets or external storage with subsampling, and loads higher resolution tiles from the image as you pinch to zoom in. As high resolution image data for areas of the screen is not loaded it should avoid out of memory exceptions.

https://github.com/davemorrissey/subsampling-scale-image-view

这篇关于Android捏缩放大图,内存高效不丢失细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android捏缩放大图,内存高效不丢失细节

基础教程推荐