Android pinch zoom large image, memory efficient without losing detail(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捏缩放大图,内存高效不丢失细节
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01