#211 Impossible to save a 2-color PNG with transparency (patch)

None
closed
None
5
2013-01-09
2012-05-01
No

My bitmap is a monochrome bitmap WITH transparency (white = transparent).

This bitmap, when saved as a PNG, loses its transparency, because monochrome bitmaps are saved by the PNG plugin without a palette.

Attached is a patch PluginPNG.cpp to store the palette also for monochrome images in case the bitmap contains transparency.

Discussion

  • Hervé Drolon

    Hervé Drolon - 2012-05-13

    Hi,

    I don't understand the need for this patch. I made a simple test : save a 1-bit transparent GIF to PNG, and all is OK. Inside PluginPNG::Save, at line 847, you have :

            // set the transparency table
    
            if (FreeImage_IsTransparent(dib) && (FreeImage_GetTransparencyCount(dib) > 0)) {
                png_set_tRNS(png_ptr, info_ptr, FreeImage_GetTransparencyTable(dib), FreeImage_GetTransparencyCount(dib), NULL);
            }
    

    So the trns info is correctly saved for 1-bit bitmaps.

    Can you give more info on your use case and explain what doesn't work for you ?

    Hervé

     
  • Rustam Abdullaev

    test project with resulting PNGs

     
  • Rustam Abdullaev

    See attached freeimage-test.zip. It shows that a MINISWHITE bitmap is saved as a PNG incorrectly - with a transparent black instead of white.

     
  • Hervé Drolon

    Hervé Drolon - 2012-07-26

    Hi,

    Thanks for the patch, it is now available in the CVS.

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2013-01-09
    • status: pending --> closed
    • milestone: -->
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks