This project is read-only.

SetPixel/GetPixel bug

Feb 18, 2012 at 11:12 PM
Edited Feb 18, 2012 at 11:14 PM

I've noticed if I set a pixel where the alpha is 0, RGB all get set to 0. So color information is not dependably saved if you have an alpha of 0. This of course doesn't cause a visual difference, but it means you have to store your colors elsewhere.


                    Color clear = Colors.Yellow;

                    for (int widthIndex = 0; widthIndex < getWidth(); widthIndex++)
                        for (int heightIndex = 0; heightIndex < getHeight(); heightIndex++)
                            clear.A = (byte) (heightIndex % 255);
                            pencilBitmap.SetPixel(widthIndex, heightIndex, clear);
                            Color testColor = pencilBitmap.GetPixel(widthIndex, heightIndex);

For example here, when clear.A is set to 0, testColor is not a transparent yellow. However when A is set to anything else it is.

Has anyone else run into this?


Feb 22, 2012 at 10:24 PM

I believe it's because the Pixel format is 'premultiplied ARGB32, more info:

Feb 23, 2012 at 9:02 AM

That's right, the WB uses premultiplied-alpha.

- Rene Schulte