Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Color.FromArgb(Int32) not always possible

$
0
0

I was thinking of rewriting this part ...

                int b = (int)Pixels[i] & 0xff;
                int g = (int)Pixels[i + 1] & 0xff;
                int r = (int)Pixels[i + 2] & 0xff;
                clr = Color.FromArgb(r, g, b);

as this...

                uint pix = (uint) Pixels[i] | 0xFF000000;
                clr = Color.FromArgb(pix);

But I can't. Here's why. FromArgb() takes a *signed* integer. The components of A, R, G, B are equivalent to unsigned BYTE, that is, each part can have value of 0xFF. In Int32, the A part can have a maximum value of 0x7F, making the pixel about 50% transparent. :(

Why was it designed like that? Can Microsoft write a new method FromArgb(UInt32)?



VP


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>