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()

Submitter:  None
Submitted:  Sat 01 Oct 2011 01:52:06 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  alexshulgin
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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>
Group administrator
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 Files:
   
   
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
  • -email is unavailable- added by alexshulgin (Posted a comment)
  • -email is unavailable- added by malvineous (Posted a comment)
  • -email is unavailable- added by malvineous (Original submitter)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-10-25 alexshulgin Open/ClosedOpen Closed
    2011-10-01 alexshulgin StatusIn Progress Fixed
    2011-10-01 alexshulgin StatusNone In Progress
        Assigned toNone alexshulgin
    2011-10-01 malvineous Carbon-Copy- Added malvineous
    2011-10-01 None Attached File- Added test.png, #24068

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code