In short I am unable to access all the pixels of a bitmap image.
I have used an intent to fire the native Camera app and returned a Bitmap image to my application activity. The data is definitely a bitmap object and I am able to display, get the height/width etc and access some pixels using getPixel(). However when I use the values of getHeight() and getWidth() I get an array out of bounds error. By trail and error I have found I can only access a reduced number of pixels of the image, for example with one image which returned a height and width value of 420,380, I could also access 200,100. I then do some image processing and used setPixel() on the original image. When I display the image it shows the, say 200,100, processing pixels and the rest normal, therefore the pixels are obviously there and accessible by android but not by me. I have to spoken to other people who have also had this problem with images.
Does anyone know anything more about this, reasons? or a work around?
Many thanks in advance.
It seems that there’s no way around this, does anyone think it would be better/possible to access the image directly in memory maybe using the NDK?
Got an answer from Albert Pucciani on the Android forums. I now create an
int bufferand copy the pixels to it, then useget()andput()to extract the pixels. It’s also much quicker to useget()andput()instead of theget/setPixel()from theBitmapclass. Need to test now whether this does return all the pixels to the buffer for all images.After more testing I have discovered this is simply a memory issue as the amount allocated for each process includes all bitmaps.