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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)