Jul 27, 2021 Replies: 8 Q: I want to load a 10,000 x 10,000 image? A: That's impossible!!! The memory required is: width * height * 4 = 400MB. A: You will need to scale down the image. A: Sure. Use HugeImageView: (image source: https://images4.alphacoders.com/655/655004.jpg) How does it work? It uses two layers - one with a scaled down image and another made of tiles. The visible tiles are loaded in the background using a native API that allows loading specific regions (BitmapRegionDecoder). I've tested it with a 40,000x20,000 image and it worked (such image requires 3GB of RAM to fully load it). Updates: - v1.04 - Fixes an issue with Android 15. - v1.03 - Adds support for B4J. - v1.02 - Fixes an issue related to image vs. device orientation (https://www.b4x.com/android/forum/threads/hugeimageview-tile-not-showing-at-bottom.134387/). - v1.01 - Adds support for B4i. Attachments HugeImageView.zip HugeImageView.zip 256.6 KB · Views: 594 Last edited: Mar 12, 2025 Click to expand...
Q: I want to load a 10,000 x 10,000 image? A: That's impossible!!! The memory required is: width * height * 4 = 400MB. A: You will need to scale down the image. A: Sure. Use HugeImageView: (image source: https://images4.alphacoders.com/655/655004.jpg) How does it work? It uses two layers - one with a scaled down image and another made of tiles. The visible tiles are loaded in the background using a native API that allows loading specific regions (BitmapRegionDecoder). I've tested it with a 40,000x20,000 image and it worked (such image requires 3GB of RAM to fully load it). Updates: - v1.04 - Fixes an issue with Android 15. - v1.03 - Adds support for B4J. - v1.02 - Fixes an issue related to image vs. device orientation (https://www.b4x.com/android/forum/threads/hugeimageview-tile-not-showing-at-bottom.134387/). - v1.01 - Adds support for B4i.
Erel B4X founder Staff member Licensed User Longtime User Jul 27, 2021 #2 - v1.01 - Adds support for B4i.
omarruben Active Member Licensed User Longtime User Jul 28, 2021 #3 wow!!!!!!!!! this is excellent !!!!! thank you!!!
Martin Larsen Active Member Licensed User Longtime User Aug 16, 2021 #4 Awesome. Could be very useful.
Erel B4X founder Staff member Licensed User Longtime User Sep 20, 2021 #5 - v1.02 - Fixes an issue related to image vs. device orientation (https://www.b4x.com/android/forum/threads/hugeimageview-tile-not-showing-at-bottom.134387/).
- v1.02 - Fixes an issue related to image vs. device orientation (https://www.b4x.com/android/forum/threads/hugeimageview-tile-not-showing-at-bottom.134387/).
Erel B4X founder Staff member Licensed User Longtime User Jun 6, 2022 #6 V1.03 adds support for B4J. The B4J implementation is a bit different. It caches all tiles.
A alyami Member Licensed User May 18, 2024 #7 Thank you it was awesome, can we control level of zoom and center image by code?
Erel B4X founder Staff member Licensed User Longtime User May 19, 2024 #8 Add this code to the class to center the image: Code: Copy Public Sub CenterImage(ZoomLevel As Float) pnlBackground.SetLayoutAnimated(0, 0, 0, mBase.Width, mBase.Height) ZoomChanged(pnl.Width / 2, pnl.Height / 2, ZoomLevel) End Sub Pass 1 for no zoom.
Add this code to the class to center the image: Code: Copy Public Sub CenterImage(ZoomLevel As Float) pnlBackground.SetLayoutAnimated(0, 0, 0, mBase.Width, mBase.Height) ZoomChanged(pnl.Width / 2, pnl.Height / 2, ZoomLevel) End Sub Pass 1 for no zoom.
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2025 #9 - v1.04 - Fixes an issue with Android 15.