I was hoping to save some memory by creating the Graphics.BufferedBitmap with a lower color depth than what the device supports, e.g. using 16 colors (4bpp) on devices with 64 colors (RGB222).
But what is the correct way to do that?
- I took the image and process it with ImageMagick to reduce the colors to 16
- I have ensured the image is not truetype but uses palette
- I have checked which colors the final image uses. In my case it was reduced to 14 colors. See screenshot:
What is the next step?
1. If I put this into resource file:
2. I specify the palette from ImageMagick in the code:
buffer = new Graphics.BufferedBitmap({
:width => width,
:height => height,
:palette => [0x0494B7, 0x17ABCA,0x52CAD0,0x75C5CC,0x9ECABE,0xAFCDB4,0xD6D499,0xCED5A8,0xE0DEBA,0x8DC6C6,0xB5E8E1,0xDEE0C4,0xE2E4D3,0xE7F5F6],
:colorDepth => 4,
:alphaBlending => 0}) as BufferedBitmap;
3. It looks great on simulator and I can see a lot of memory is saved.
4. But on device I have error:
5. I have tried to disable the transparency, but it leads to the same error on the device
What is the correct way to do that? Also, I do not expect it to be necessary to copy the the palette in the code, but I could be wrong...
Thanks a lot!
STeN
P.S. Sorry for entering the code with images, when I c&p the code directly the post is rejected by forum for some "Cloudflare security checks"