Note that there are some explanatory texts on larger screens.

plurals
  1. POViewing a small region of a Large Image in Android
    text
    copied!<p>In a gist this is what I want to do:</p> <p><strong><em>I want to load a 100x100 region (any part) of a 5mega pixel Image into a Android Bitmap class so that I can draw it onto a canvas element</em></strong> Its that simple. Thats all I want to do. Thats it. Nothing more. Nothing less. Sounds simple enough. So before you have a smirk on your face, read on further down.</p> <p>I understand that this question has been asked a million times already. And I have also done my homework, researching it. Unfortunately I have hit a dead end from all sides. Maybe I need to make my question clear enough.</p> <p>There is a limit on the amount of heap the Android VM lets you allocate. So loading a large bitmap, even the one from its own camera (I own a Nexus S) is not possible by using the following function.</p> <pre><code>BitmapFactory.decodeStream(InputStream is) </code></pre> <p>Yes I could scale it by using <strong>BitmapFactory.Options</strong>, but how then should I zoom in?</p> <p>Now I am trying to design an image viewer which can smoothly zoom in/out from the image. Obviously that's not possible if I can't even load the image.</p> <p>In gingerbread we have a new class <strong>BitmapRegionDecoder</strong> , but I am designing my app for Froyo. All these classes have hooks into the native api which use the <strong>Skia 2D Graphics Library</strong>. The Android NDK does not give access to these api's also. Maybe there is a way to manually build Skia and use it to load a java bitmap. But I am not sure how?</p> <p>It seems to have been solved already (<a href="http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/" rel="nofollow">http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/</a>) in this app - <a href="https://market.android.com/details?id=image.viewer" rel="nofollow">https://market.android.com/details?id=image.viewer</a> by using the memory allocated in the native C code using <strong>malloc/new</strong>. But I cant figure out how?</p> <p>So make things clearer what I want is something that can zoom in/out of an image to full resolution. If possible it should be smooth or atleast it can be done in a separate thread.</p> <p>If I need to use OpenGL, then please give me a sample code also.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload