PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jun 04, 2024 11:49 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Aug 22, 2013 8:12 am 
Offline

Joined: Tue Jun 18, 2013 7:48 am
Posts: 8
Hi Support,

by adding images to a PDF with PDFsharp, we got an issue in PdfImage.cs class. The attached image is identified as an white-on-black image, although it's a normal black-on-white image. Therefore, this image won't be included into PDF. Unfortunately, I'm not having a clue about image processing, so i would like to ask you, if you have any idea. The code snippet, which contains the bug (in my opinion) is in class PdfImage Line 640:
Code:
if (bits == 1)
        {
          if (paletteColors == 0)
            isBitonal = 1;
          if (paletteColors == 2)
          {
            if (paletteData[0] == 0 &&
              paletteData[1] == 0 &&
              paletteData[2] == 0 &&
              paletteData[3] == 255 &&
              paletteData[4] == 255 &&
              paletteData[5] == 255)
              isBitonal = 1; // Black on white
            if (paletteData[5] == 0 &&
              paletteData[4] == 0 &&
              paletteData[3] == 0 &&
              paletteData[2] == 255 &&
              paletteData[1] == 255 &&
              paletteData[0] == 255)
              isBitonal = -1; // White on black
          }
        }


If you need more information, feel free to ask for it. Thank you!

Best regards

Fabian


Attachments:
9029030590090-ez.png
9029030590090-ez.png [ 3.91 KiB | Viewed 4431 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 26, 2013 8:25 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3099
Location: Cologne, Germany
Hi!
FEN wrote:
The attached image is identified as an white-on-black image, although it's a normal black-on-white image.
"Normal" images use 0 for black and 1 for white. That image uses 0 for white and 1 for black, so it is the inverted case that needs special treatment. And it's a combination that was not covered by our test images - sorry for the inconvenience.

In PdfImage.cs search for "if (isBitonal == 0 && !isGray)" and replace it with "if (isBitonal == 0 && !isGray || isBitonal < 0)".

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 03, 2013 7:14 am 
Offline

Joined: Tue Jun 18, 2013 7:48 am
Posts: 8
Hi Thomas,

thanks for the helpful answer. Your code snippet solves the issue :)


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 123 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