PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
5Faulty dirty tracking in XSolidBrush Color setter https://forum.pdfsharp.net/viewtopic.php?f=3&t=2381 |
Page 1 of 1 |
Author: | inexorabletash [ Sat Mar 23, 2013 11:57 pm ] |
Post subject: | 5Faulty dirty tracking in XSolidBrush Color setter |
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"); |
Author: | dheijl [ Mon Mar 25, 2013 7:38 am ] |
Post subject: | Re: 5Faulty dirty tracking in XSolidBrush Color setter |
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 |
Author: | Thomas Hoevel [ Mon Mar 25, 2013 8:55 am ] |
Post subject: | Re: 5Faulty dirty tracking in XSolidBrush Color setter |
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.
|
Author: | inexorabletash [ Sat Mar 30, 2013 5:37 pm ] |
Post subject: | Re: 5Faulty dirty tracking in XSolidBrush Color setter |
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); |
Author: | Thomas Hoevel [ Wed Oct 22, 2014 1:33 pm ] |
Post subject: | Re: 5Faulty dirty tracking in XSolidBrush Color setter |
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.
|
Author: | inexorabletash [ Wed Dec 10, 2014 4:29 am ] |
Post subject: | Re: 5Faulty dirty tracking in XSolidBrush Color setter |
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!) |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |