~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to coders/tiff.c

  • Committer: Bazaar Package Importer
  • Author(s): Nelson A. de Oliveira
  • Date: 2010-06-20 19:59:55 UTC
  • mfrom: (6.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100620195955-n3eq0yenhycw888i
Tags: 7:6.6.2.6-1
* New upstream release;
* Change Recommends on ufraw to ufraw-batch (Closes: #579775);
* Fix FTBFS when using dash to run the configure script, by setting
  CONFIG_SHELL=/bin/bash (Closes: #582073, #583024). Thank you, Niko Tyni!

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
%                                 July 1992                                   %
18
18
%                                                                             %
19
19
%                                                                             %
20
 
%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
 
20
%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
21
21
%  dedicated to making software imaging solutions freely available.           %
22
22
%                                                                             %
23
23
%  You may not use this file except in compliance with the License.  You may  %
46
46
#include "magick/cache.h"
47
47
#include "magick/color.h"
48
48
#include "magick/color-private.h"
 
49
#include "magick/colormap.h"
49
50
#include "magick/colorspace.h"
50
51
#include "magick/constitute.h"
51
52
#include "magick/enhance.h"
73
74
#include "magick/static.h"
74
75
#include "magick/statistic.h"
75
76
#include "magick/string_.h"
 
77
#include "magick/string-private.h"
76
78
#include "magick/thread_.h"
77
79
#include "magick/utility.h"
78
 
#include "magick/module.h"
79
80
#if defined(MAGICKCORE_TIFF_DELEGATE)
80
81
# if defined(MAGICKCORE_HAVE_TIFFCONF_H)
81
82
#  include "tiffconf.h"
262
263
%
263
264
*/
264
265
 
265
 
static inline size_t WriteLSBLong(FILE *file,const unsigned int value)
 
266
static inline size_t WriteLSBLong(FILE *file,const size_t value)
266
267
{
267
268
  unsigned char
268
269
    buffer[4];
340
341
  length=fwrite("\006\001\003\000\001\000\000\000\000\000\000\000",1,12,file);
341
342
  length=fwrite("\021\001\003\000\001\000\000\000",1,8,file);
342
343
  strip_offset=10+(12*14)+4+8;
343
 
  length=WriteLSBLong(file,(unsigned long) strip_offset);
 
344
  length=WriteLSBLong(file,(size_t) strip_offset);
344
345
  length=fwrite("\022\001\003\000\001\000\000\000",1,8,file);
345
 
  length=WriteLSBLong(file,(unsigned long) image_info->orientation);
 
346
  length=WriteLSBLong(file,(size_t) image_info->orientation);
346
347
  length=fwrite("\025\001\003\000\001\000\000\000\001\000\000\000",1,12,file);
347
348
  length=fwrite("\026\001\004\000\001\000\000\000",1,8,file);
348
349
  length=WriteLSBLong(file,image->rows);
349
350
  length=fwrite("\027\001\004\000\001\000\000\000\000\000\000\000",1,12,file);
350
351
  offset=(ssize_t) ftell(file)-4;
351
352
  length=fwrite("\032\001\005\000\001\000\000\000",1,8,file);
352
 
  length=WriteLSBLong(file,(unsigned long) (strip_offset-8));
 
353
  length=WriteLSBLong(file,(size_t) (strip_offset-8));
353
354
  length=fwrite("\033\001\005\000\001\000\000\000",1,8,file);
354
 
  length=WriteLSBLong(file,(unsigned long) (strip_offset-8));
 
355
  length=WriteLSBLong(file,(size_t) (strip_offset-8));
355
356
  length=fwrite("\050\001\003\000\001\000\000\000\002\000\000\000",1,12,file);
356
357
  length=fwrite("\000\000\000\000",1,4,file);
357
358
  length=WriteLSBLong(file,image->x_resolution);
358
359
  length=WriteLSBLong(file,1);
359
360
  for (length=0; (c=ReadBlobByte(image)) != EOF; length++)
360
361
    (void) fputc(c,file);
361
 
  offset=(ssize_t) fseek(file,(long) offset,SEEK_SET);
 
362
  offset=(ssize_t) fseek(file,(ssize_t) offset,SEEK_SET);
362
363
  length=WriteLSBLong(file,(unsigned int) length);
363
364
  (void) fclose(file);
364
365
  (void) CloseBlob(image);
420
421
  return(y);
421
422
}
422
423
 
423
 
static inline long MagickMin(const long x,const long y)
 
424
static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
424
425
{
425
426
  if (x < y)
426
427
    return(x);
428
429
}
429
430
 
430
431
static MagickBooleanType ReadProfile(Image *image,const char *name,
431
 
  unsigned char *datum,long length)
 
432
  unsigned char *datum,ssize_t length)
432
433
{
433
434
  MagickBooleanType
434
435
    status;
435
436
 
436
 
  register long
 
437
  register ssize_t
437
438
    i;
438
439
 
439
440
  StringInfo
505
506
#if defined(TIFFTAG_ICCPROFILE)
506
507
  length=0;
507
508
  if (TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1)
508
 
    (void) ReadProfile(image,"icc",profile,(long) length);
 
509
    (void) ReadProfile(image,"icc",profile,(ssize_t) length);
509
510
#endif
510
511
#if defined(TIFFTAG_PHOTOSHOP)
511
512
  length=0;
512
513
  if (TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1)
513
 
    (void) ReadProfile(image,"8bim",profile,(long) length);
 
514
    (void) ReadProfile(image,"8bim",profile,(ssize_t) length);
514
515
#endif
515
516
#if defined(TIFFTAG_RICHTIFFIPTC)
516
517
  length=0;
517
518
  if (TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1)
518
519
    {
519
520
      if (TIFFIsByteSwapped(tiff) != 0)
520
 
        TIFFSwabArrayOfLong((uint32 *) profile,(unsigned long) length);
 
521
        TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length);
521
522
      (void) ReadProfile(image,"iptc",profile,4L*length);
522
523
    }
523
524
#endif
524
525
#if defined(TIFFTAG_XMLPACKET)
525
526
  length=0;
526
527
  if (TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1)
527
 
    (void) ReadProfile(image,"xmp",profile,(long) length);
 
528
    (void) ReadProfile(image,"xmp",profile,(ssize_t) length);
528
529
#endif
529
530
  length=0;
530
531
  if (TIFFGetField(tiff,37724,&length,&profile) == 1)
531
 
    (void) ReadProfile(image,"tiff:37724",profile,(long) length);
 
532
    (void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length);
532
533
}
533
534
 
534
535
static void TIFFGetProperties(TIFF *tiff,Image *image)
564
565
  char
565
566
    value[MaxTextExtent];
566
567
 
567
 
  register long
 
568
  register ssize_t
568
569
    i;
569
570
 
570
571
  tdir_t
607
608
      case TIFF_LONG:
608
609
      {
609
610
        uint32
610
 
          longy;
 
611
          ssize_ty;
611
612
 
612
 
        if (TIFFGetField(tiff,exif_info[i].tag,&longy) != 0)
613
 
          (void) FormatMagickString(value,MaxTextExtent,"%d",longy);
 
613
        if (TIFFGetField(tiff,exif_info[i].tag,&ssize_ty) != 0)
 
614
          (void) FormatMagickString(value,MaxTextExtent,"%d",ssize_ty);
614
615
        break;
615
616
      }
616
617
      case TIFF_RATIONAL:
656
657
  return(count);
657
658
}
658
659
 
