diff options
Diffstat (limited to 'src/readpng.c')
-rw-r--r-- | src/readpng.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/readpng.c b/src/readpng.c index 14e5fe2..dc72e6e 100644 --- a/src/readpng.c +++ b/src/readpng.c @@ -97,7 +97,7 @@ int readpng_read(const char *filename, double tilt, ControlContext *ctx) { height = png_get_image_height(png_ptr, info_ptr); bit_depth = png_get_bit_depth(png_ptr, info_ptr); channels = png_get_channels(png_ptr, info_ptr); -// printf("RI: width=%i, height=%i, depth=%i, channels=%i\n", width, height, bit_depth, channels); + printf("RI: width=%i, height=%i, depth=%i, channels=%i\n", width, height, bit_depth, channels); if ( (bit_depth != 16) && (bit_depth != 8) ) { printf("RI: Whoops! Can't handle images with other than 8 or 16 bpp yet...\n"); png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); @@ -109,7 +109,6 @@ int readpng_read(const char *filename, double tilt, ControlContext *ctx) { row_pointers = png_get_rows(png_ptr, info_ptr); image = malloc(height * width * sizeof(int16_t)); - ctx->width = width; ctx->height = height; ctx->fmode = FORMULATION_CLEN; for ( y=0; y<height; y++ ) { @@ -121,8 +120,9 @@ int readpng_read(const char *filename, double tilt, ControlContext *ctx) { int i; val = 0; for ( i=0; i<channels; i++ ) { - val += row_pointers[y][(channels*x)+i] << 8; - val += row_pointers[y][(channels*x)+i]; + /* PNG files are big-endian: */ + val += row_pointers[y][(channels*x*2)+(2*i)] << 8; + val += row_pointers[y][(channels*x*2)+(2*i)+1]; } } if ( bit_depth == 8 ) { |