From ce86061d9ffd2d0c9f84ff48d6d10fd4dcef8016 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 8 Aug 2013 14:32:51 +0200 Subject: Add offset reading support in pnghandler This patch adds the offset reading that matches the offset writing in writeImage Qt 5 fix commit 0b62a5d3c931aa4d91b986ec518567e9463a6360 Task-number: QTBUG-32674 Change-Id: I64f7e31049834ecbd052a061b79d3ed97e60e063 Reviewed-by: aavit Reviewed-by: Laszlo Papp --- src/gui/image/qpnghandler.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index fd0dd91..ac78610 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -492,10 +492,14 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage) png_uint_32 width; png_uint_32 height; + png_int_32 offset_x; + png_int_32 offset_y; int bit_depth; int color_type; + int unit_type; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -527,6 +531,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage) outImage->setDotsPerMeterX(png_get_x_pixels_per_meter(png_ptr,info_ptr)); outImage->setDotsPerMeterY(png_get_y_pixels_per_meter(png_ptr,info_ptr)); + if (unit_type == PNG_OFFSET_PIXEL) + outImage->setOffset(QPoint(offset_x, offset_y)); + state = ReadingEnd; png_read_end(png_ptr, end_info); -- cgit v0.12