From 34d9d55846a1281ae5695ff075969e04d168eebf Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 17 Nov 2014 11:40:27 +0100 Subject: [PATCH] fix png_reader --- platform/default/png_reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/default/png_reader.cpp b/platform/default/png_reader.cpp index 33d17a1b8..76437dec3 100644 --- a/platform/default/png_reader.cpp +++ b/platform/default/png_reader.cpp @@ -248,7 +248,7 @@ void png_reader::read(unsigned x0, unsigned y0, unsigned w, unsigned h, char // alloc row pointers const std::unique_ptr rows(new png_bytep[height_]); for (unsigned row = 0; row < height_; ++row) - rows[row] = (png_bytep)image + row * width_ ; + rows[row] = (png_bytep)image + row * width_ * 4 ; png_read_image(png_ptr, rows.get()); } else @@ -263,7 +263,7 @@ void png_reader::read(unsigned x0, unsigned y0, unsigned w, unsigned h, char png_read_row(png_ptr,row.get(),0); if (i >= y0 && i < (y0 + h)) { - std::copy(&row[x0 * 4], &row[x0 * 4] + w, image + i * width_* 4); + std::copy(&row[x0 * 4], &row[x0 * 4] + w * 4, image + i * width_* 4); } } }