I have noticed that everyone working with the Canvas object multiply their way around the pixelbuffer by 4's (RGBA). I have worked a lot with native pixel coding (Delphi and C++) and recognize this as a normal 32bit RGBA (888-8 encoding). My question is: is there a way to detect the pixelformat of the browser? If you are running on a device supporting 16bit (565 encoding) or 24bit (888 encoding) it will be very slow if the browser has to downgrade the bitmaps for each redraw. Especially when alpha blending is involved.
Also (and this is secondary): Is it possible to create a pure 888 or 565 bitmap at all under javascript? Or what about an 8bit palette based bitmap? JS based games would benefit greatly only having to work with 8bit pixels in my view.
No. There is no seeming way to downgrade the pixels of the canvas, as that is what the imageData simply is as far as the specification itself is concerned.
You can of course make a javascript game using nothing but 8-bit PNGs, which would save space and load time, but not render time.
No, there is no way to specify what color space you want. Any manual hacks around this would only slow down the rendering further. In my experience, some browsers (Google Chrome) can render very complex games and still maintain a high frame rate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With