]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed calculated image pitch being off-by-one in some cases.
authorDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Sun, 28 Aug 2011 21:38:22 +0000 (21:38 +0000)
committerDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Sun, 28 Aug 2011 21:38:22 +0000 (21:38 +0000)
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

index fff70bfa6474186b907cdecaba930a6370997fcd..2d224133c408201c9709231eebd80b87ec51faaa 100644 (file)
@@ -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) )