659
 
static int32 TIFFReadPixels(TIFF *tiff,unsigned long bits_per_sample,
660
 
  tsample_t sample,long row,tdata_t scanline)
 
660
static int32 TIFFReadPixels(TIFF *tiff,size_t bits_per_sample,
 
661
  tsample_t sample,ssize_t row,tdata_t scanline)
661
662
{
662
663
  int32
663
664
    status;
744
745
  Image
745
746
    *image;
746
747
 
747
 
  long
 
748
  ssize_t
748
749
    y;
749
750
 
750
751
  MagickBooleanType
761
762
  QuantumType
762
763
    quantum_type;
763
764
 
764
 
  register long
 
765
  register ssize_t
765
766
    i;
766
767
 
767
768
  size_t
803
804
  unsigned char
804
805
    *pixels;
805
806
 
806
 
  unsigned long
 
807
  size_t
807
808
    lsb_first;
808
809
 
809
810
  /*
842
843
      /*
843
844
        Generate blank images for subimage specification (e.g. image.tif[4].
844
845
      */
845
 
      for (i=0; i < (long) image_info->scene; i++)
 
846
      for (i=0; i < (ssize_t) image_info->scene; i++)
846
847
      {
847
848
        (void) TIFFReadDirectory(tiff);
848
849
        AcquireNextImage(image_info,image);
922
923
        (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Photometric "
923
924
          "interpretation: %s",GetImageProperty(image,"tiff:photometric"));
924
925
      }
925
 
    image->columns=(unsigned long) width;
926
 
    image->rows=(unsigned long) height;
927
 
    image->depth=(unsigned long) bits_per_sample;
 
926
    image->columns=(size_t) width;
 
927
    image->rows=(size_t) height;
 
928
    image->depth=(size_t) bits_per_sample;
928
929
    if (image->debug != MagickFalse)
929
 
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image depth: %lu",
930
 
        image->depth);
 
930
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image depth: %.20g",
 
931
        (double) image->depth);
931
932
    lsb_first=1;
932
933
    image->endian=MSBEndian;
933
934
    if ((int) (*(char *) &lsb_first) != 0)
949
950
    y_position=(float) image->page.y/y_resolution;
950
951
    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
951
952
    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
952
 
    image->page.x=(long) (x_position*x_resolution+0.5);
953
 
    image->page.y=(long) (y_position*y_resolution+0.5);
 
953
    image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
 
954
    image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
954
955
    image->orientation=(OrientationType) orientation;
955
956
    chromaticity=(float *) NULL;
956
957
    (void) TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity);
1030
1031
    }
1031
1032
    quantum_info=AcquireQuantumInfo(image_info,image);
1032
1033
    if (quantum_info == (QuantumInfo *) NULL)
1033
 
      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1034
      {
 
1035
        TIFFClose(tiff);
 
1036
        ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1037
      }
1034
1038
    if (sample_format == SAMPLEFORMAT_UINT)
1035
1039
      status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat);
1036
1040
    if (sample_format == SAMPLEFORMAT_INT)
1038
1042
    if (sample_format == SAMPLEFORMAT_IEEEFP)
1039
1043
      status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);
1040
1044
    if (status == MagickFalse)
1041
 
      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1045
      {
 
1046
        TIFFClose(tiff);
 
1047
        ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1048
      }
1042
1049
    status=MagickTrue;
1043
1050
    switch (photometric)
1044
1051
    {
1065
1072
          image->matte=MagickTrue;
1066
1073
      }
1067
1074
    else
 
1075
      for (i=0; i < extra_samples; i++)
1068
1076
      {
1069
 
        if (samples_per_pixel > 3)
1070
 
          {
1071
 
            image->matte=MagickTrue;
1072
 
            associated_alpha=MagickFalse;
1073
 
          }
1074
 
        if (sample_info[0] == EXTRASAMPLE_UNASSALPHA)
1075
 
          {
1076
 
            image->matte=MagickTrue;
1077
 
            associated_alpha=MagickFalse;
1078
 
          }
1079
 
        if (sample_info[0] == EXTRASAMPLE_ASSOCALPHA)
1080
 
          {
1081
 
            image->matte=MagickTrue;
1082
 
            associated_alpha=MagickTrue;
1083
 
            SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
1084
 
          }
 
1077
        image->matte=MagickTrue;
 
1078
        if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
 
1079
          SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
1085
1080
      }
