aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2010-01-11 13:43:19 -0800
committerJohn Hawthorn <john.hawthorn@gmail.com>2010-01-11 13:43:19 -0800
commitc4316ba892943b9cf9ba190761164472f92f627c (patch)
treee455be278abdb7b63bda7c135051c04a4645055a /src
parentb63719d245db3073db51a75ba3d39cf13ccc3e28 (diff)
downloadmirror-meh-c4316ba892943b9cf9ba190761164472f92f627c.tar.gz
mirror-meh-c4316ba892943b9cf9ba190761164472f92f627c.tar.bz2
mirror-meh-c4316ba892943b9cf9ba190761164472f92f627c.zip
proper alpha handling with pngs. (hardcoded white background)
Diffstat (limited to 'src')
-rw-r--r--src/png.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/png.c b/src/png.c
index 290f51d..bab55e6 100644
--- a/src/png.c
+++ b/src/png.c
@@ -85,7 +85,16 @@ int png_read(struct image *img){
png_set_strip_16(p->png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(p->png_ptr);
- png_set_strip_alpha(p->png_ptr);
+ //png_set_strip_alpha(p->png_ptr);
+
+ png_color_16 my_background = {.red = 0xff, .green = 0xff, .blue = 0xff};
+ png_color_16p image_background;
+
+ if(png_get_bKGD(p->png_ptr, p->info_ptr, &image_background))
+ png_set_background(p->png_ptr, image_background, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+ else
+ png_set_background(p->png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 2, 1.0);
+
if(png_get_interlace_type(p->png_ptr, p->info_ptr) == PNG_INTERLACE_ADAM7)
p->numpasses = png_set_interlace_handling(p->png_ptr);
else