Android的双指缩放大的图像,内存使用效率而不会丢失细节 [英] Android pinch zoom large image, memory efficient without losing detail
问题描述
我的应用程序已经显示了一些高分辨率的图像(约1900 * 2200像素),支持双指缩放。为了避免内存不足的错误我打算去code图像通过显示全屏
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的
)
这样我就可以快速加载图像和屏幕(图像)之间顺利刷卡。然而,当我捏缩放,我的应用程序,因为失去缩放图像的细节。 如果我加载完整图像,我不能快速加载或顺利刷卡,双指缩放后的阻力。 然后我尝试只加载完整的图像时,用户开始捏缩放,但由于非常大的图像,我依然无法顺利拖动图像。 Android的画廊可以做到这一点甚至完全8Mpx图像。
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.
<一个href="https://github.com/davemorrissey/subsampling-scale-image-view">https://github.com/davemorrissey/subsampling-scale-image-view
这篇关于Android的双指缩放大的图像,内存使用效率而不会丢失细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!