diff options
Diffstat (limited to 'libdimension/png.c')
-rw-r--r-- | libdimension/png.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libdimension/png.c b/libdimension/png.c index 7631804..44bf978 100644 --- a/libdimension/png.c +++ b/libdimension/png.c @@ -145,7 +145,7 @@ dmnsn_png_write_canvas_thread(void *ptr) } /* libpng will longjmp here if it encounters an error from here on */ - uint16_t *row = NULL; + uint8_t *row = NULL; if (setjmp(png_jmpbuf(png_ptr))) { /* libpng error */ dmnsn_free(row); @@ -157,8 +157,8 @@ dmnsn_png_write_canvas_thread(void *ptr) /* Associate file with the libpng write struct */ png_init_io(png_ptr, payload->file); - /* Set header correctly for 16-bit sRGB image */ - png_set_IHDR(png_ptr, info_ptr, width, height, 16, + /* Set header correctly for 8-bit sRGB image */ + png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE); @@ -181,7 +181,7 @@ dmnsn_png_write_canvas_thread(void *ptr) if (i->optimizer_fn == dmnsn_rgba16_optimizer_fn) { for (size_t y = 0; y < height; ++y) { /* Invert the rows. PNG coordinates are fourth quadrant. */ - uint16_t *row = (uint16_t *)i->ptr + 4*(height - y - 1)*width; + uint8_t *row = (uint8_t *)i->ptr + 4*(height - y - 1)*width; png_write_row(png_ptr, (png_bytep)row); dmnsn_future_increment(payload->future); } @@ -195,7 +195,7 @@ dmnsn_png_write_canvas_thread(void *ptr) } /* Allocate the temporary row of RGBA values */ - row = dmnsn_malloc(4*sizeof(uint16_t)*width); + row = dmnsn_malloc(4*sizeof(uint8_t)*width); /* Write the pixels */ for (size_t y = 0; y < height; ++y) { @@ -207,10 +207,10 @@ dmnsn_png_write_canvas_thread(void *ptr) color = dmnsn_color_to_sRGB(color); color = dmnsn_color_saturate(color); - row[4*x] = lround(color.R*UINT16_MAX); - row[4*x + 1] = lround(color.G*UINT16_MAX); - row[4*x + 2] = lround(color.B*UINT16_MAX); - row[4*x + 3] = lround(color.trans*UINT16_MAX); + row[4*x] = lround(color.R*UINT8_MAX); + row[4*x + 1] = lround(color.G*UINT8_MAX); + row[4*x + 2] = lround(color.B*UINT8_MAX); + row[4*x + 3] = lround(color.trans*UINT8_MAX); } /* Write the row */ |