0

I've programmed an Android game in the past and had always run into memory issues because my images have been quite large ~(1000x400 px each). I'm now wondering if it is necessary to load images into memory solely as bitmaps. Is there any reason for not loading bitmaps in some loss-less compressed format?

I don't know much at all about image compression/decompression efficiency, but I assume that there would be performance issues. But I feel as though "simple" compression algorithms can't be too processor intensive, even if they only cut down the image to half of it's uncompressed memory footprint.

you786
  • 3,659
  • 5
  • 48
  • 74

2 Answers2

2

The problem is that at some level you must have pixel by pixel representation of the image, hence you must have a bitmap.

slayton
  • 20,123
  • 10
  • 60
  • 89
  • There are no algorithms that allow you to request a pixel for use like this: compressedImage.getPixel(x,y) and have some sort of decompression lookup for the given pixel? – you786 Apr 18 '12 at 22:04
  • 1
    They could exist but they will be horribly inefficient. Invoking a method for each pixel would be incredibly slow! Additionally the OS itself would need to represent the image as a Bitmap for the OS to draw it. – slayton Apr 18 '12 at 22:05
  • Well I'm imagining something like this (albeit this is a extreme example): the compression algorithm finds that there are only 256 different colors in the bitmap. It creates a lookup table and then uses only the 8 bits necessary for each pixel to find it's actual value in the table. Now the lookup will barely effect the speed and the memory can be compressed greatly. – you786 Apr 18 '12 at 22:14
0

The best solution to this is to switch to a compressed graphics type that can be used by OpenGL, as answered on gamedev.stackexchange.com at thsi question:

https://gamedev.stackexchange.com/a/28463/8126

Unfortunately for me I have no experience in OpenGL.

Community
  • 1
  • 1
you786
  • 3,659
  • 5
  • 48
  • 74