1086
1081
    option=GetImageOption(image_info,"tiff:alpha");
1087
1082
    if (option != (const char *) NULL)
1093
1088
    if ((photometric == PHOTOMETRIC_PALETTE) &&
1094
1089
        (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))
1095
1090
      {
1096
 
        unsigned long
 
1091
        size_t
1097
1092
          colors;
1098
1093
 
1099
 
        colors=(unsigned long) GetQuantumRange(bits_per_sample)+1;
 
1094
        colors=(size_t) GetQuantumRange(bits_per_sample)+1;
1100
1095
        if (AcquireImageColormap(image,colors) == MagickFalse)
1101
1096
          {
1102
1097
            TIFFClose(tiff);
1158
1153
        if ((image->storage_class == PseudoClass) &&
1159
1154
            (photometric == PHOTOMETRIC_PALETTE))
1160
1155
          {
1161
 
            unsigned long
 
1156
            size_t
1162
1157
              range;
1163
1158
 
1164
1159
            uint16
1172
1167
            (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
1173
1168
              &green_colormap,&blue_colormap);
1174
1169
            range=255;  /* might be old style 8-bit colormap */
1175
 
            for (i=0; i < (long) image->colors; i++)
 
1170
            for (i=0; i < (ssize_t) image->colors; i++)
1176
1171
              if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
1177
1172
                  (blue_colormap[i] >= 256))
1178
1173
                {
1179
1174
                  range=65535;
1180
1175
                  break;
1181
1176
                }
1182
 
            for (i=0; i < (long) image->colors; i++)
 
1177
            for (i=0; i < (ssize_t) image->colors; i++)
1183
1178
            {
1184
 
              image->colormap[i].red=RoundToQuantum(((double) QuantumRange*
 
1179
              image->colormap[i].red=ClampToQuantum(((double) QuantumRange*
1185
1180
                red_colormap[i])/range);
1186
 
              image->colormap[i].green=RoundToQuantum(((double) QuantumRange*
 
1181
              image->colormap[i].green=ClampToQuantum(((double) QuantumRange*
1187
1182
                green_colormap[i])/range);
1188
 
              image->colormap[i].blue=RoundToQuantum(((double) QuantumRange*
 
1183
              image->colormap[i].blue=ClampToQuantum(((double) QuantumRange*
1189
1184
                blue_colormap[i])/range);
1190
1185
            }
1191
1186
          }
1213
1208
            }
1214
1209
        status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3));
1215
1210
        if (status == MagickFalse)
1216
 
          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1211
          {
 
1212
            TIFFClose(tiff);
 
1213
            ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1214
          }
1217
1215
        pixels=GetQuantumPixels(quantum_info);
1218
 
        for (y=0; y < (long) image->rows; y++)
 
1216
        for (y=0; y < (ssize_t) image->rows; y++)
1219
1217
        {
1220
1218
          int
1221
1219
            status;
1222
1220
 
1223
1221
          register PixelPacket
1224
 
            *__restrict q;
 
1222
            *restrict q;
1225
1223
 
1226
1224
          status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels);
1227
1225
          if (status == -1)
1235
1233
            break;
1236
1234
          if (image->previous == (Image *) NULL)
1237
1235
            {
1238
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1236
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1237
                image->rows);
1239
1238
              if (status == MagickFalse)
1240
1239
                break;
1241
1240
            }
1266
1265
          }
1267
1266
        status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3));
1268
1267
        if (status == MagickFalse)
1269
 
          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1268
          {
 
1269
            TIFFClose(tiff);
 
1270
            ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
 
1271
          }
1270
1272
        pixels=GetQuantumPixels(quantum_info);
1271
 
        for (y=0; y < (long) image->rows; y++)
 
1273
        for (y=0; y < (ssize_t) image->rows; y++)
1272
1274
        {
1273
1275
          int
1274
1276
            status;
1275
1277
 
1276
1278
          register PixelPacket
1277
 
            *__restrict q;
 
1279
            *restrict q;
1278
1280
 
1279
1281
          status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels);
1280
1282
          if (status == -1)
1288
1290
            break;
1289
1291
          if (image->previous == (Image *) NULL)
1290
1292
            {
1291
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1293
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1294
                image->rows);
1292
1295
              if (status == MagickFalse)
1293
1296
                break;
1294
1297
            }
1300
1303
        /*
1301
1304
          Convert TIFF image to DirectClass MIFF image.
1302
1305
        */
1303
 
        for (i=0; i < (long) samples_per_pixel; i++)
 
1306
        for (i=0; i < (ssize_t) samples_per_pixel; i++)
1304
1307
        {
1305
 
          for (y=0; y < (long) image->rows; y++)
 
1308
          for (y=0; y < (ssize_t) image->rows; y++)
1306
1309
          {
1307
1310
            register PixelPacket
1308
 
              *__restrict q;
 
1311
              *restrict q;
1309
1312
 
1310
1313
            int
1311
1314
              status;
1343
1346
          }
1344
1347
          if (image->previous == (Image *) NULL)
1345
1348
            {
1346
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1349
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1350
                image->rows);
1347
1351
              if (status == MagickFalse)
1348
1352
                break;
1349
1353
            }
1360
1364
        */
1361
1365
        i=0;
1362
1366
        p=(unsigned char *) NULL;
1363
 
        for (y=0; y < (long) image->rows; y++)
 
