When using the XColor.FromArgb(int alpha, System.Drawing.Color color) overload, the behavior is not what is expected. This static method simply creates a new XColor with this code:
Code:
return new XColor(alpha, color.R, color.G, color.B);
and I believe the intention was that the constructor XColor(byte alpha, byte red, byte green, byte blue) would be called, but as I step through it in Visual Studio 2008 SP1 I see that this is not the case. The constructor XColor(double cyan, double magenta, double yellow, double black) is getting called instead, probably because alpha is an int and not a byte. This results in completely incorrect color values in the resulting XColor.
I corrected this by simply casting alpha to byte in the code above. I don't really know why alpha was made an int in the first place. I recommend that you provide another overload that takes a byte and deprecate the int version (as well as adding the cast).
To reproduce the problem as it exists, simply run this line of code:
Code:
XColor dummy = XColor.FromArgb(128, Color.Blue);
You'll get black instead of blue and the XColor will have the CMYK color space instead of RGB. I'm using version 1.31 of PDFsharp.