Need guidance on 1bit images

YQN

5 years ago

Hi,

For the game I'm developing I need to display images in 1 colour and be able to change their colour. I was thinking creating an image class with a width, height, colour, and bool array for the pixels where false means transparent, and then create a method to draw the image pixel by pixel, but I wondered if that's not using too much CPU. Before I start I wanted to know if there's a simpler or more efficient way to achieve the same result, or if I'm on the right track?

Thanks!

deeph

NEW 5 years ago

There's gb.display.drawBitmap(), but I'm not sure if it handles transparency.

YQN

5 years ago

It does work, thanks. Not sure how safe legacy functions are but I'll use it for now :)

YQN

NEW 5 years ago

deeph deeph

It does work, thanks. Not sure how safe legacy functions are but I'll use it for now :)

alxm

NEW 5 years ago

If you're not short on flash memory, the simplest way might be to use the library's 8bit indexed mode and restrict yourself to 1 color.

Alternatively, you could save lots of memory by using a single bit per pixel instead the full bool type. and use bit shifts + masking to get an individual pixel's value. This should be fast enough, the library draw functions also just go over the image pixel by pixel.

Edit: My bad, I missed deeph's post!