bugpng++, a C++ wrapper for libpng - Bugs: bug #34451, 4bpp .png causes std::logic_error...

 
 

bug #34451: 4bpp .png causes std::logic_error in png::consumer::read()

Submitted by:  None
Submitted on:  Sat 01 Oct 2011 01:52:06 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Alexander Shulgin <alexshulgin>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 02 Oct 2011 01:52:34 AM UTC, comment #4:

Ah, I didn't notice I was using the wrong template declaration. I tried changing it but then I had to deal with packed rows/pixels and I couldn't use the same code for 8bpp and <8bpp.

Your change in rev 120 fixed the problem however, now I can read the images perfectly with the same code regardless of the depth - many thanks!

Adam Nielsen <malvineous>
Sat 01 Oct 2011 06:05:43 PM UTC, comment #3:

OK, with this revision: http://svn.savannah.nongnu.org/viewvc/trunk/convert_color_space.hpp?root=pngpp&r1=120&r2=119&pathrev=120 you could use this code:

png::image<png::index_pixel> png;
png.read(filename);

That would automagically convert any images with colormap (1,2,4 or 8-bits depth.)

Alexander Shulgin <alexshulgin>
Project AdministratorIn charge of this item.
Sat 01 Oct 2011 02:28:27 PM UTC, comment #2:

Hm... I wonder if you really meant:

png::image<png::index_pixel_4> png;

instead?

I'd agree that the error message is not very helpful.

If you really want to read any bit-depth indexed image into 8-bits indexed image, you'll need just a little more support from convert_color_space template.

I'll try to see if this would be an easy fix.

Alexander Shulgin <alexshulgin>
Project AdministratorIn charge of this item.
Sat 01 Oct 2011 02:18:23 PM UTC, comment #1:

Just thinking about this further, I think the issue might stem from the fact that the image is only 16-colours, but because it uses palette based transparency there's a 17th entry in the palette (at index 0). This means the image indices need to be expanded to 8-bit to hold all the values, despite the image only being 16-colours.

Adam Nielsen <malvineous>
Sat 01 Oct 2011 01:52:06 PM UTC, original submission:

When I try to read the attached 16-colour .png like this:

png::image<png::index_pixel> png;
png.read(filename, png::require_color_space<png::index_pixel_4>());

I get an std::logic_error thrown that says "color type and/or bit depth mismatch in png::consumer::read()"

This is with the SVN version. The png was originally produced with png++ then edited in the GIMP.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #24068:  test.png added by None (321B - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by alexshulgin (Posted a comment)
  • -unavailable- added by malvineous (Posted a comment)
  • -unavailable- added by malvineous (Original submitter)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 25 Oct 2015 06:37:49 PM UTCalexshulginOpen/ClosedOpen=>Closed
    Sat 01 Oct 2011 06:05:43 PM UTCalexshulginStatusIn Progress=>Fixed
    Sat 01 Oct 2011 02:28:27 PM UTCalexshulginStatusNone=>In Progress
      Assigned toNone=>alexshulgin
    Sat 01 Oct 2011 02:18:23 PM UTCmalvineousCarbon-Copy-=>Added malvineous
    Sat 01 Oct 2011 01:52:06 PM UTCNoneAttached File-=>Added test.png, #24068

    Back to the top


    Powered by Savane 3.1-cleanup1