1367
        for (y=0; y < (ssize_t) image->rows; y++)
1364
1368
        {
1365
 
          register long
 
1369
          register ssize_t
1366
1370
            x;
1367
1371
 
1368
1372
          register PixelPacket
1369
 
            *__restrict q;
 
1373
            *restrict q;
1370
1374
 
1371
1375
          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
1372
1376
          if (q == (PixelPacket *) NULL)
1375
1379
            {
1376
1380
              if (TIFFReadRGBAStrip(tiff,(tstrip_t) y,(uint32 *) pixels) == 0)
1377
1381
                break;
1378
 
              i=(long) MagickMin((long) rows_per_strip,(long) image->rows-y);
 
1382
              i=(ssize_t) MagickMin((ssize_t) rows_per_strip,(ssize_t)
 
1383
                image->rows-y);
1379
1384
            }
1380
1385
          i--;
1381
1386
          p=pixels+image->columns*i;
1382
 
          for (x=0; x < (long) image->columns; x++)
 
1387
          for (x=0; x < (ssize_t) image->columns; x++)
1383
1388
          {
1384
1389
            q->red=ScaleCharToQuantum((unsigned char) (TIFFGetR(*p)));
1385
1390
            q->green=ScaleCharToQuantum((unsigned char) (TIFFGetG(*p)));
1393
1398
            break;
1394
1399
          if (image->previous == (Image *) NULL)
1395
1400
            {
1396
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1401
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1402
                image->rows);
1397
1403
              if (status == MagickFalse)
1398
1404
                break;
1399
1405
            }
1410
1416
          columns,
1411
1417
          rows;
1412
1418
 
1413
 
        unsigned long
 
1419
        size_t
1414
1420
          number_pixels;
1415
1421
 
1416
1422
        /*
1431
1437
            TIFFClose(tiff);
1432
1438
            ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
1433
1439
          }
1434
 
        for (y=0; y < (long) image->rows; y+=rows)
 
1440
        for (y=0; y < (ssize_t) image->rows; y+=rows)
1435
1441
        {
1436
1442
          PixelPacket
1437
1443
            *tile;
1438
1444
 
1439
 
          register long
 
1445
          register ssize_t
1440
1446
            x;
1441
1447
 
1442
1448
          register PixelPacket
1443
 
            *__restrict q;
 
1449
            *restrict q;
1444
1450
 
1445
 
          unsigned long
 
1451
          size_t
1446
1452
            columns_remaining,
1447
1453
            rows_remaining;
1448
1454
 
1449
1455
          rows_remaining=image->rows-y;
1450
 
          if ((long) (y+rows) < (long) image->rows)
 
1456
          if ((ssize_t) (y+rows) < (ssize_t) image->rows)
1451
1457
            rows_remaining=rows;
1452
1458
          tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining,
1453
1459
            exception);
1454
1460
          if (tile == (PixelPacket *) NULL)
1455
1461
            break;
1456
 
          for (x=0; x < (long) image->columns; x+=columns)
 
1462
          for (x=0; x < (ssize_t) image->columns; x+=columns)
1457
1463
          {
1458
 
            unsigned long
 
1464
            size_t
1459
1465
              column,
1460
1466
              row;
1461
1467
 
1462
1468
            if (TIFFReadRGBATile(tiff,(uint32) x,(uint32) y,tile_pixels) == 0)
1463
1469
              break;
1464
1470
            columns_remaining=image->columns-x;
1465
 
            if ((long) (x+columns) < (long) image->columns)
 
1471
            if ((ssize_t) (x+columns) < (ssize_t) image->columns)
1466
1472
              columns_remaining=columns;
1467
1473
            p=tile_pixels+(rows-rows_remaining)*columns;
1468
1474
            q=tile+(image->columns*(rows_remaining-1)+x);
1496
1502
            break;
1497
1503
          if (image->previous == (Image *) NULL)
1498
1504
            {
1499
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1505
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1506
                image->rows);
1500
1507
              if (status == MagickFalse)
1501
1508
                break;
1502
1509
            }
1536
1543
          Convert image to DirectClass pixel packets.
1537
1544
        */
1538
1545
        p=pixels+number_pixels-1;
1539
 
        for (y=0; y < (long) image->rows; y++)
 
1546
        for (y=0; y < (ssize_t) image->rows; y++)
1540
1547
        {
1541
 
          register long
 
1548
          register ssize_t
1542
1549
            x;
1543
1550
 
1544
1551
          register PixelPacket
1545
 
            *__restrict q;
 
1552
            *restrict q;
1546
1553
 
1547
1554
          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
1548
1555
          if (q == (PixelPacket *) NULL)
1549
1556
            break;
1550
1557
          q+=image->columns-1;
1551
 
          for (x=0; x < (long) image->columns; x++)
 
1558
          for (x=0; x < (ssize_t) image->columns; x++)
1552
1559
          {
1553
1560
            q->red=ScaleCharToQuantum((unsigned char) TIFFGetR(*p));
1554
1561
            q->green=ScaleCharToQuantum((unsigned char) TIFFGetG(*p));
1562
1569
            break;
1563
1570
          if (image->previous == (Image *) NULL)
1564
1571
            {
1565
 
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
 
1572
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
 
1573
                image->rows);
1566
1574
              if (status == MagickFalse)
1567
1575
                break;
1568
1576
            }
1647
1655
%
1648
1656
%  The format of the RegisterTIFFImage method is:
1649
1657
%
1650
 
%      unsigned long RegisterTIFFImage(void)
 
1658
%      size_t RegisterTIFFImage(void)
1651
1659
%
1652
1660
*/
1653
 
ModuleExport unsigned long RegisterTIFFImage(void)
 
1661
ModuleExport size_t RegisterTIFFImage(void)
1654
1662
{
1655
1663
#define TIFFDescription  "Tagged Image File Format"
1656
1664
 
1662
1670
  
1663
1671
  if (tiff_semaphore == (SemaphoreInfo *) NULL)
1664
1672
    tiff_semaphore=AllocateSemaphoreInfo();
1665
 
  (void) LockSemaphoreInfo(tiff_semaphore);
 
1673
  LockSemaphoreInfo(tiff_semaphore);
1666
1674
  if (instantiate_key == MagickFalse)
1667
1675
    {
1668
1676
      if (MagickCreateThreadKey(&tiff_exception) == MagickFalse)
1669
1677
        ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1670
1678
      instantiate_key=MagickTrue;
1671
1679
    }
1672
 
  (void) UnlockSemaphoreInfo(tiff_semaphore);
 
1680
  UnlockSemaphoreInfo(tiff_semaphore);
1673
1681
  *version='\0';
1674
1682
#if defined(TIFF_VERSION)
1675
1683
  (void) FormatMagickString(version,MaxTextExtent,"%d",TIFF_VERSION);
1679
1687
    const char
1680
1688
      *p;
1681
1689
 
1682
 
    register long int
 
1690
    register ssize_t
1683
1691
      i;
1684
1692
 
1685
1693
    p=TIFFGetVersion();
1784
1792
  (void) UnregisterMagickInfo("TIF");
1785
1793
  (void) UnregisterMagickInfo("TIFF");
1786
1794
  (void) UnregisterMagickInfo("TIFF64");
1787
 
  (void) LockSemaphoreInfo(tiff_semaphore);
 
1795
  if (tiff_semaphore == (SemaphoreInfo *) NULL)
 
1796
    tiff_semaphore=AllocateSemaphoreInfo();
 
1797
  LockSemaphoreInfo(tiff_semaphore);
1788
1798
  if (instantiate_key != MagickFalse)
1789
1799
    if (MagickDeleteThreadKey(tiff_exception) == MagickFalse)
1790
1800
      ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1791
1801
  instantiate_key=MagickFalse;
1792
 
  (void) UnlockSemaphoreInfo(tiff_semaphore);
 
1802
  UnlockSemaphoreInfo(tiff_semaphore);
1793
1803
  DestroySemaphoreInfo(&tiff_semaphore);
1794
1804
}
1795
1805
 
1840
1850
  MagickBooleanType
1841
1851
    status;
1842
1852
 
1843
 
  register long
 
1853
  register ssize_t
1844
1854
    i;
1845
1855
 
1846
1856
  ssize_t
1926
1936
      return(MagickFalse);
1927
1937
    }
1928
1938
  strip_size=byte_count[0];
1929
 
  for (i=1; i < (long) TIFFNumberOfStrips(tiff); i++)
 
1939
  for (i=1; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
1930
1940
    if (byte_count[i] > strip_size)
1931
1941
      strip_size=byte_count[i];
1932
1942
  buffer=(unsigned char *) AcquireQuantumMemory((size_t) strip_size,
1943
1953
  /*
1944
1954
    Compress runlength encoded to 2D Huffman pixels.
1945
1955
  */
1946
 
  for (i=0; i < (long) TIFFNumberOfStrips(tiff); i++)
 
1956
  for (i=0; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
1947
1957
  {
1948
1958
    count=(ssize_t) TIFFReadRawStrip(tiff,(uint32) i,buffer,strip_size);
1949
1959
    if (WriteBlob(image,(size_t) count,buffer) != count)
2000
2010
  MagickBooleanType
2001
2011
    status;
2002
2012
 
2003
 
  unsigned long
 
2013
  size_t
2004
2014
    columns,
2005
2015
    rows;
2006
2016
 
2119
2129
  return(MagickTrue);
2120
2130
}
2121
2131
 
2122
 
static int32 TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,long row,
 
2132
static int32 TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,
2123
2133
  tsample_t sample,Image *image)
2124
2134
{
2125
2135
  int32
2126
2136
    status;
2127
2137
 
2128
 
  long
 
2138
  ssize_t
2129
2139
    bytes_per_pixel,
2130
2140
    j,
2131
2141
    k,
2132
2142
    l;
2133
2143
 
2134
 
  register long
 
2144
  register ssize_t
2135
2145
    i;
2136
2146
 
2137
2147
  register unsigned char
2138
2148
    *p,
2139
2149
    *q;
2140
2150
 
2141
 
  unsigned long
 
2151
  size_t
2142
2152
    number_tiles,
2143
2153
    tile_width;
2144
2154
 
2147
2157
  /*
2148
2158
    Fill scanlines to tile height.
2149
2159
  */
2150
 
  i=(long) (row % tiff_info->tile_geometry.height)*TIFFScanlineSize(tiff);
 
2160
  i=(ssize_t) (row % tiff_info->tile_geometry.height)*TIFFScanlineSize(tiff);
2151
2161
  (void) CopyMagickMemory(tiff_info->scanlines+i,(char *) tiff_info->scanline,
2152
2162
    (size_t) TIFFScanlineSize(tiff));
2153
 
  if (((unsigned long) (row % tiff_info->tile_geometry.height) !=
2154
 
      (tiff_info->tile_geometry.height-1)) && (row != (long) (image->rows-1)))
 
2163
  if (((size_t) (row % tiff_info->tile_geometry.height) !=
 
2164
      (tiff_info->tile_geometry.height-1)) && (row != (ssize_t) (image->rows-1)))
2155
2165
    return(0);
2156
2166
  /*
2157
2167
    Write tile to TIFF image.
2158
2168
  */
2159
2169
  status=0;
2160
 
  bytes_per_pixel=TIFFTileSize(tiff)/(long) (tiff_info->tile_geometry.height*
 
2170
  bytes_per_pixel=TIFFTileSize(tiff)/(ssize_t) (tiff_info->tile_geometry.height*
2161
2171
    tiff_info->tile_geometry.width);
2162
2172
  number_tiles=(image->columns+tiff_info->tile_geometry.width)/
2163
2173
    tiff_info->tile_geometry.width;
2164
 
  for (i=0; i < (long) number_tiles; i++)
 
2174
  for (i=0; i < (ssize_t) number_tiles; i++)
2165
2175
  {
2166
 
    tile_width=(i == (long) (number_tiles-1)) ? image->columns-(i*
 
2176
    tile_width=(i == (ssize_t) (number_tiles-1)) ? image->columns-(i*
2167
2177
      tiff_info->tile_geometry.width) : tiff_info->tile_geometry.width;
2168
 
    for (j=0; j < (long) ((row % tiff_info->tile_geometry.height)+1); j++)
2169
 
      for (k=0; k < (long) tile_width; k++)
 
2178
    for (j=0; j < (ssize_t) ((row % tiff_info->tile_geometry.height)+1); j++)
 
2179
      for (k=0; k < (ssize_t) tile_width; k++)
2170
2180
      {
2171
2181
        if (bytes_per_pixel == 0)
2172
2182
          {
2182
2192
        for (l=0; l < bytes_per_pixel; l++)
2183
2193
          *q++=(*p++);
2184
2194
      }
2185
 
    status=TIFFWriteTile(tiff,tiff_info->pixels,(uint32) (i*
2186
 
      tiff_info->tile_geometry.width),(uint32) ((row/
2187
 
      tiff_info->tile_geometry.height)*tiff_info->tile_geometry.height),0,
2188
 
      sample);
 
2195
    if ((i*tiff_info->tile_geometry.width) != image->columns)
 
2196
      status=TIFFWriteTile(tiff,tiff_info->pixels,(uint32) (i*
 
2197
        tiff_info->tile_geometry.width),(uint32) ((row/
 
2198
        tiff_info->tile_geometry.height)*tiff_info->tile_geometry.height),0,
 
2199
        sample);
2189
2200
    if (status < 0)
2190
2201
      break;
2191
2202
  }
2268
2279
  if (value != (const char *) NULL)
2269
2280
    (void) TIFFSetField(tiff,TIFFTAG_MODEL,value);
2270
2281
  (void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,
2271
 
    GetMagickVersion((unsigned long *) NULL));
 
2282
    GetMagickVersion((size_t *) NULL));
2272
2283
  (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
2273
2284
  value=GetImageProperty(image,"tiff:copyright");
2274
2285
  if (value != (const char *) NULL)
2293
2304
  const char
2294
2305
    *value;
2295
2306
 
2296
 
  register long
 
2307
  register ssize_t
2297
2308
    i;
2298
2309
 
2299
2310
  uint32
2321
2332
        uint16
2322
2333
          shorty;
2323
2334
 
2324
 
        shorty=(uint16) atoi(value);
 
2335
        shorty=(uint16) StringToLong(value);
2325
2336
        (void) TIFFSetField(tiff,exif_info[i].tag,shorty);
2326
2337
        break;
2327
2338
      }
2328
2339
      case TIFF_LONG:
2329
2340
      {
2330
2341
        uint16
2331
 
          longy;
 
2342
          ssize_ty;
2332
2343
 
2333
 
        longy=(uint16) atol(value);
2334
 
        (void) TIFFSetField(tiff,exif_info[i].tag,longy);
 
2344
        ssize_ty=(uint16) StringToLong(value);
 
2345
        (void) TIFFSetField(tiff,exif_info[i].tag,ssize_ty);
2335
2346
        break;
2336
2347
      }
2337
2348
      case TIFF_RATIONAL:
2340
2351
        float
2341
2352
          rational;
2342
2353
 
2343
 
        rational=atof(value);
 
2354
        rational=StringToDouble(value);
2344
2355
        (void) TIFFSetField(tiff,exif_info[i].tag,rational);
2345
2356
        break;
2346
2357
      }
2366
2377
    *mode,
2367
2378
    *option;
2368
2379
 
2369
 
  const char
2370
 
    *value;
2371
 
 
2372
2380
  CompressionType
2373
2381
    compression;
2374
2382
 
2375
 
  long
 
2383
  ssize_t
2376
2384
    y;
2377
2385
 
2378
2386
  MagickBooleanType
2388
2396
  QuantumType
2389
2397
    quantum_type;
2390
2398
 
2391
 
  register long
 
2399
  register ssize_t
2392
2400
    i;
2393
2401
 
2394
2402
  size_t
2416
2424
  unsigned char
2417
2425
    *pixels;
2418
2426
 
2419
 
  unsigned long
 
2427
  size_t
2420
2428
    lsb_first;
2421
2429
 
2422
2430
  /*
2537
2545
      {
2538
2546
        (void) ThrowMagickException(&image->exception,GetMagickModule(),
2539
2547
          CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
2540
 
          MagickCompressOptions,(long) compression));
 
2548
          MagickCompressOptions,(ssize_t) compression));
2541
2549
        compress_tag=COMPRESSION_NONE;
2542
2550
        compression=NoCompression;
2543
2551
      }
2566
2574
        {
2567
2575
          (void) ThrowMagickException(&image->exception,GetMagickModule(),
2568
2576
            CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
2569
 
              MagickCompressOptions,(long) compression));
 
2577
              MagickCompressOptions,(ssize_t) compression));
2570
2578
          compress_tag=COMPRESSION_NONE;
2571
2579
          compression=NoCompression;
2572
2580
          break;
2639
2647
            else
2640
2648
              if (image->storage_class == PseudoClass)
2641
2649
                {
2642
 
                  unsigned long
 
2650
                  size_t
2643
2651
                    depth;
2644
2652
 
2645
2653
                  /*
2680
2688
    image->endian=MSBEndian;
2681
2689
    if ((int) (*(char *) &lsb_first) != 0)
2682
2690
      image->endian=LSBEndian;
2683
 
    if ((compress_tag == COMPRESSION_JPEG) && (photometric != PHOTOMETRIC_RGB))
2684
 
      compress_tag=COMPRESSION_NONE;
 
2691
    if ((compress_tag == COMPRESSION_CCITTFAX3) &&
 
2692
        (photometric != PHOTOMETRIC_MINISWHITE))
 
2693
      {
 
2694
        compress_tag=COMPRESSION_NONE;
 
2695
        endian=FILLORDER_MSB2LSB;
 
2696
      }
2685
2697
    else
2686
 
      if ((compress_tag == COMPRESSION_CCITTFAX3) &&
2687
 
          (photometric != PHOTOMETRIC_MINISWHITE))
2688
 
        {
2689
 
          compress_tag=COMPRESSION_NONE;
2690
 
          endian=FILLORDER_MSB2LSB;
2691
 
        }
2692
 
      else
2693
 
        if ((compress_tag == COMPRESSION_CCITTFAX4) &&
2694
 
           (photometric != PHOTOMETRIC_MINISWHITE))
2695
 
         {
2696
 
           compress_tag=COMPRESSION_NONE;
2697
 
           endian=FILLORDER_MSB2LSB;
2698
 
         }
 
2698
      if ((compress_tag == COMPRESSION_CCITTFAX4) &&
 
2699
         (photometric != PHOTOMETRIC_MINISWHITE))
 
2700
       {
 
2701
         compress_tag=COMPRESSION_NONE;
 
2702
         endian=FILLORDER_MSB2LSB;
 
2703
       }
2699
2704
    (void) TIFFSetField(tiff,TIFFTAG_COMPRESSION,compress_tag);
2700
2705
    (void) TIFFSetField(tiff,TIFFTAG_FILLORDER,endian);
2701
2706
    (void) TIFFSetField(tiff,TIFFTAG_BITSPERSAMPLE,quantum_info->depth);
2754
2759
        (void) TIFFSetField(tiff,TIFFTAG_PLANARCONFIG,PLANARCONFIG_SEPARATE);
2755
2760
    rows_per_strip=1;
2756
2761
    if (TIFFScanlineSize(tiff) != 0)
2757
 
      rows_per_strip=(unsigned long) MagickMax((size_t)
2758
 
        TIFFDefaultStripSize(tiff,-1),1);
 
2762
      rows_per_strip=(uint32) MagickMax((size_t) TIFFDefaultStripSize(tiff,0),
 
2763
        1);
2759
2764
    option=GetImageOption(image_info,"tiff:rows-per-strip");
2760
2765
    if (option != (const char *) NULL)
2761
 
      rows_per_strip=(unsigned long) strtol(option,(char **) NULL,10);
 
2766
      rows_per_strip=(size_t) strtol(option,(char **) NULL,10);
2762
2767
    switch (compress_tag)
2763
2768
    {
2764
2769
      case COMPRESSION_JPEG:
2781
2786
        (void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RAW);
2782
2787
        if (image->colorspace == RGBColorspace)
2783
2788
          {
 
2789
            const char
 
2790
              *value;
 
2791
 
2784
2792
            (void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB);
2785
2793
            sampling_factor=(const char *) NULL;
2786
2794
            value=GetImageProperty(image,"jpeg:sampling-factor");
2809
2817
      }
2810
2818
      case COMPRESSION_ADOBE_DEFLATE:
2811
2819
      {
2812
 
        rows_per_strip=image->rows;
 
2820
        rows_per_strip=(uint32) image->rows;
2813
2821
        (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,
2814
2822
          &bits_per_sample);
2815
2823
        if (((photometric == PHOTOMETRIC_RGB) ||
2816
2824
             (photometric == PHOTOMETRIC_MINISBLACK)) &&
2817
2825
            ((bits_per_sample == 8) || (bits_per_sample == 16)))
2818
2826
          (void) TIFFSetField(tiff,TIFFTAG_PREDICTOR,2);
2819
 
        (void) TIFFSetField(tiff,TIFFTAG_ZIPQUALITY,image_info->quality ==
2820
 
          UndefinedCompressionQuality ? 7 : MagickMin(1L*image_info->quality/10,
2821
 
          9));
 
2827
        (void) TIFFSetField(tiff,TIFFTAG_ZIPQUALITY,(long) (
 
2828
          image_info->quality == UndefinedCompressionQuality ? 7 :
 
2829
          MagickMin((ssize_t) image_info->quality/10,9)));
2822
2830
        break;
2823
2831
      }
2824
2832
      case COMPRESSION_CCITTFAX3:
2826
2834
        /*
2827
2835
          Byte-aligned EOL.
2828
2836
        */
2829
 
        rows_per_strip=image->rows;
 
2837
        rows_per_strip=(uint32) image->rows;
2830
2838
        (void) TIFFSetField(tiff,TIFFTAG_GROUP3OPTIONS,4);
2831
2839
        break;
2832
2840
      }
2833
2841
      case COMPRESSION_CCITTFAX4:
2834
2842
      {
2835
 
        rows_per_strip=image->rows;
 
2843
        rows_per_strip=(uint32) image->rows;
2836
2844
        break;
2837
2845
      }
2838
2846
      case COMPRESSION_LZW:
2911
2919
        pages;
2912
2920
 
2913
2921
      page=(uint16) scene;
2914
 
      pages=GetImageListLength(image);
 
2922
      pages=(uint16) GetImageListLength(image);
2915
2923
      if ((image_info->adjoin != MagickFalse) && (pages > 1))
2916
2924
        (void) TIFFSetField(tiff,TIFFTAG_SUBFILETYPE,FILETYPE_PAGE);
2917
2925
      (void) TIFFSetField(tiff,TIFFTAG_PAGENUMBER,page,pages);
2943
2951
            quantum_type=RGBQuantum;
2944
2952
            if (image->matte != MagickFalse)
2945
2953
              quantum_type=RGBAQuantum;
2946
 
            for (y=0; y < (long) image->rows; y++)
 
2954
            for (y=0; y < (ssize_t) image->rows; y++)
2947
2955
            {
2948
2956
              register const PixelPacket
2949
 
                *__restrict p;
 
2957
                *restrict p;
2950
2958
 
2951
2959
              p=GetVirtualPixels(image,0,y,image->columns,1,
2952
2960
                &image->exception);
2958
2966
                break;
2959
2967
              if (image->previous == (Image *) NULL)
2960
2968
                {
2961
 
                  status=SetImageProgress(image,SaveImageTag,y,image->rows);
 
2969
                  status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
 
2970
                image->rows);
2962
2971
                  if (status == MagickFalse)
2963
2972
                    break;
2964
2973
                }
2971
2980
            /*
2972
2981
              Plane interlacing:  RRRRRR...GGGGGG...BBBBBB...
2973
2982
            */
2974
 
            for (y=0; y < (long) image->rows; y++)
 
2983
            for (y=0; y < (ssize_t) image->rows; y++)
2975
2984
            {
2976
2985
              register const PixelPacket
2977
 
                *__restrict p;
 
2986
                *restrict p;
2978
2987
 
2979
2988
              p=GetVirtualPixels(image,0,y,image->columns,1,
2980
2989
                &image->exception);
2991
3000
                if (status == MagickFalse)
2992
3001
                  break;
2993
3002
              }
2994
 
            for (y=0; y < (long) image->rows; y++)
 
3003
            for (y=0; y < (ssize_t) image->rows; y++)
2995
3004
            {
2996
3005
              register const PixelPacket
2997
 
                *__restrict p;
 
3006
                *restrict p;
2998
3007
 
2999
3008
              p=GetVirtualPixels(image,0,y,image->columns,1,
3000
3009
                &image->exception);
3011
3020
                if (status == MagickFalse)
3012
3021
                  break;
3013
3022
              }
3014
 
            for (y=0; y < (long) image->rows; y++)
 
3023
            for (y=0; y < (ssize_t) image->rows; y++)
3015
3024
            {
3016
3025
              register const PixelPacket
3017
 
                *__restrict p;
 
3026
                *restrict p;
3018
3027
 
3019
3028
              p=GetVirtualPixels(image,0,y,image->columns,1,
3020
3029
                &image->exception);
3032
3041
                  break;
3033
3042
              }
3034
3043
            if (image->matte != MagickFalse)
3035
 
              for (y=0; y < (long) image->rows; y++)
 
3044
              for (y=0; y < (ssize_t) image->rows; y++)
3036
3045
              {
3037
3046
                register const PixelPacket
3038
 
                  *__restrict p;
 
3047
                  *restrict p;
3039
3048
 
3040
3049
                p=GetVirtualPixels(image,0,y,image->columns,1,
3041
3050
                  &image->exception);
3067
3076
          quantum_type=CMYKAQuantum;
3068
3077
        if (image->colorspace != CMYKColorspace)
3069
3078
          (void) TransformImageColorspace(image,CMYKColorspace);
3070
 
        for (y=0; y < (long) image->rows; y++)
 
3079
        for (y=0; y < (ssize_t) image->rows; y++)
3071
3080
        {
3072
3081
          register const PixelPacket
3073
 
            *__restrict p;
 
3082
            *restrict p;
3074
3083
 
3075
3084
          p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
3076
3085
          if (p == (const PixelPacket *) NULL)
3081
3090
            break;
3082
3091
          if (image->previous == (Image *) NULL)
3083
3092
            {
3084
 
              status=SetImageProgress(image,SaveImageTag,y,image->rows);
 
3093
              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
 
3094
                image->rows);
3085
3095
              if (status == MagickFalse)
3086
3096
                break;
3087
3097
            }
3110
3120
        (void) ResetMagickMemory(red,0,65536*sizeof(*red));
3111
3121
        (void) ResetMagickMemory(green,0,65536*sizeof(*green));
3112
3122
        (void) ResetMagickMemory(blue,0,65536*sizeof(*blue));
3113
 
        for (i=0; i < (long) image->colors; i++)
 
3123
        for (i=0; i < (ssize_t) image->colors; i++)
3114
3124
        {
3115
3125
          red[i]=ScaleQuantumToShort(image->colormap[i].red);
3116
3126
          green[i]=ScaleQuantumToShort(image->colormap[i].green);
3137
3147
         else
3138
3148
           if (photometric != PHOTOMETRIC_PALETTE)
3139
3149
             quantum_type=GrayQuantum;
3140
 
        for (y=0; y < (long) image->rows; y++)
 
3150
        for (y=0; y < (ssize_t) image->rows; y++)
3141
3151
        {
3142
3152
          register const PixelPacket
3143
 
            *__restrict p;
 
3153
            *restrict p;
3144
3154
 
3145
3155
          p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
3146
3156
          if (p == (const PixelPacket *) NULL)
3151
3161
            break;
3152
3162
          if (image->previous == (Image *) NULL)
3153
3163
            {
3154
 
              status=SetImageProgress(image,SaveImageTag,y,image->rows);
 
3164
              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
 
3165
                image->rows);
3155
3166
              if (status == MagickFalse)
3156
3167
                break;
3157
3168
            }