PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:36 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Jun 04, 2010 3:37 pm 
Offline

Joined: Thu Feb 25, 2010 2:44 pm
Posts: 14
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group