[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
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.
* 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.