Hi Pete,
English is not my motherlanguage, I do not understand all errors.
I saw that the color I was writing was always 0.
Unfornually, I leave it :(
Thanks for support.
"Peter Duniho" <Np*********@nnowslpianmk.comschreef in bericht
news:op***************@petes-computer.local...
On Sat, 08 Dec 2007 09:15:06 -0800, Rinaldo
<zw*************@hotmail.com.nospamwrote:
Hi,
My code:
kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;
but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.
transparent backgroundcolors not handled.
As Jon says, the exception seems pretty clear.
As far as why you're getting the exception, note the name of the method
you're using to initialize the Color. FromArgb(). From==>A<==rgb().
Emphasis on "A". That's "alpha" and it means that it expects the number
you're passing into include an alpha component (i.e. transparency).
It seems likely that the color value you're reading is just as plain
24-bit color value, so the alpha is 0 (i.e. completely transparent).
You need to make sure you have a color with the alpha component set to 255
(i.e. completely opaque) before using it somewhere that transparent colors
aren't supported (like for background colors). IMHO, the easiest way to
do that is just use the FromArgb() overload that takes the alpha and color
separately:
Color kl = Color.FromArgb(255, Color.FromArgb(kleur));
Why there's no Color.FromArgb(Int32, Int32) so that you can avoid going
through the constructor twice, I don't know. But it shouldn't be a big
deal. This is unlikely to ever be a performance bottleneck.
Pete