PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:47 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: Fri Jul 06, 2012 8:12 pm 
Offline

Joined: Fri Jul 06, 2012 7:59 pm
Posts: 1
It appears there is a bug in PdfImage.FaxEncode.cs. The "CountZeroBits" and "CountOneBits" does not properly detect the right edge in certain circumstances where the width is not divisible by 8. Basically it confuses the encoder so it thinks the current line is different length from the previous line.

I fixed it by replacing "return found + hits;" with the following code:

Code:
          found += hits;
          if (found >= bitsLeft)
              return bitsLeft;
          return found;



Code:
    private static uint CountOneBits(BitReader reader, uint bitsLeft)
    {
      uint found = 0;
      for (; ; )
      {
        uint bits;
        int @byte = reader.PeekByte(out bits);
        uint hits = OneRuns[@byte];
        if (hits < bits)
        {
          if (hits > 0)
            reader.SkipBits(hits);
          found += hits;
          if (found >= bitsLeft)
              return bitsLeft;
          return found;
        }
        found += bits;
        if (found >= bitsLeft)
          return bitsLeft;
        reader.NextByte();
      }
    }


Code:
    private static uint CountZeroBits(BitReader reader, uint bitsLeft)
    {
      uint found = 0;
      for (; ; )
      {
        uint bits;
        int @byte = reader.PeekByte(out bits);
        uint hits = ZeroRuns[@byte];
        if (hits < bits)
        {
          if (hits > 0)
            reader.SkipBits(hits);
          found += hits;
          if (found >= bitsLeft)
              return bitsLeft;
          return found;
        }
        found += bits;
        if (found >= bitsLeft)
          return bitsLeft;
        reader.NextByte();
      }
    }


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 09, 2012 8:46 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Thank you for your feedback, bug will be fixed with the next release.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 05, 2014 8:38 am 
Offline

Joined: Mon Jun 02, 2014 8:46 am
Posts: 1
I see the above code fix has not been integrated into the source. And there hasn't been a release since this was posted, coming up on 2 years ago.

Is the above fix problematic? We've encountered the same issue and the fix appears to resolve, but if it has not been committed to the source I am wary of why.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 05, 2014 3:52 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Two years ago we thought we would publish a new release very dang soon.

We still want to publish a new release with improvements and bug fixes ASAP (I cannot give any EDA).

Nothing wrong with this correction in particular.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 20, 2015 1:07 pm 
Offline

Joined: Fri Mar 20, 2015 1:00 pm
Posts: 13
Is this fixed in 1.50 Beta?


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2015 9:10 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
That bug should be fixed with 1.50 beta.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


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 58 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group