I would like to implement a simple fullscreen gallery image preview which will include zoom by pinch and drag features.
我想实现一个简单的全屏图片库图像预览,其中将包括缩放缩放和拖动功能。
The basic stuff is straight-forward: imageview inside a framelayout which is controlled by setScaleX(/Y) and setScrollX(/Y).
基本的东西是直接的:imageview在一个由setScaleX(/Y)和setScrollX(/Y)控制的框架布局中。
The trouble starts when I try to load an image larger than OpenGL max texture size (4096x4096 in my case). I get the following error Bitmap too large to be uploaded into a texture
, which makes sense.
当我试图加载一个大于OpenGL最大纹理大小(在我的例子中是4096x4096)的图像时,问题就出现了。我得到以下错误位图太大,无法上传到纹理,这是有意义的。
How do other image viewers open and show large images? Is there a trick or a magic method?
其他的图像观众如何打开和显示大的图像?有魔术还是魔术?
I was thinking of dividing one big image into a grid of cropped images (for instance 5x5) and tiling them, but it seems like a not so healthy solution. May be a wise usage of BitmapRegionDecoder would be the answer?
我正在考虑将一个大的图像分割成一个裁剪过的网格(例如5x5)并将它们平铺,但这似乎不是一个很健康的解决方案。也许是一个明智的使用位图区域解码器将是答案?
Could you suggest how to resolve this issue?
你能建议如何解决这个问题吗?
1 个解决方案
#1
1
My library, SubsamplingScaleImageView, is designed for image galleries and displaying other large images like building plans. It automatically tiles images larger than the max texture size and subsamples images to avoid loading too much data. Try the sample app to see if it does what you need.
我的库SubsamplingScaleImageView是为图像库和显示其他大型图像(如建筑计划)而设计的。它自动地将图像大于最大纹理大小和子样本图像,以避免加载过多的数据。试试这个应用程序,看看它是否能满足你的需要。
https://github.com/davemorrissey/subsampling-scale-image-view
https://github.com/davemorrissey/subsampling-scale-image-view
#1
1
My library, SubsamplingScaleImageView, is designed for image galleries and displaying other large images like building plans. It automatically tiles images larger than the max texture size and subsamples images to avoid loading too much data. Try the sample app to see if it does what you need.
我的库SubsamplingScaleImageView是为图像库和显示其他大型图像(如建筑计划)而设计的。它自动地将图像大于最大纹理大小和子样本图像,以避免加载过多的数据。试试这个应用程序,看看它是否能满足你的需要。
https://github.com/davemorrissey/subsampling-scale-image-view
https://github.com/davemorrissey/subsampling-scale-image-view