Skip to content

Commit

Permalink
Use png_set_packing to expand 1/2/4bpp paletted PNG (for Issue #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Feb 16, 2015
1 parent cb53ae1 commit 808aeae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion converters/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ load_png(unsigned char *buffer, int size,
switch (png_get_color_type(png_ptr, info_ptr)) {
case PNG_COLOR_TYPE_PALETTE:
palette_bitdepth = png_get_PLTE(png_ptr, info_ptr, &png_palette, pncolors);
if (ppalette && png_palette && bitdepth == 8 && palette_bitdepth == 8 && *pncolors <= reqcolors) {
if (ppalette && png_palette && palette_bitdepth == 8 && *pncolors <= reqcolors) {
if (bitdepth != 8) {
png_set_packing(png_ptr);
}
*ppalette = malloc(*pncolors * 3);
if (*ppalette == NULL) {
goto cleanup;
Expand All @@ -356,6 +359,7 @@ load_png(unsigned char *buffer, int size,
*pcomp = 1;
*pixelformat = PIXELFORMAT_PAL8;
} else {
png_set_packing(png_ptr);
png_set_palette_to_rgb(png_ptr);
*pcomp = 3;
*pixelformat = PIXELFORMAT_RGB888;
Expand Down

0 comments on commit 808aeae

Please sign in to comment.