diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-05-28 18:05:05 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-05-28 18:05:05 -0600 |
commit | efd3c1c2b42ffda0c8f7e5cd9b03fba07eead1ea (patch) | |
tree | c522f2bafe5def3eb68a79005c049e130ef76b24 /libdimension/png.c | |
parent | 1bf306d4d93cc21c220a3f31835023e49e84dd2d (diff) | |
download | dimension-efd3c1c2b42ffda0c8f7e5cd9b03fba07eead1ea.tar.xz |
Handle sRGB gamma correctly.
Diffstat (limited to 'libdimension/png.c')
-rw-r--r-- | libdimension/png.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libdimension/png.c b/libdimension/png.c index 5b7f625..6a56a87 100644 --- a/libdimension/png.c +++ b/libdimension/png.c @@ -64,7 +64,9 @@ dmnsn_png_optimizer_fn(const dmnsn_canvas *canvas, dmnsn_color color; uint16_t *pixel = (uint16_t *)optimizer.ptr + 4*(y*canvas->width + x); - color = dmnsn_remove_filter(dmnsn_get_pixel(canvas, x, y)); + color = dmnsn_get_pixel(canvas, x, y); + color = dmnsn_remove_filter(color); + color = dmnsn_color_to_sRGB(color); /* Saturate R, G, and B to [0, UINT16_MAX] */ @@ -272,6 +274,7 @@ dmnsn_png_write_canvas_thread(void *ptr) /* Invert the rows. PNG coordinates are fourth quadrant. */ dmnsn_color color = dmnsn_get_pixel(payload->canvas, x, height - y - 1); color = dmnsn_remove_filter(color); + color = dmnsn_color_to_sRGB(color); /* Saturate R, G, and B to [0, UINT16_MAX] */ @@ -477,6 +480,7 @@ dmnsn_png_read_canvas_thread(void *ptr) } } + color = dmnsn_color_from_sRGB(color); dmnsn_set_pixel(*payload->canvas, x, height - y - 1, color); } |