GraphicsMagick: coders/topol.c: Fix tile positioning.

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.7850.1687351533.1565.graphicsmagick-commit@lists.sourceforge.net>
changeset d45cc9051a4f in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d45cc9051a4f
summary: coders/topol.c: Fix tile positioning.

diffstat:

 ChangeLog      |   4 ++++
 coders/topol.c |  13 ++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diffs (55 lines):

diff -r ee4446b4fa94 -r d45cc9051a4f ChangeLog
--- a/ChangeLog	Tue Jun 20 13:11:06 2023 -0500
+++ b/ChangeLog	Wed Jun 21 14:44:58 2023 +0200
@@ -1,3 +1,7 @@
+2023-06-21  Fojtik Jaroslav  <[email protected]>
+
+	* coders/topol.c: Fix tile positioning.
+
 2023-06-20  Bob Friesenhahn  <[email protected]>
 
 	* coders/webp.c (ReadWEBPImage): SourceForge patch #77 "Don't
diff -r ee4446b4fa94 -r d45cc9051a4f coders/topol.c
--- a/coders/topol.c	Tue Jun 20 13:11:06 2023 -0500
+++ b/coders/topol.c	Wed Jun 21 14:44:58 2023 +0200
@@ -550,9 +550,8 @@
   /* If ping is true, then only set image size and colors without reading any image data. */
   if (image_info->ping) goto DONE_READING;
 
-  if(j>=512)
-      if(((magick_uint64_t)(depth*Header.Cols+7)/8) * (magick_uint64_t)Header.Rows > (magick_uint64_t)GetBlobSize(image)-512)
-        goto TOPOL_KO;    /* Check for forged image that overflows file size. */
+  if(((magick_uint64_t)(depth*Header.Cols+7)/8) * (magick_uint64_t)Header.Rows > (magick_uint64_t)GetBlobSize(image)-512)
+      goto TOPOL_KO;    /* Check for forged image that overflows file size. */
 
   /* ----- Handle the reindexing mez file ----- */
   j = image->colors;
@@ -730,8 +729,8 @@
          ThrowTOPOLReaderException(CorruptImageError,InsufficientImageDataInFile, image);
        }
 
-       for(TilY=0;TilY<Header.Rows;TilY+=Header.TileHeight)
-         for(TilX=0;TilX<TilesAcross;TilX++)
+       for(TilY=0; TilY<Header.Rows; TilY+=Header.TileHeight)	/* TilY counts per pixel.*/
+         for(TilX=0; TilX<TilesAcross; TilX++)			/* TilX counts per tile.*/
            {
            ldblk = Offsets[(TilY/Header.TileHeight)*TilesAcross+TilX];
            if(SeekBlob(image, ldblk, SEEK_SET) != ldblk)
@@ -760,7 +759,8 @@
              }
              if(SkipBlk>0)
                SeekBlob(image, SkipBlk, SEEK_CUR);
-             if(InsertRow(depth, BImgBuff, i+TilY, image, TilX,
+             /*printf("Inserting x=%d; y=%d\n", TilX*Header.TileWidth, i+TilY);*/
+             if(InsertRow(depth, BImgBuff, i+TilY, image, TilX*Header.TileWidth,
                     (image->columns<Header.TileWidth)?image->columns:Header.TileWidth, &import_options))
              {
                MagickFreeResourceLimitedMemory(Offsets);
@@ -775,7 +775,6 @@
       }
     }
 
-
   /* Finish: */
 DONE_READING:
   MagickFreeResourceLimitedMemory(BImgBuff);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.