You load in image in ImageView (android) , how is the memory allocated for it?
And whether the memory allocated is in 1D array or 2D array? (like in terms of pixels maybe)
And which is better BufferedImage or Bitmap for image handling?
PS – It is not a duplicate of this.
An
ImageViewdoes not allocate the memory for the images it displays, the images do that. Most likely aBitmap. And those allocate the memory in native context (somemalloc) so Java’s garbage collector can’t clean up the allocated memory and regularly fails if you don’t take care.The memory allocated is a 1D block of memory and probably stores pixel by pixel, row after row (2D access is a simple calculation). Images are stored uncompressed so a 100kb .jpg file may use several MB of data. Each pixel takes up to 4 byte (R,G,B,A in _8888 mode)
The actual implementation (allocation) of
Bitmapshould be somewhere in skia – SkBitmap.I don’t know what a
BufferedImageis but a good read on working with images is:http://developer.android.com/training/displaying-bitmaps/index.html