Page 1 of 1

[Solved(Duplicate)] Is there any way to create 8bit-per-pixel grayscale canvas and draw on it?

Posted: Fri Oct 04, 2024 6:51 am
by qwdqwqwffqw
It would be helpful as in many simple games we use grayscale graphics only. Also, there are many elements(textbox, mask, etc) that use only black and white.

* Normal canvas needs 3 times more memory.
* 'la8' pixel format might be a good option(grayscale+alpha), but it can not be used in canvas - one could make imageData with la8 and use setPixel/mapPixel to draw on that, but it would be costly and cumbersome.
* 'r8' pixel format is available for canvas, but it is monochrome red(r, 0, 0) unlike la8(l, l, l, a). To my knowledge there is no way to turn this into grayscale(or monochrome of other tones) with setColor or setBlendMode, other than relying on shaders.

Re: Is there any way to create 8bit-per-pixel grayscale canvas and draw on it?

Posted: Fri Oct 04, 2024 7:47 am
by pgimeno
I asked pretty much the same question a few years ago. I guess the answer is still the same.

viewtopic.php?t=89381

Re: Is there any way to create 8bit-per-pixel grayscale canvas and draw on it?

Posted: Fri Oct 04, 2024 9:31 am
by qwdqwqwffqw
Oops, should have searched for 'greyscale' as well. :)
Thanks!