PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 12:42 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Mar 23, 2013 11:57 pm 
Offline

Joined: Sat Mar 23, 2013 11:48 pm
Posts: 11
Reported at:
http://sourceforge.net/tracker/?func=de ... tid=777115
http://pdfsharp.codeplex.com/workitem/15658

The code in XSolidBrush's Color attribute reads;

Code:
  this.color = value;
#if GDI
  this.gdiDirty = this.gdiDirty || this.color != value;
#endif


Since the test follows the assignment it will never be true. In other words, once the brush has been realized, assignments to Color will not update it.

The assignment should be moved after the tests (i.e. to the end of the Color setter)

Patch:

Code:
Index: C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing/XSolidBrush.cs
===================================================================
--- C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing/XSolidBrush.cs   (revision 99631)
+++ C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing/XSolidBrush.cs   (working copy)
@@ -85,7 +85,6 @@
       {
         if (this.immutable)
           throw new ArgumentException(PSSR.CannotChangeImmutableObject("XSolidBrush"));
-        this.color = value;
 #if GDI
         this.gdiDirty = this.gdiDirty || this.color != value;
 #endif
@@ -95,6 +94,7 @@
 #if GDI && WPF
         this.gdiDirty = this.wpfDirty = true;
 #endif
+        this.color = value;
       }
     }
     internal XColor color;


And while I'm here, another minor glitch that would prevent PDF colors from updating:

Code:
Index: C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing.Pdf/PdfGraphicsState.cs
===================================================================
--- C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing.Pdf/PdfGraphicsState.cs   (revision 99631)
+++ C:/dev/PDFsharp/code/PdfSharp/PdfSharp.Drawing.Pdf/PdfGraphicsState.cs   (working copy)
@@ -248,7 +248,7 @@
 
         if (colorMode != PdfColorMode.Cmyk)
         {
-          if (this.realizedFillColor.Rgb != color.Rgb)
+          if (this.realizedFillColor.Argb != color.Argb)
           {
             this.renderer.Append(PdfEncoders.ToString(color, PdfColorMode.Rgb));
             this.renderer.Append(" rg\n");


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 25, 2013 7:38 am 
Offline

Joined: Fri Apr 13, 2012 6:33 am
Posts: 10
Thanks for patch #1.

But the second issue seems fixed (in a slightly different way) in the latest release (1.32):

Code:
                if (colorMode != PdfColorMode.Cmyk) {
                    if (this.realizedFillColor != Color.Empty || this.realizedFillColor.Rgb != color.Rgb) {
                        this.renderer.Append(PdfEncoders.ToString(color, PdfColorMode.Rgb));
                        this.renderer.Append(" rg\n");
                    }
                } else {


Danny


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 25, 2013 8:55 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!
inexorabletash wrote:
The assignment should be moved after the tests (i.e. to the end of the Color setter)
Thank you very much for your feedback.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 30, 2013 5:37 pm 
Offline

Joined: Sat Mar 23, 2013 11:48 pm
Posts: 11
dheijl wrote:
But the second issue seems fixed (in a slightly different way) in the latest release (1.32):

Code:
                    if (this.realizedFillColor != Color.Empty || this.realizedFillColor.Rgb != color.Rgb) {




I haven't tried, but that still looks like it would compare equal if the colors were not Empty and had equal RGB values but different Alpha.

E.g. if realizedFillColor = Color.FromArgb(0x80, Color.White) and color = Color.FromArgb(0xFF, Color.White);


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 22, 2014 1:33 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
inexorabletash wrote:
E.g. if realizedFillColor = Color.FromArgb(0x80, Color.White) and color = Color.FromArgb(0xFF, Color.White);
At that point, only "RGB" will be written. "A" will be written later. IMHO there is no need to write an unchanged RGB if A has changed.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 10, 2014 4:29 am 
Offline

Joined: Sat Mar 23, 2013 11:48 pm
Posts: 11
Thomas Hoevel wrote:
At that point, only "RGB" will be written. "A" will be written later. IMHO there is no need to write an unchanged RGB if A has changed.


Makes sense - I hadn't looked at the code in context.

(Glad to see some recent activity here, and keep up the great work!)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 52 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