Bug 27616 - libgdiplus mishandles PNG files with 2bpp PNG_COLOR_TYPE_PALETTE
Summary: libgdiplus mishandles PNG files with 2bpp PNG_COLOR_TYPE_PALETTE
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: libgdiplus ()
Version: 3.4.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-03 16:52 UTC by Stephen McConnel
Modified: 2016-05-04 19:48 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
read.png is the original file. (8.14 KB, image/png)
2015-03-03 16:52 UTC, Stephen McConnel
Details
read-munged.png is the file as displayed and saved, going through Mono Graphics and libgdiplus (16.96 KB, image/png)
2015-03-03 16:53 UTC, Stephen McConnel
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Stephen McConnel 2015-03-03 16:52:29 UTC
Created attachment 10138 [details]
read.png is the original file.

libgdiplus does not properly handle PNG_COLOR_TYPE_PALETTE files with 2 bits per pixel.  I'm attaching two files to show what happens.  I've figured out a non-ideal fix for this, and will post a pull request with that fix.  (The ideal fix would be to change libgdiplus to use libpng properly, and fix libpng to handle this case properly.  Since the current libgdiplus code was already trying to work around the effects of not calling libpng properly, I made a minimal change to its current code.)
Comment 1 Stephen McConnel 2015-03-03 16:53:30 UTC
Created attachment 10139 [details]
read-munged.png is the file as displayed and saved, going through Mono Graphics and libgdiplus
Comment 2 Stephen McConnel 2015-03-03 17:28:08 UTC
See https://github.com/mono/libgdiplus/pull/30 for my proposed fix.
Comment 3 Alexander Köplinger [MSFT] 2016-05-04 19:48:38 UTC
The PR was merged. Thanks!