HTML5 Canvas - Banding with low alpha?

微笑、不失礼 提交于 2019-12-06 14:18:21

This problem seems entirely due to color precision. I think most Canvas API implementations use 8 bit RGBA channels. 1% or 2% opacity means that you are applying a very small amount of color to the image, only about 2-5 levels of difference - so even after a lot of repeated applications of the brush, any colors you use will end up being quantised down to a smaller number.

You could make your own a floating point canvas and copy it into a normal canvas after every change. That will make the problem completely unnoticeable for most operations. You'd have to implement your own drawing operations (not too bad if you only use drawImage) and they are likely to be slower than the canvas ones.

Do you see similar issues on MugTug's Sketchpad? I tried with a 4% alpha blue brush over an orange background, and there is banding and such. If it does better than you code then you are doing something wrong.

I've always seen canvas working with 32bit graphics (24 for color + 8 for alpha) so I doubt this can be solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!