From 649df4bff86bf8b82a8bdb1c44b06d570b612028 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Sun, 28 Aug 2011 21:38:22 +0000 Subject: [PATCH] Fixed calculated image pitch being off-by-one in some cases. The variable linebytes sometimes counted one extra byte, which is OK for allocating but not when accessing the image later on. Calculate the value in a slightly different way and made the variable const. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/imagtiff.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index fff70bfa64..2d224133c4 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -640,7 +640,9 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); - // scanlinesize if determined by spp and bps + // scanlinesize is determined by spp and bps + const tsize_t linebytes = + (tsize_t)((image->GetWidth() * spp * bps + 7) / 8); tsize_t linebytes = (tsize_t)image->GetWidth() * spp * bps / 8; if ( (image->GetWidth() % 8 > 0) && (spp * bps < 8) ) -- 2.50.0