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

« back to all changes in this revision

Viewing changes to magick/cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-06-15 11:05:28 UTC
  • mfrom: (6.2.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110615110528-08jgo07a4846xh8d
Tags: 8:6.6.0.4-3ubuntu1
* Resynchronise with Debian (LP: #797595).  Remaining changes:
  - Make ufraw-batch (universe) a suggestion instead of a recommendation.
  - Make debian/rules install target depend on check; they cannot reliably
    be run in parallel.
  - Don't set MAKEFLAGS in debian/rules; just pass it to the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
*/
74
74
typedef struct _MagickModulo
75
75
{
76
 
  ssize_t
 
76
  long
77
77
    quotient,
78
78
    remainder;
79
79
} MagickModulo;
96
96
  IndexPacket
97
97
    *indexes;
98
98
 
99
 
  size_t
 
99
  unsigned long
100
100
    signature;
101
101
};
102
102
 
111
111
  *GetVirtualIndexesFromCache(const Image *);
112
112
 
113
113
static const PixelPacket
114
 
  *GetVirtualPixelCache(const Image *,const VirtualPixelMethod,const ssize_t,
115
 
    const ssize_t,const size_t,const size_t,ExceptionInfo *),
 
114
  *GetVirtualPixelCache(const Image *,const VirtualPixelMethod,const long,
 
115
    const long,const unsigned long,const unsigned long,ExceptionInfo *),
116
116
  *GetVirtualPixelsCache(const Image *);
117
117
 
118
118
static MagickBooleanType
119
 
  GetOneAuthenticPixelFromCache(Image *,const ssize_t,const ssize_t,PixelPacket *,
 
119
  GetOneAuthenticPixelFromCache(Image *,const long,const long,PixelPacket *,
120
120
    ExceptionInfo *),
121
121
  GetOneVirtualPixelFromCache(const Image *,const VirtualPixelMethod,
122
 
    const ssize_t,const ssize_t,PixelPacket *,ExceptionInfo *),
 
122
    const long,const long,PixelPacket *,ExceptionInfo *),
123
123
  OpenPixelCache(Image *,const MapMode,ExceptionInfo *),
124
124
  ReadPixelCacheIndexes(CacheInfo *,NexusInfo *,ExceptionInfo *),
125
125
  ReadPixelCachePixels(CacheInfo *,NexusInfo *,ExceptionInfo *),
128
128
  WritePixelCachePixels(CacheInfo *,NexusInfo *,ExceptionInfo *);
129
129
 
130
130
static PixelPacket
131
 
  *GetAuthenticPixelsCache(Image *,const ssize_t,const ssize_t,const size_t,
132
 
    const size_t,ExceptionInfo *),
133
 
  *QueueAuthenticPixelsCache(Image *,const ssize_t,const ssize_t,const size_t,
134
 
    const size_t,ExceptionInfo *),
 
131
  *GetAuthenticPixelsCache(Image *,const long,const long,const unsigned long,
 
132
    const unsigned long,ExceptionInfo *),
 
133
  *QueueAuthenticPixelsCache(Image *,const long,const long,const unsigned long,
 
134
    const unsigned long,ExceptionInfo *),
135
135
  *SetPixelCacheNexusPixels(const Image *,const RectangleInfo *,NexusInfo *,
136
136
    ExceptionInfo *);
137
137
 
166
166
%
167
167
%  The format of the AcquirePixelCache() method is:
168
168
%
169
 
%      Cache AcquirePixelCache(const size_t number_threads)
 
169
%      Cache AcquirePixelCache(const unsigned long number_threads)
170
170
%
171
171
%  A description of each parameter follows:
172
172
%
173
173
%    o number_threads: the number of nexus threads.
174
174
%
175
175
*/
176
 
MagickExport Cache AcquirePixelCache(const size_t number_threads)
 
176
MagickExport Cache AcquirePixelCache(const unsigned long number_threads)
177
177
{
178
178
  CacheInfo
179
179
    *cache_info;
233
233
%
234
234
%  The format of the AcquirePixelCacheNexus method is:
235
235
%
236
 
%      NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
 
236
%      NexusInfo **AcquirePixelCacheNexus(const unsigned long number_threads)
237
237
%
238
238
%  A description of each parameter follows:
239
239
%
241
241
%
242
242
*/
243
243
MagickExport NexusInfo **AcquirePixelCacheNexus(
244
 
  const size_t number_threads)
 
244
  const unsigned long number_threads)
245
245
{
246
 
  register ssize_t
 
246
  register long
247
247
    i;
248
248
 
249
249
  NexusInfo
253
253
    sizeof(*nexus_info));
254
254
  if (nexus_info == (NexusInfo **) NULL)
255
255
    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
256
 
  for (i=0; i < (ssize_t) number_threads; i++)
 
256
  for (i=0; i < (long) number_threads; i++)
257
257
  {
258
258
    nexus_info[i]=(NexusInfo *) AcquireAlignedMemory(1,sizeof(**nexus_info));
259
259
    if (nexus_info[i] == (NexusInfo *) NULL)
417
417
    *restrict nexus_indexes,
418
418
    *restrict indexes;
419
419
 
420
 
  register ssize_t
 
420
  register long
421
421
    i;
422
422
 
423
423
  register PixelPacket
450
450
    nexus_info->region.height,clip_nexus[0],exception);
451
451
  number_pixels=(MagickSizeType) nexus_info->region.width*
452
452
    nexus_info->region.height;
453
 
  for (i=0; i < (ssize_t) number_pixels; i++)
 
453
  for (i=0; i < (long) number_pixels; i++)
454
454
  {
455
455
    if ((p == (PixelPacket *) NULL) || (r == (const PixelPacket *) NULL))
456
456
      break;
469
469
  }
470
470
  clip_nexus=DestroyPixelCacheNexus(clip_nexus,1);
471
471
  image_nexus=DestroyPixelCacheNexus(image_nexus,1);
472
 
  if (i < (ssize_t) number_pixels)
 
472
  if (i < (long) number_pixels)
473
473
    return(MagickFalse);
474
474
  return(MagickTrue);
475
475
}
579
579
  MagickSizeType
580
580
    number_pixels;
581
581
 
582
 
  register ssize_t
 
582
  register long
583
583
    i;
584
584
 
585
585
  register const NexusInfo
589
589
    *q;
590
590
 
591
591
  status=MagickTrue;
592
 
  for (i=0; i < (ssize_t) source->number_threads; i++)
 
592
  for (i=0; i < (long) source->number_threads; i++)
593
593
  {
594
594
    p=source->nexus_info[i];
595
595
    q=destination->nexus_info[i];
873
873
  MagickSizeType
874
874
    length;
875
875
 
876
 
  register ssize_t
 
876
  register long
877
877
    y;
878
878
 
879
879
  register PixelPacket
880
880
    *restrict pixels;
881
881
 
882
 
  size_t
 
882
  unsigned long
883
883
    columns,
884
884
    rows;
885
885
 
897
897
        cache_info->cache_filename);
898
898
      return(MagickFalse);
899
899
    }
900
 
  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
901
 
  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
 
900
  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
 
901
  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
902
902
  if ((clone_info->active_index_channel != MagickFalse) &&
903
903
      (cache_info->active_index_channel != MagickFalse))
904
904
    {
923
923
        sizeof(*pixels)+cache_info->columns*rows*sizeof(*indexes);
924
924
      offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
925
925
        sizeof(*pixels)+clone_info->columns*rows*sizeof(*indexes);
926
 
      for (y=0; y < (ssize_t) rows; y++)
 
926
      for (y=0; y < (long) rows; y++)
927
927
      {
928
928
        source_offset-=cache_info->columns*sizeof(*indexes);
929
929
        count=ReadPixelCacheRegion(cache_info,cache_info->offset+source_offset,
936
936
        if ((MagickSizeType) count != length)
937
937
          break;
938
938
      }
939
 
      if (y < (ssize_t) rows)
 
939
      if (y < (long) rows)
940
940
        {
941
941
          indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
942
942
          ThrowFileException(exception,CacheError,"UnableToCloneCache",
949
949
          (void) ResetMagickMemory(indexes,0,(size_t) length);
950
950
          offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
951
951
            sizeof(*pixels)+(clone_info->columns*rows+columns)*sizeof(*indexes);
952
 
          for (y=0; y < (ssize_t) rows; y++)
 
952
          for (y=0; y < (long) rows; y++)
953
953
          {
954
954
            offset-=clone_info->columns*sizeof(*indexes);
955
955
            count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,
957
957
            if ((MagickSizeType) count != length)
958
958
              break;
959
959
          }
960
 
          if (y < (ssize_t) rows)
 
960
          if (y < (long) rows)
961
961
            {
962
962
              indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
963
963
              ThrowFileException(exception,CacheError,"UnableToCloneCache",
982
982
  length=columns*sizeof(*pixels);
983
983
  source_offset=(MagickOffsetType) cache_info->columns*rows*sizeof(*pixels);
984
984
  offset=(MagickOffsetType) clone_info->columns*rows*sizeof(*pixels);
985
 
  for (y=0; y < (ssize_t) rows; y++)
 
985
  for (y=0; y < (long) rows; y++)
986
986
  {
987
987
    source_offset-=cache_info->columns*sizeof(*pixels);
988
988
    count=ReadPixelCacheRegion(cache_info,cache_info->offset+source_offset,
995
995
    if ((MagickSizeType) count != length)
996
996
      break;
997
997
  }
998
 
  if (y < (ssize_t) rows)
 
998
  if (y < (long) rows)
999
999
    {
1000
1000
      pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
1001
1001
      ThrowFileException(exception,CacheError,"UnableToCloneCache",
1008
1008
        sizeof(*pixels);
1009
1009
      length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
1010
1010
      (void) ResetMagickMemory(pixels,0,(size_t) length);
1011
 
      for (y=0; y < (ssize_t) rows; y++)
 
1011
      for (y=0; y < (long) rows; y++)
1012
1012
      {
1013
1013
        offset-=clone_info->columns*sizeof(*pixels);
1014
1014
        count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,length,
1016
1016
        if ((MagickSizeType) count != length)
1017
1017
          break;
1018
1018
      }
1019
 
      if (y < (ssize_t) rows)
 
1019
      if (y < (long) rows)
1020
1020
        {
1021
1021
          pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
1022
1022
          ThrowFileException(exception,CacheError,"UnableToCloneCache",
1038
1038
  MagickSizeType
1039
1039
    length;
1040
1040
 
1041
 
  register ssize_t
 
1041
  register long
1042
1042
    y;
1043
1043
 
1044
1044
  register PixelPacket
1045
1045
    *restrict pixels,
1046
1046
    *restrict q;
1047
1047
 
1048
 
  size_t
 
1048
  unsigned long
1049
1049
    columns,
1050
1050
    rows;
1051
1051
 
1057
1057
        cache_info->cache_filename);
1058
1058
      return(MagickFalse);
1059
1059
    }
1060
 
  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
1061
 
  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
 
1060
  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
 
1061
  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
1062
1062
  if ((clone_info->active_index_channel != MagickFalse) &&
1063
1063
      (cache_info->active_index_channel != MagickFalse))
1064
1064
    {
1083
1083
      offset=(MagickOffsetType) cache_info->columns*cache_info->rows*
1084
1084
        sizeof(*pixels)+cache_info->columns*rows*sizeof(*indexes);
1085
1085
      q=clone_info->indexes+clone_info->columns*rows;
1086
 
      for (y=0; y < (ssize_t) rows; y++)
 
1086
      for (y=0; y < (long) rows; y++)
1087
1087
      {
1088
1088
        offset-=cache_info->columns*sizeof(IndexPacket);
1089
1089
        count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset,
1095
1095
        if ((MagickSizeType) count != length)
1096
1096
          break;
1097
1097
      }
1098
 
      if (y < (ssize_t) rows)
 
1098
      if (y < (long) rows)
1099
1099
        {
1100
1100
          indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
1101
1101
          ThrowFileException(exception,CacheError,"UnableToCloneCache",
1119
1119
  length=columns*sizeof(*pixels);
1120
1120
  offset=(MagickOffsetType) cache_info->columns*rows*sizeof(*pixels);
1121
1121
  q=clone_info->pixels+clone_info->columns*rows;
1122
 
  for (y=0; y < (ssize_t) rows; y++)
 
1122
  for (y=0; y < (long) rows; y++)
1123
1123
  {
1124
1124
    offset-=cache_info->columns*sizeof(*pixels);
1125
1125
    count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset,length,
1129
1129
    q-=clone_info->columns;
1130
1130
    (void) CopyMagickMemory(q,pixels,(size_t) length);
1131
1131
  }
1132
 
  if (y < (ssize_t) rows)
 
1132
  if (y < (long) rows)
1133
1133
    {
1134
1134
      pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
1135
1135
      ThrowFileException(exception,CacheError,"UnableToCloneCache",
1150
1150
  MagickSizeType
1151
1151
    length;
1152
1152
 
1153
 
  register ssize_t
 
1153
  register long
1154
1154
    y;
1155
1155
 
1156
1156
  register PixelPacket
1157
1157
    *restrict p,
1158
1158
    *restrict pixels;
1159
1159
 
1160
 
  size_t
 
1160
  unsigned long
1161
1161
    columns,
1162
1162
    rows;
1163
1163
 
1169
1169
        clone_info->cache_filename);
1170
1170
      return(MagickFalse);
1171
1171
    }
1172
 
  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
1173
 
  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
 
1172
  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
 
1173
  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
1174
1174
  if ((clone_info->active_index_channel != MagickFalse) &&
1175
1175
      (cache_info->active_index_channel != MagickFalse))
1176
1176
    {
1195
1195
      p=cache_info->indexes+cache_info->columns*rows;
1196
1196
      offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
1197
1197
        sizeof(*pixels)+clone_info->columns*rows*sizeof(*indexes);
1198
 
      for (y=0; y < (ssize_t) rows; y++)
 
1198
      for (y=0; y < (long) rows; y++)
1199
1199
      {
1200
1200
        p-=cache_info->columns;
1201
1201
        (void) CopyMagickMemory(indexes,p,(size_t) length);
1205
1205
        if ((MagickSizeType) count != length)
1206
1206
          break;
1207
1207
      }
1208
 
      if (y < (ssize_t) rows)
 
1208
      if (y < (long) rows)
1209
1209
        {
1210
1210
          indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
1211
1211
          ThrowFileException(exception,CacheError,"UnableToCloneCache",
1218
1218
          (void) ResetMagickMemory(indexes,0,(size_t) length);
1219
1219
          offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
1220
1220
            sizeof(*pixels)+(clone_info->columns*rows+columns)*sizeof(*indexes);
1221
 
          for (y=0; y < (ssize_t) rows; y++)
 
1221
          for (y=0; y < (long) rows; y++)
1222
1222
          {
1223
1223
            offset-=clone_info->columns*sizeof(*indexes);
1224
1224
            count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,
1226
1226
            if ((MagickSizeType) count != length)
1227
1227
              break;
1228
1228
          }
1229
 
          if (y < (ssize_t) rows)
 
1229
          if (y < (long) rows)
1230
1230
            {
1231
1231
              indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
1232
1232
              ThrowFileException(exception,CacheError,"UnableToCloneCache",
1251
1251
  length=columns*sizeof(*pixels);
1252
1252
  p=cache_info->pixels+cache_info->columns*rows;
1253
1253
  offset=(MagickOffsetType) clone_info->columns*rows*sizeof(*pixels);
1254
 
  for (y=0; y < (ssize_t) rows; y++)
 
1254
  for (y=0; y < (long) rows; y++)
1255
1255
  {
1256
1256
    p-=cache_info->columns;
1257
1257
    (void) CopyMagickMemory(pixels,p,(size_t) length);
1261
1261
    if ((MagickSizeType) count != length)
1262
1262
      break;
1263
1263
  }
1264
 
  if (y < (ssize_t) rows)
 
1264
  if (y < (long) rows)
1265
1265
    {
1266
1266
      pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
1267
1267
      ThrowFileException(exception,CacheError,"UnableToCloneCache",
1274
1274
        sizeof(*pixels);
1275
1275
      length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
1276
1276
      (void) ResetMagickMemory(pixels,0,(size_t) length);
1277
 
      for (y=0; y < (ssize_t) rows; y++)
 
1277
      for (y=0; y < (long) rows; y++)
1278
1278
      {
1279
1279
        offset-=clone_info->columns*sizeof(*pixels);
1280
1280
        count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,length,
1282
1282
        if ((MagickSizeType) count != length)
1283
1283
          break;
1284
1284
      }
1285
 
      if (y < (ssize_t) rows)
 
1285
      if (y < (long) rows)
1286
1286
        {
1287
1287
          pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
1288
1288
          ThrowFileException(exception,CacheError,"UnableToCloneCache",
1297
1297
static MagickBooleanType CloneMemoryToMemoryPixelCache(CacheInfo *clone_info,
1298
1298
  CacheInfo *cache_info,ExceptionInfo *magick_unused(exception))
1299
1299
{
1300
 
  register ssize_t
 
1300
  register long
1301
1301
    y;
1302
1302
 
1303
1303
  register PixelPacket
1307
1307
  size_t
1308
1308
    length;
1309
1309
 
1310
 
  size_t
 
1310
  unsigned long
1311
1311
    columns,
1312
1312
    rows;
1313
1313
 
1314
1314
  if (cache_info->debug != MagickFalse)
1315
1315
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),"memory => memory");
1316
 
  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
1317
 
  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
 
1316
  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
 
1317
  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
1318
1318
  if ((clone_info->active_index_channel != MagickFalse) &&
1319
1319
      (cache_info->active_index_channel != MagickFalse))
1320
1320
    {
1333
1333
        {
1334
1334
          source_indexes=cache_info->indexes+cache_info->columns*rows;
1335
1335
          indexes=clone_info->indexes+clone_info->columns*rows;
1336
 
          for (y=0; y < (ssize_t) rows; y++)
 
1336
          for (y=0; y < (long) rows; y++)
1337
1337
          {
1338
1338
            source_indexes-=cache_info->columns;
1339
1339
            indexes-=clone_info->columns;
1345
1345
                sizeof(*indexes);
1346
1346
              indexes=clone_info->indexes+clone_info->columns*rows+
1347
1347
                cache_info->columns;
1348
 
              for (y=0; y < (ssize_t) rows; y++)
 
1348
              for (y=0; y < (long) rows; y++)
1349
1349
              {
1350
1350
                indexes-=clone_info->columns;
1351
1351
                (void) ResetMagickMemory(indexes,0,length);
1363
1363
    {
1364
1364
      source_pixels=cache_info->pixels+cache_info->columns*rows;
1365
1365
      pixels=clone_info->pixels+clone_info->columns*rows;
1366
 
      for (y=0; y < (ssize_t) rows; y++)
 
1366
      for (y=0; y < (long) rows; y++)
1367
1367
      {
1368
1368
        source_pixels-=cache_info->columns;
1369
1369
        pixels-=clone_info->columns;
1374
1374
          length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
1375
1375
          pixels=clone_info->pixels+clone_info->columns*rows+
1376
1376
            cache_info->columns;
1377
 
          for (y=0; y < (ssize_t) rows; y++)
 
1377
          for (y=0; y < (long) rows; y++)
1378
1378
          {
1379
1379
            pixels-=clone_info->columns;
1380
1380
            (void) ResetMagickMemory(pixels,0,length);
1640
1640
%  The format of the DestroyPixelCacheNexus() method is:
1641
1641
%
1642
1642
%      NexusInfo **DestroyPixelCacheNexus(NexusInfo *nexus_info,
1643
 
%        const size_t number_threads)
 
1643
%        const unsigned long number_threads)
1644
1644
%
1645
1645
%  A description of each parameter follows:
1646
1646
%
1664
1664
}
1665
1665
 
1666
1666
MagickExport NexusInfo **DestroyPixelCacheNexus(NexusInfo **nexus_info,
1667
 
  const size_t number_threads)
 
1667
  const unsigned long number_threads)
1668
1668
{
1669
 
  register ssize_t
 
1669
  register long
1670
1670
    i;
1671
1671
 
1672
1672
  assert(nexus_info != (NexusInfo **) NULL);
1673
 
  for (i=0; i < (ssize_t) number_threads; i++)
 
1673
  for (i=0; i < (long) number_threads; i++)
1674
1674
  {
1675
1675
    if (nexus_info[i]->cache != (PixelPacket *) NULL)
1676
1676
      RelinquishCacheNexusPixels(nexus_info[i]);
1712
1712
  IndexPacket
1713
1713
    *indexes;
1714
1714
 
1715
 
  ssize_t
 
1715
  long
1716
1716
    id;
1717
1717
 
1718
1718
  if (image->debug != MagickFalse)
1719
1719
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1720
1720
  cache_info=(CacheInfo *) image->cache;
1721
1721
  id=GetOpenMPThreadId();
1722
 
  assert(id < (ssize_t) cache_info->number_threads);
 
1722
  assert(id < (long) cache_info->number_threads);
1723
1723
  indexes=GetPixelCacheNexusIndexes(image->cache,cache_info->nexus_info[id]);
1724
1724
  return(indexes);
1725
1725
}
1785
1785
%
1786
1786
%  The format of the GetAuthenticPixelCacheNexus() method is:
1787
1787
%
1788
 
%      PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const ssize_t x,
1789
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
1788
%      PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const long x,
 
1789
%        const long y,const unsigned long columns,const unsigned long rows,
1790
1790
%        NexusInfo *nexus_info,ExceptionInfo *exception)
1791
1791
%
1792
1792
%  A description of each parameter follows:
1808
1808
  MagickOffsetType
1809
1809
    offset;
1810
1810
 
1811
 
  if (cache_info->type == PingCache)
1812
 
    return(MagickTrue);
1813
1811
  offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
1814
1812
    nexus_info->region.x;
1815
1813
  if (nexus_info->pixels != (cache_info->pixels+offset))
1817
1815
  return(MagickTrue);
1818
1816
}
1819
1817
 
1820
 
MagickExport PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const ssize_t x,
1821
 
  const ssize_t y,const size_t columns,const size_t rows,
 
1818
MagickExport PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const long x,
 
1819
  const long y,const unsigned long columns,const unsigned long rows,
1822
1820
  NexusInfo *nexus_info,ExceptionInfo *exception)
1823
1821
{
1824
1822
  CacheInfo
1877
1875
  CacheInfo
1878
1876
    *cache_info;
1879
1877
 
1880
 
  ssize_t
 
1878
  long
1881
1879
    id;
1882
1880
 
1883
1881
  PixelPacket
1887
1885
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1888
1886
  cache_info=(CacheInfo *) image->cache;
1889
1887
  id=GetOpenMPThreadId();
1890
 
  assert(id < (ssize_t) cache_info->number_threads);
 
1888
  assert(id < (long) cache_info->number_threads);
1891
1889
  pixels=GetPixelCacheNexusPixels(image->cache,cache_info->nexus_info[id]);
1892
1890
  return(pixels);
1893
1891
}
1965
1963
%
1966
1964
%  The format of the GetAuthenticPixels() method is:
1967
1965
%
1968
 
%      PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,
1969
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
1966
%      PixelPacket *GetAuthenticPixels(Image *image,const long x,const long y,
 
1967
%        const unsigned long columns,const unsigned long rows,
1970
1968
%        ExceptionInfo *exception)
1971
1969
%
1972
1970
%  A description of each parameter follows:
1979
1977
%    o exception: return any errors or warnings in this structure.
1980
1978
%
1981
1979
*/
1982
 
MagickExport PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,
1983
 
  const ssize_t y,const size_t columns,const size_t rows,
 
1980
MagickExport PixelPacket *GetAuthenticPixels(Image *image,const long x,
 
1981
  const long y,const unsigned long columns,const unsigned long rows,
1984
1982
  ExceptionInfo *exception)
1985
1983
{
1986
1984
  CacheInfo
2021
2019
%
2022
2020
%  The format of the GetAuthenticPixelsCache() method is:
2023
2021
%
2024
 
%      PixelPacket *GetAuthenticPixelsCache(Image *image,const ssize_t x,
2025
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
2022
%      PixelPacket *GetAuthenticPixelsCache(Image *image,const long x,
 
2023
%        const long y,const unsigned long columns,const unsigned long rows,
2026
2024
%        ExceptionInfo *exception)
2027
2025
%
2028
2026
%  A description of each parameter follows:
2035
2033
%    o exception: return any errors or warnings in this structure.
2036
2034
%
2037
2035
*/
2038
 
static PixelPacket *GetAuthenticPixelsCache(Image *image,const ssize_t x,
2039
 
  const ssize_t y,const size_t columns,const size_t rows,
 
2036
static PixelPacket *GetAuthenticPixelsCache(Image *image,const long x,
 
2037
  const long y,const unsigned long columns,const unsigned long rows,
2040
2038
  ExceptionInfo *exception)
2041
2039
{
2042
2040
  CacheInfo
2043
2041
    *cache_info;
2044
2042
 
2045
 
  ssize_t
 
2043
  long
2046
2044
    id;
2047
2045
 
2048
2046
  PixelPacket
2052
2050
  if (cache_info == (Cache) NULL)
2053
2051
    return((PixelPacket *) NULL);
2054
2052
  id=GetOpenMPThreadId();
2055
 
  assert(id < (ssize_t) cache_info->number_threads);
 
2053
  assert(id < (long) cache_info->number_threads);
2056
2054
  pixels=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
2057
2055
    cache_info->nexus_info[id],exception);
2058
2056
  return(pixels);
2086
2084
  CacheInfo
2087
2085
    *cache_info;
2088
2086
 
2089
 
  ssize_t
 
2087
  long
2090
2088
    id;
2091
2089
 
2092
2090
  MagickSizeType
2100
2098
  cache_info=(CacheInfo *) image->cache;
2101
2099
  assert(cache_info->signature == MagickSignature);
2102
2100
  id=GetOpenMPThreadId();
2103
 
  assert(id < (ssize_t) cache_info->number_threads);
 
2101
  assert(id < (long) cache_info->number_threads);
2104
2102
  extent=GetPixelCacheNexusExtent(image->cache,cache_info->nexus_info[id]);
2105
2103
  return(extent);
2106
2104
}
2258
2256
%
2259
2257
%  The format of the GetOneAuthenticPixel() method is:
2260
2258
%
2261
 
%      MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
2262
 
%        const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 
2259
%      MagickBooleanType GetOneAuthenticPixel(const Image image,const long x,
 
2260
%        const long y,PixelPacket *pixel,ExceptionInfo *exception)
2263
2261
%
2264
2262
%  A description of each parameter follows:
2265
2263
%
2272
2270
%    o exception: return any errors or warnings in this structure.
2273
2271
%
2274
2272
*/
2275
 
MagickExport MagickBooleanType GetOneAuthenticPixel(Image *image,const ssize_t x,
2276
 
  const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 
2273
MagickExport MagickBooleanType GetOneAuthenticPixel(Image *image,const long x,
 
2274
  const long y,PixelPacket *pixel,ExceptionInfo *exception)
2277
2275
{
2278
2276
  CacheInfo
2279
2277
    *cache_info;
2319
2317
%  The format of the GetOneAuthenticPixelFromCache() method is:
2320
2318
%
2321
2319
%      MagickBooleanType GetOneAuthenticPixelFromCache(const Image image,
2322
 
%        const ssize_t x,const ssize_t y,PixelPacket *pixel,
2323
 
%        ExceptionInfo *exception)
 
2320
%        const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
2324
2321
%
2325
2322
%  A description of each parameter follows:
2326
2323
%
2334
2331
%
2335
2332
*/
2336
2333
static MagickBooleanType GetOneAuthenticPixelFromCache(Image *image,
2337
 
  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 
2334
  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
2338
2335
{
2339
2336
  PixelPacket
2340
2337
    *pixels;
2367
2364
%  The format of the GetOneVirtualMagickPixel() method is:
2368
2365
%
2369
2366
%      MagickBooleanType GetOneVirtualMagickPixel(const Image image,
2370
 
%        const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,
 
2367
%        const long x,const long y,MagickPixelPacket *pixel,
2371
2368
%        ExceptionInfo exception)
2372
2369
%
2373
2370
%  A description of each parameter follows:
2382
2379
%
2383
2380
*/
2384
2381
MagickExport MagickBooleanType GetOneVirtualMagickPixel(const Image *image,
2385
 
  const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,ExceptionInfo *exception)
 
2382
  const long x,const long y,MagickPixelPacket *pixel,ExceptionInfo *exception)
2386
2383
{
2387
2384
  CacheInfo
2388
2385
    *cache_info;
2427
2424
%  The format of the GetOneVirtualMethodPixel() method is:
2428
2425
%
2429
2426
%      MagickBooleanType GetOneVirtualMethodPixel(const Image image,
2430
 
%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
2431
 
%        const ssize_t y,Pixelpacket *pixel,ExceptionInfo exception)
 
2427
%        const VirtualPixelMethod virtual_pixel_method,const long x,
 
2428
%        const long y,Pixelpacket *pixel,ExceptionInfo exception)
2432
2429
%
2433
2430
%  A description of each parameter follows:
2434
2431
%
2444
2441
%
2445
2442
*/
2446
2443
MagickExport MagickBooleanType GetOneVirtualMethodPixel(const Image *image,
2447
 
  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
 
2444
  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
2448
2445
  PixelPacket *pixel,ExceptionInfo *exception)
2449
2446
{
2450
2447
  GetOneVirtualPixelFromHandler
2489
2486
%
2490
2487
%  The format of the GetOneVirtualPixel() method is:
2491
2488
%
2492
 
%      MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
2493
 
%        const ssize_t y,PixelPacket *pixel,ExceptionInfo exception)
 
2489
%      MagickBooleanType GetOneVirtualPixel(const Image image,const long x,
 
2490
%        const long y,PixelPacket *pixel,ExceptionInfo exception)
2494
2491
%
2495
2492
%  A description of each parameter follows:
2496
2493
%
2504
2501
%
2505
2502
*/
2506
2503
MagickExport MagickBooleanType GetOneVirtualPixel(const Image *image,
2507
 
  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 
2504
  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
2508
2505
{
2509
2506
  GetOneVirtualPixelFromHandler
2510
2507
    get_one_virtual_pixel_from_handler;
2549
2546
%  The format of the GetOneVirtualPixelFromCache() method is:
2550
2547
%
2551
2548
%      MagickBooleanType GetOneVirtualPixelFromCache(const Image image,
2552
 
%        const VirtualPixelPacket method,const ssize_t x,const ssize_t y,
 
2549
%        const VirtualPixelPacket method,const long x,const long y,
2553
2550
%        PixelPacket *pixel,ExceptionInfo *exception)
2554
2551
%
2555
2552
%  A description of each parameter follows:
2566
2563
%
2567
2564
*/
2568
2565
static MagickBooleanType GetOneVirtualPixelFromCache(const Image *image,
2569
 
  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
 
2566
  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
2570
2567
  PixelPacket *pixel,ExceptionInfo *exception)
2571
2568
{
2572
2569
  const PixelPacket
2885
2882
%
2886
2883
%  The format of the GetPixelCacheTileSize() method is:
2887
2884
%
2888
 
%      void GetPixelCacheTileSize(const Image *image,size_t *width,
2889
 
%        size_t *height)
 
2885
%      void GetPixelCacheTileSize(const Image *image,unsigned long *width,
 
2886
%        unsigned long *height)
2890
2887
%
2891
2888
%  A description of each parameter follows:
2892
2889
%
2897
2894
%    o height: the optimize cache tile height in pixels.
2898
2895
%
2899
2896
*/
2900
 
MagickExport void GetPixelCacheTileSize(const Image *image,size_t *width,
2901
 
  size_t *height)
 
2897
MagickExport void GetPixelCacheTileSize(const Image *image,unsigned long *width,
 
2898
  unsigned long *height)
2902
2899
{
2903
2900
  CacheInfo
2904
2901
    *cache_info;
3023
3020
  const IndexPacket
3024
3021
    *indexes;
3025
3022
 
3026
 
  ssize_t
 
3023
  long
3027
3024
    id;
3028
3025
 
3029
3026
  if (image->debug != MagickFalse)
3030
3027
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3031
3028
  cache_info=(CacheInfo *) image->cache;
3032
3029
  id=GetOpenMPThreadId();
3033
 
  assert(id < (ssize_t) cache_info->number_threads);
 
3030
  assert(id < (long) cache_info->number_threads);
3034
3031
  indexes=GetVirtualIndexesFromNexus(image->cache,cache_info->nexus_info[id]);
3035
3032
  return(indexes);
3036
3033
}
3137
3134
%  The format of the GetVirtualPixelsFromNexus() method is:
3138
3135
%
3139
3136
%      PixelPacket *GetVirtualPixelsFromNexus(const Image *image,
3140
 
%        const VirtualPixelMethod method,const ssize_t x,const ssize_t y,
3141
 
%        const size_t columns,const size_t rows,NexusInfo *nexus_info,
3142
 
%        ExceptionInfo *exception)
 
3137
%        const VirtualPixelMethod method,const long x,const long y,
 
3138
%        const unsigned long columns,const unsigned long rows,
 
3139
%        NexusInfo *nexus_info,ExceptionInfo *exception)
3143
3140
%
3144
3141
%  A description of each parameter follows:
3145
3142
%
3156
3153
%
3157
3154
*/
3158
3155
 
3159
 
static ssize_t
 
3156
static long
3160
3157
  DitherMatrix[64] =
3161
3158
  {
3162
3159
     0,  48,  12,  60,   3,  51,  15,  63,
3169
3166
    42,  26,  38,  22,  41,  25,  37,  21
3170
3167
  };
3171
3168
 
3172
 
static inline ssize_t DitherX(const ssize_t x,const size_t columns)
 
3169
static inline long DitherX(const long x,const unsigned long columns)
3173
3170
{
3174
 
  ssize_t
 
3171
  long
3175
3172
    index;
3176
3173
 
3177
3174
  index=x+DitherMatrix[x & 0x07]-32L;
3178
3175
  if (index < 0L)
3179
3176
    return(0L);
3180
 
  if (index >= (ssize_t) columns)
3181
 
    return((ssize_t) columns-1L);
 
3177
  if (index >= (long) columns)
 
3178
    return((long) columns-1L);
3182
3179
  return(index);
3183
3180
}
3184
3181
 
3185
 
static inline ssize_t DitherY(const ssize_t y,const size_t rows)
 
3182
static inline long DitherY(const long y,const unsigned long rows)
3186
3183
{
3187
 
  ssize_t
 
3184
  long
3188
3185
    index;
3189
3186
 
3190
3187
  index=y+DitherMatrix[y & 0x07]-32L;
3191
3188
  if (index < 0L)
3192
3189
    return(0L);
3193
 
  if (index >= (ssize_t) rows)
3194
 
    return((ssize_t) rows-1L);
 
3190
  if (index >= (long) rows)
 
3191
    return((long) rows-1L);
3195
3192
  return(index);
3196
3193
}
3197
3194
 
3198
 
static inline ssize_t EdgeX(const ssize_t x,const size_t columns)
 
3195
static inline long EdgeX(const long x,const unsigned long columns)
3199
3196
{
3200
3197
  if (x < 0L)
3201
3198
    return(0L);
3202
 
  if (x >= (ssize_t) columns)
3203
 
    return((ssize_t) (columns-1));
 
3199
  if (x >= (long) columns)
 
3200
    return((long) (columns-1));
3204
3201
  return(x);
3205
3202
}
3206
3203
 
3207
 
static inline ssize_t EdgeY(const ssize_t y,const size_t rows)
 
3204
static inline long EdgeY(const long y,const unsigned long rows)
3208
3205
{
3209
3206
  if (y < 0L)
3210
3207
    return(0L);
3211
 
  if (y >= (ssize_t) rows)
3212
 
    return((ssize_t) (rows-1));
 
3208
  if (y >= (long) rows)
 
3209
    return((long) (rows-1));
3213
3210
  return(y);
3214
3211
}
3215
3212
 
3216
 
static inline ssize_t RandomX(RandomInfo *random_info,const size_t columns)
 
3213
static inline long RandomX(RandomInfo *random_info,const unsigned long columns)
3217
3214
{
3218
 
  return((ssize_t) (columns*GetPseudoRandomValue(random_info)));
 
3215
  return((long) (columns*GetPseudoRandomValue(random_info)));
3219
3216
}
3220
3217
 
3221
 
static inline ssize_t RandomY(RandomInfo *random_info,const size_t rows)
 
3218
static inline long RandomY(RandomInfo *random_info,const unsigned long rows)
3222
3219
{
3223
 
  return((ssize_t) (rows*GetPseudoRandomValue(random_info)));
 
3220
  return((long) (rows*GetPseudoRandomValue(random_info)));
3224
3221
}
3225
3222
 
3226
3223
/*
3230
3227
  essentially a ldiv() using a floored modulo division rather than the normal
3231
3228
  default truncated modulo division.
3232
3229
*/
3233
 
static inline MagickModulo VirtualPixelModulo(const ssize_t offset,
3234
 
  const size_t extent)
 
3230
static inline MagickModulo VirtualPixelModulo(const long offset,
 
3231
  const unsigned long extent)
3235
3232
{
3236
3233
  MagickModulo
3237
3234
    modulo;
3238
3235
 
3239
 
  modulo.quotient=offset/(ssize_t) extent;
 
3236
  modulo.quotient=offset/(long) extent;
3240
3237
  if (offset < 0L)
3241
3238
    modulo.quotient--;
3242
 
  modulo.remainder=offset-modulo.quotient*(ssize_t) extent;
 
3239
  modulo.remainder=offset-modulo.quotient*(long) extent;
3243
3240
  return(modulo);
3244
3241
}
3245
3242
 
3246
3243
MagickExport const PixelPacket *GetVirtualPixelsFromNexus(const Image *image,
3247
 
  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
3248
 
  const size_t columns,const size_t rows,NexusInfo *nexus_info,
 
3244
  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
 
3245
  const unsigned long columns,const unsigned long rows,NexusInfo *nexus_info,
3249
3246
  ExceptionInfo *exception)
3250
3247
{
3251
3248
  CacheInfo
3252
3249
    *cache_info;
3253
3250
 
3254
 
  IndexPacket
3255
 
    virtual_index;
3256
 
 
3257
3251
  MagickOffsetType
3258
3252
    offset;
3259
3253
 
3272
3266
    region;
3273
3267
 
3274
3268
  register const IndexPacket
3275
 
    *restrict virtual_indexes;
 
3269
    *restrict nexus_indexes;
3276
3270
 
3277
3271
  register const PixelPacket
3278
3272
    *restrict p;
3280
3274
  register IndexPacket
3281
3275
    *restrict indexes;
3282
3276
 
3283
 
  register ssize_t
 
3277
  register long
3284
3278
    u,
3285
3279
    v;
3286
3280
 
3302
3296
  pixels=SetPixelCacheNexusPixels(image,&region,nexus_info,exception);
3303
3297
  if (pixels == (PixelPacket *) NULL)
3304
3298
    return((const PixelPacket *) NULL);
3305
 
  offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
3306
 
    nexus_info->region.x;
3307
 
  length=(MagickSizeType) (nexus_info->region.height-1L)*cache_info->columns+
3308
 
    nexus_info->region.width-1L;
 
3299
  offset=(MagickOffsetType) region.y*cache_info->columns+region.x;
 
3300
  length=(MagickSizeType) (region.height-1L)*cache_info->columns+
 
3301
    region.width-1L;
3309
3302
  number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
3310
3303
  if ((offset >= 0) && (((MagickSizeType) offset+length) < number_pixels))
3311
 
    if ((x >= 0) && ((ssize_t) (x+columns) <= (ssize_t) cache_info->columns) &&
3312
 
        (y >= 0) && ((ssize_t) (y+rows) <= (ssize_t) cache_info->rows))
 
3304
    if ((x >= 0) && ((long) (x+columns) <= (long) cache_info->columns) &&
 
3305
        (y >= 0) && ((long) (y+rows) <= (long) cache_info->rows))
3313
3306
      {
3314
3307
        MagickBooleanType
3315
3308
          status;
3384
3377
      break;
3385
3378
    }
3386
3379
  }
3387
 
  virtual_index=0;
3388
 
  for (v=0; v < (ssize_t) rows; v++)
 
3380
  for (v=0; v < (long) rows; v++)
3389
3381
  {
3390
 
    for (u=0; u < (ssize_t) columns; u+=length)
 
3382
    for (u=0; u < (long) columns; u+=length)
3391
3383
    {
3392
3384
      length=(MagickSizeType) MagickMin(cache_info->columns-(x+u),columns-u);
3393
 
      if ((((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns)) ||
3394
 
          (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows)) || (length == 0))
 
3385
      if ((((x+u) < 0) || ((x+u) >= (long) cache_info->columns)) ||
 
3386
          (((y+v) < 0) || ((y+v) >= (long) cache_info->rows)) || (length == 0))
3395
3387
        {
3396
3388
          MagickModulo
3397
3389
            x_modulo,
3412
3404
            case WhiteVirtualPixelMethod:
3413
3405
            {
3414
3406
              p=(&virtual_pixel);
3415
 
              virtual_indexes=(&virtual_index);
3416
3407
              break;
3417
3408
            }
3418
3409
            case EdgeVirtualPixelMethod:
3421
3412
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3422
3413
                EdgeX(x+u,cache_info->columns),EdgeY(y+v,cache_info->rows),
3423
3414
                1UL,1UL,virtual_nexus[0],exception);
3424
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3425
 
                virtual_nexus[0]);
3426
3415
              break;
3427
3416
            }
3428
3417
            case RandomVirtualPixelMethod:
3433
3422
                RandomX(cache_info->random_info,cache_info->columns),
3434
3423
                RandomY(cache_info->random_info,cache_info->rows),1UL,1UL,
3435
3424
                virtual_nexus[0],exception);
3436
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3437
 
                virtual_nexus[0]);
3438
3425
              break;
3439
3426
            }
3440
3427
            case DitherVirtualPixelMethod:
3442
3429
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3443
3430
                DitherX(x+u,cache_info->columns),DitherY(y+v,cache_info->rows),
3444
3431
                1UL,1UL,virtual_nexus[0],exception);
3445
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3446
 
                virtual_nexus[0]);
3447
3432
              break;
3448
3433
            }
3449
3434
            case TileVirtualPixelMethod:
3453
3438
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3454
3439
                x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
3455
3440
                exception);
3456
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3457
 
                virtual_nexus[0]);
3458
3441
              break;
3459
3442
            }
3460
3443
            case MirrorVirtualPixelMethod:
3461
3444
            {
3462
3445
              x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
3463
3446
              if ((x_modulo.quotient & 0x01) == 1L)
3464
 
                x_modulo.remainder=(ssize_t) cache_info->columns-
 
3447
                x_modulo.remainder=(long) cache_info->columns-
3465
3448
                  x_modulo.remainder-1L;
3466
3449
              y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
3467
3450
              if ((y_modulo.quotient & 0x01) == 1L)
3468
 
                y_modulo.remainder=(ssize_t) cache_info->rows-
 
3451
                y_modulo.remainder=(long) cache_info->rows-
3469
3452
                  y_modulo.remainder-1L;
3470
3453
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3471
3454
                x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
3472
3455
                exception);
3473
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3474
 
                virtual_nexus[0]);
3475
3456
              break;
3476
3457
            }
3477
3458
            case CheckerTileVirtualPixelMethod:
3481
3462
              if (((x_modulo.quotient ^ y_modulo.quotient) & 0x01) != 0L)
3482
3463
                {
3483
3464
                  p=(&virtual_pixel);
3484
 
                  virtual_indexes=(&virtual_index);
3485
3465
                  break;
3486
3466
                }
3487
3467
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3488
3468
                x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
3489
3469
                exception);
3490
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3491
 
                virtual_nexus[0]);
3492
3470
              break;
3493
3471
            }
3494
3472
            case HorizontalTileVirtualPixelMethod:
3495
3473
            {
3496
 
              if (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows))
 
3474
              if (((y+v) < 0) || ((y+v) >= (long) cache_info->rows))
3497
3475
                {
3498
3476
                  p=(&virtual_pixel);
3499
 
                  virtual_indexes=(&virtual_index);
3500
3477
                  break;
3501
3478
                }
3502
3479
              x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
3504
3481
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3505
3482
                x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
3506
3483
                exception);
3507
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3508
 
                virtual_nexus[0]);
3509
3484
              break;
3510
3485
            }
3511
3486
            case VerticalTileVirtualPixelMethod:
3512
3487
            {
3513
 
              if (((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns))
 
3488
              if (((x+u) < 0) || ((x+u) >= (long) cache_info->columns))
3514
3489
                {
3515
3490
                  p=(&virtual_pixel);
3516
 
                  virtual_indexes=(&virtual_index);
3517
3491
                  break;
3518
3492
                }
3519
3493
              x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
3521
3495
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3522
3496
                x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
3523
3497
                exception);
3524
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3525
 
                virtual_nexus[0]);
3526
3498
              break;
3527
3499
            }
3528
3500
            case HorizontalTileEdgeVirtualPixelMethod:
3531
3503
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3532
3504
                x_modulo.remainder,EdgeY(y+v,cache_info->rows),1UL,1UL,
3533
3505
                virtual_nexus[0],exception);
3534
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3535
 
                virtual_nexus[0]);
3536
3506
              break;
3537
3507
            }
3538
3508
            case VerticalTileEdgeVirtualPixelMethod:
3541
3511
              p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
3542
3512
                EdgeX(x+u,cache_info->columns),y_modulo.remainder,1UL,1UL,
3543
3513
                virtual_nexus[0],exception);
3544
 
              virtual_indexes=GetVirtualIndexesFromNexus(cache_info,
3545
 
                virtual_nexus[0]);
3546
3514
              break;
3547
3515
            }
3548
3516
          }
3549
3517
          if (p == (const PixelPacket *) NULL)
3550
3518
            break;
3551
3519
          *q++=(*p);
3552
 
          if ((indexes != (IndexPacket *) NULL) &&
3553
 
              (virtual_indexes != (const IndexPacket *) NULL))
3554
 
            *indexes++=(*virtual_indexes);
 
3520
          if (indexes != (IndexPacket *) NULL)
 
3521
            {
 
3522
              nexus_indexes=GetVirtualIndexesFromNexus(cache_info,
 
3523
                virtual_nexus[0]);
 
3524
              if (nexus_indexes != (const IndexPacket *) NULL)
 
3525
                *indexes++=(*nexus_indexes);
 
3526
            }
3555
3527
          continue;
3556
3528
        }
3557
3529
      /*
3558
3530
        Transfer a run of pixels.
3559
3531
      */
3560
3532
      p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x+u,y+v,
3561
 
        (size_t) length,1UL,virtual_nexus[0],exception);
 
3533
        (unsigned long) length,1UL,virtual_nexus[0],exception);
3562
3534
      if (p == (const PixelPacket *) NULL)
3563
3535
        break;
3564
 
      virtual_indexes=GetVirtualIndexesFromNexus(cache_info,virtual_nexus[0]);
3565
3536
      (void) CopyMagickMemory(q,p,(size_t) length*sizeof(*p));
3566
3537
      q+=length;
3567
 
      if ((indexes != (IndexPacket *) NULL) &&
3568
 
          (virtual_indexes != (const IndexPacket *) NULL))
 
3538
      if (indexes != (IndexPacket *) NULL)
3569
3539
        {
3570
 
          (void) CopyMagickMemory(indexes,virtual_indexes,(size_t) length*
3571
 
            sizeof(*virtual_indexes));
3572
 
          indexes+=length;
 
3540
          nexus_indexes=GetVirtualIndexesFromNexus(cache_info,virtual_nexus[0]);
 
3541
          if (nexus_indexes != (const IndexPacket *) NULL)
 
3542
            {
 
3543
              (void) CopyMagickMemory(indexes,nexus_indexes,(size_t) length*
 
3544
                sizeof(*nexus_indexes));
 
3545
              indexes+=length;
 
3546
            }
3573
3547
        }
3574
3548
    }
3575
3549
  }
3595
3569
%  The format of the GetVirtualPixelCache() method is:
3596
3570
%
3597
3571
%      const PixelPacket *GetVirtualPixelCache(const Image *image,
3598
 
%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
3599
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
3572
%        const VirtualPixelMethod virtual_pixel_method,const long x,
 
3573
%        const long y,const unsigned long columns,const unsigned long rows,
3600
3574
%        ExceptionInfo *exception)
3601
3575
%
3602
3576
%  A description of each parameter follows:
3612
3586
%
3613
3587
*/
3614
3588
static const PixelPacket *GetVirtualPixelCache(const Image *image,
3615
 
  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
3616
 
  const size_t columns,const size_t rows,ExceptionInfo *exception)
 
3589
  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
 
3590
  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
3617
3591
{
3618
3592
  CacheInfo
3619
3593
   *cache_info;
3621
3595
  const PixelPacket
3622
3596
    *pixels;
3623
3597
 
3624
 
  ssize_t
 
3598
  long
3625
3599
    id;
3626
3600
 
3627
3601
  if (image->debug != MagickFalse)
3628
3602
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3629
3603
  cache_info=(CacheInfo *) image->cache;
3630
3604
  id=GetOpenMPThreadId();
3631
 
  assert(id < (ssize_t) cache_info->number_threads);
 
3605
  assert(id < (long) cache_info->number_threads);
3632
3606
  pixels=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x,y,columns,rows,
3633
3607
    cache_info->nexus_info[id],exception);
3634
3608
  return(pixels);
3709
3683
%
3710
3684
%  The format of the GetVirtualPixels() method is:
3711
3685
%
3712
 
%      const PixelPacket *GetVirtualPixels(const Image *image,const ssize_t x,
3713
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
3686
%      const PixelPacket *GetVirtualPixels(const Image *image,const long x,
 
3687
%        const long y,const unsigned long columns,const unsigned long rows,
3714
3688
%        ExceptionInfo *exception)
3715
3689
%
3716
3690
%  A description of each parameter follows:
3724
3698
%
3725
3699
*/
3726
3700
MagickExport const PixelPacket *GetVirtualPixels(const Image *image,
3727
 
  const ssize_t x,const ssize_t y,const size_t columns,
3728
 
  const size_t rows,ExceptionInfo *exception)
 
3701
  const long x,const long y,const unsigned long columns,
 
3702
  const unsigned long rows,ExceptionInfo *exception)
3729
3703
{
3730
3704
  CacheInfo
3731
3705
    *cache_info;
3779
3753
  const PixelPacket
3780
3754
    *pixels;
3781
3755
 
3782
 
  ssize_t
 
3756
  long
3783
3757
    id;
3784
3758
 
3785
3759
  if (image->debug != MagickFalse)
3786
3760
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3787
3761
  cache_info=(CacheInfo *) image->cache;
3788
3762
  id=GetOpenMPThreadId();
3789
 
  assert(id < (ssize_t) cache_info->number_threads);
 
3763
  assert(id < (long) cache_info->number_threads);
3790
3764
  pixels=GetVirtualPixelsNexus(image->cache,cache_info->nexus_info[id]);
3791
3765
  return(pixels);
3792
3766
}
3907
3881
    *restrict nexus_indexes,
3908
3882
    *restrict indexes;
3909
3883
 
3910
 
  register ssize_t
 
3884
  register long
3911
3885
    i;
3912
3886
 
3913
3887
  register PixelPacket
3942
3916
  GetMagickPixelPacket(image,&beta);
3943
3917
  number_pixels=(MagickSizeType) nexus_info->region.width*
3944
3918
    nexus_info->region.height;
3945
 
  for (i=0; i < (ssize_t) number_pixels; i++)
 
3919
  for (i=0; i < (long) number_pixels; i++)
3946
3920
  {
3947
3921
    if ((p == (PixelPacket *) NULL) || (r == (const PixelPacket *) NULL))
3948
3922
      break;
3962
3936
  }
3963
3937
  clip_nexus=DestroyPixelCacheNexus(clip_nexus,1);
3964
3938
  image_nexus=DestroyPixelCacheNexus(image_nexus,1);
3965
 
  if (i < (ssize_t) number_pixels)
 
3939
  if (i < (long) number_pixels)
3966
3940
    return(MagickFalse);
3967
3941
  return(MagickTrue);
3968
3942
}
4030
4004
 
4031
4005
      (void) FormatMagickSize(length,MagickFalse,format);
4032
4006
      (void) FormatMagickString(message,MaxTextExtent,
4033
 
        "extend %s (%s[%d], disk, %sB)",cache_info->filename,
 
4007
        "extend %s (%s[%d], disk, %s)",cache_info->filename,
4034
4008
        cache_info->cache_filename,cache_info->file,format);
4035
4009
      (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",message);
4036
4010
    }
4067
4041
  size_t
4068
4042
    packet_size;
4069
4043
 
4070
 
  size_t
 
4044
  unsigned long
4071
4045
    columns;
4072
4046
 
4073
4047
  if (image->debug != MagickFalse)
4077
4051
  cache_info=(CacheInfo *) image->cache;
4078
4052
  source_info=(*cache_info);
4079
4053
  source_info.file=(-1);
4080
 
  (void) FormatMagickString(cache_info->filename,MaxTextExtent,"%s[%.20g]",
4081
 
    image->filename,(double) GetImageIndexInList(image));
 
4054
  (void) FormatMagickString(cache_info->filename,MaxTextExtent,"%s[%ld]",
 
4055
    image->filename,GetImageIndexInList(image));
4082
4056
  cache_info->mode=mode;
4083
4057
  cache_info->rows=image->rows;
4084
4058
  cache_info->columns=image->columns;
4085
4059
  cache_info->active_index_channel=((image->storage_class == PseudoClass) ||
4086
4060
    (image->colorspace == CMYKColorspace)) ? MagickTrue : MagickFalse;
4087
 
  if (image->ping != MagickFalse)
4088
 
    {
4089
 
      cache_info->storage_class=image->storage_class;
4090
 
      cache_info->colorspace=image->colorspace;
4091
 
      cache_info->type=PingCache;
4092
 
      cache_info->pixels=(PixelPacket *) NULL;
4093
 
      cache_info->indexes=(IndexPacket *) NULL;
4094
 
      cache_info->length=0;
4095
 
      return(MagickTrue);
4096
 
    }
4097
4061
  number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
4098
4062
  packet_size=sizeof(PixelPacket);
4099
4063
  if (cache_info->active_index_channel != MagickFalse)
4100
4064
    packet_size+=sizeof(IndexPacket);
4101
4065
  length=number_pixels*packet_size;
4102
 
  columns=(size_t) (length/cache_info->rows/packet_size);
 
4066
  columns=(unsigned long) (length/cache_info->rows/packet_size);
4103
4067
  if (cache_info->columns != columns)
4104
4068
    ThrowBinaryException(ResourceLimitError,"PixelCacheAllocationFailed",
4105
4069
      image->filename);
4125
4089
                  (void) FormatMagickSize(cache_info->length,MagickTrue,
4126
4090
                    format);
4127
4091
                  (void) FormatMagickString(message,MaxTextExtent,
4128
 
                    "open %s (%s memory, %.20gx%.20g %sB)",cache_info->filename,
 
4092
                    "open %s (%s memory, %lux%lu %s)",cache_info->filename,
4129
4093
                    cache_info->mapped != MagickFalse ? "anonymous" : "heap",
4130
 
                    (double) cache_info->columns,(double) cache_info->rows,
4131
 
                    format);
 
4094
                    cache_info->columns,cache_info->rows,format);
4132
4095
                  (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",
4133
4096
                    message);
4134
4097
                }
4219
4182
                  (void) FormatMagickSize(cache_info->length,MagickTrue,
4220
4183
                    format);
4221
4184
                  (void) FormatMagickString(message,MaxTextExtent,
4222
 
                    "open %s (%s[%d], memory-mapped, %.20gx%.20g %sB)",
 
4185
                    "open %s (%s[%d], memory-mapped, %lux%lu %s)",
4223
4186
                    cache_info->filename,cache_info->cache_filename,
4224
 
                    cache_info->file,(double) cache_info->columns,(double)
4225
 
                    cache_info->rows,format);
 
4187
                    cache_info->file,cache_info->columns,cache_info->rows,
 
4188
                    format);
4226
4189
                  (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",
4227
4190
                    message);
4228
4191
                }
4240
4203
    {
4241
4204
      (void) FormatMagickSize(cache_info->length,MagickFalse,format);
4242
4205
      (void) FormatMagickString(message,MaxTextExtent,
4243
 
        "open %s (%s[%d], disk, %.20gx%.20g %sB)",cache_info->filename,
4244
 
        cache_info->cache_filename,cache_info->file,(double)
4245
 
        cache_info->columns,(double) cache_info->rows,format);
 
4206
        "open %s (%s[%d], disk, %lux%lu %s)",cache_info->filename,
 
4207
        cache_info->cache_filename,cache_info->file,cache_info->columns,
 
4208
        cache_info->rows,format);
4246
4209
      (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",message);
4247
4210
    }
4248
4211
  return(MagickTrue);
4297
4260
  Image
4298
4261
    clone_image;
4299
4262
 
4300
 
  ssize_t
 
4263
  long
4301
4264
    page_size;
4302
4265
 
4303
4266
  MagickBooleanType
4403
4366
%
4404
4367
%  The format of the QueueAuthenticNexus() method is:
4405
4368
%
4406
 
%      PixelPacket *QueueAuthenticNexus(Image *image,const ssize_t x,
4407
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
4369
%      PixelPacket *QueueAuthenticNexus(Image *image,const long x,const long y,
 
4370
%        const unsigned long columns,const unsigned long rows,
4408
4371
%        NexusInfo *nexus_info,ExceptionInfo *exception)
4409
4372
%
4410
4373
%  A description of each parameter follows:
4419
4382
%    o exception: return any errors or warnings in this structure.
4420
4383
%
4421
4384
*/
4422
 
MagickExport PixelPacket *QueueAuthenticNexus(Image *image,const ssize_t x,
4423
 
  const ssize_t y,const size_t columns,const size_t rows,
 
4385
MagickExport PixelPacket *QueueAuthenticNexus(Image *image,const long x,
 
4386
  const long y,const unsigned long columns,const unsigned long rows,
4424
4387
  NexusInfo *nexus_info,ExceptionInfo *exception)
4425
4388
{
4426
4389
  CacheInfo
4445
4408
        "NoPixelsDefinedInCache","`%s'",image->filename);
4446
4409
      return((PixelPacket *) NULL);
4447
4410
    }
4448
 
  if ((x < 0) || (y < 0) || (x >= (ssize_t) cache_info->columns) ||
4449
 
      (y >= (ssize_t) cache_info->rows))
 
4411
  if ((x < 0) || (y < 0) || (x >= (long) cache_info->columns) ||
 
4412
      (y >= (long) cache_info->rows))
4450
4413
    {
4451
4414
      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
4452
4415
        "PixelsAreNotAuthentic","`%s'",image->filename);
4488
4451
%
4489
4452
%  The format of the QueueAuthenticPixelsCache() method is:
4490
4453
%
4491
 
%      PixelPacket *QueueAuthenticPixelsCache(Image *image,const ssize_t x,
4492
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
4454
%      PixelPacket *QueueAuthenticPixelsCache(Image *image,const long x,
 
4455
%        const long y,const unsigned long columns,const unsigned long rows,
4493
4456
%        ExceptionInfo *exception)
4494
4457
%
4495
4458
%  A description of each parameter follows:
4502
4465
%    o exception: return any errors or warnings in this structure.
4503
4466
%
4504
4467
*/
4505
 
static PixelPacket *QueueAuthenticPixelsCache(Image *image,const ssize_t x,
4506
 
  const ssize_t y,const size_t columns,const size_t rows,
 
4468
static PixelPacket *QueueAuthenticPixelsCache(Image *image,const long x,
 
4469
  const long y,const unsigned long columns,const unsigned long rows,
4507
4470
  ExceptionInfo *exception)
4508
4471
{
4509
4472
  CacheInfo
4510
4473
    *cache_info;
4511
4474
 
4512
 
  ssize_t
 
4475
  long
4513
4476
    id;
4514
4477
 
4515
4478
  PixelPacket
4519
4482
  if (cache_info == (Cache) NULL)
4520
4483
    return((PixelPacket *) NULL);
4521
4484
  id=GetOpenMPThreadId();
4522
 
  assert(id < (ssize_t) cache_info->number_threads);
 
4485
  assert(id < (long) cache_info->number_threads);
4523
4486
  pixels=QueueAuthenticNexus(image,x,y,columns,rows,cache_info->nexus_info[id],
4524
4487
    exception);
4525
4488
  return(pixels);
4567
4530
%
4568
4531
%  The format of the QueueAuthenticPixels() method is:
4569
4532
%
4570
 
%      PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,
4571
 
%        const ssize_t y,const size_t columns,const size_t rows,
 
4533
%      PixelPacket *QueueAuthenticPixels(Image *image,const long x,const long y,
 
4534
%        const unsigned long columns,const unsigned long rows,
4572
4535
%        ExceptionInfo *exception)
4573
4536
%
4574
4537
%  A description of each parameter follows:
4581
4544
%    o exception: return any errors or warnings in this structure.
4582
4545
%
4583
4546
*/
4584
 
MagickExport PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,
4585
 
  const ssize_t y,const size_t columns,const size_t rows,
 
4547
MagickExport PixelPacket *QueueAuthenticPixels(Image *image,const long x,
 
4548
  const long y,const unsigned long columns,const unsigned long rows,
4586
4549
  ExceptionInfo *exception)
4587
4550
{
4588
4551
  CacheInfo
4648
4611
  register IndexPacket
4649
4612
    *restrict q;
4650
4613
 
4651
 
  register ssize_t
 
4614
  register long
4652
4615
    y;
4653
4616
 
4654
 
  size_t
 
4617
  unsigned long
4655
4618
    rows;
4656
4619
 
4657
4620
  if (cache_info->debug != MagickFalse)
4685
4648
          rows=1UL;
4686
4649
        }
4687
4650
      p=cache_info->indexes+offset;
4688
 
      for (y=0; y < (ssize_t) rows; y++)
 
4651
      for (y=0; y < (long) rows; y++)
4689
4652
      {
4690
4653
        (void) CopyMagickMemory(q,p,(size_t) length);
4691
4654
        p+=cache_info->columns;
4711
4674
          rows=1UL;
4712
4675
        }
4713
4676
      number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
4714
 
      for (y=0; y < (ssize_t) rows; y++)
 
4677
      for (y=0; y < (long) rows; y++)
4715
4678
      {
4716
4679
        count=ReadPixelCacheRegion(cache_info,cache_info->offset+number_pixels*
4717
4680
          sizeof(PixelPacket)+offset*sizeof(*q),length,(unsigned char *) q);
4720
4683
        offset+=cache_info->columns;
4721
4684
        q+=nexus_info->region.width;
4722
4685
      }
4723
 
      if (y < (ssize_t) rows)
 
4686
      if (y < (long) rows)
4724
4687
        {
4725
4688
          ThrowFileException(exception,CacheError,"UnableToReadPixelCache",
4726
4689
            cache_info->cache_filename);
4732
4695
      break;
4733
4696
  }
4734
4697
  if ((cache_info->debug != MagickFalse) &&
4735
 
      (QuantumTick((MagickOffsetType) nexus_info->region.y,cache_info->rows) != MagickFalse))
4736
 
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),
4737
 
      "%s[%.20gx%.20g%+.20g%+.20g]",cache_info->filename,(double)
4738
 
      nexus_info->region.width,(double) nexus_info->region.height,(double)
4739
 
      nexus_info->region.x,(double) nexus_info->region.y);
 
4698
      (QuantumTick(nexus_info->region.y,cache_info->rows) != MagickFalse))
 
4699
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s[%lux%lu%+ld%+ld]",
 
4700
      cache_info->filename,nexus_info->region.width,nexus_info->region.height,
 
4701
      nexus_info->region.x,nexus_info->region.y);
4740
4702
  return(MagickTrue);
4741
4703
}
4742
4704
 
4779
4741
    length,
4780
4742
    number_pixels;
4781
4743
 
4782
 
  register ssize_t
 
4744
  register long
4783
4745
    y;
4784
4746
 
4785
4747
  register PixelPacket
4786
4748
    *restrict q;
4787
4749
 
4788
 
  size_t
 
4750
  unsigned long
4789
4751
    rows;
4790
4752
 
4791
4753
  if (cache_info->debug != MagickFalse)
4817
4779
          rows=1UL;
4818
4780
        }
4819
4781
      p=cache_info->pixels+offset;
4820
 
      for (y=0; y < (ssize_t) rows; y++)
 
4782
      for (y=0; y < (long) rows; y++)
4821
4783
      {
4822
4784
        (void) CopyMagickMemory(q,p,(size_t) length);
4823
4785
        p+=cache_info->columns;
4842
4804
          length=number_pixels;
4843
4805
          rows=1UL;
4844
4806
        }
4845
 
      for (y=0; y < (ssize_t) rows; y++)
 
4807
      for (y=0; y < (long) rows; y++)
4846
4808
      {
4847
4809
        count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset*
4848
4810
          sizeof(*q),length,(unsigned char *) q);
4851
4813
        offset+=cache_info->columns;
4852
4814
        q+=nexus_info->region.width;
4853
4815
      }
4854
 
      if (y < (ssize_t) rows)
 
4816
      if (y < (long) rows)
4855
4817
        {
4856
4818
          ThrowFileException(exception,CacheError,"UnableToReadPixelCache",
4857
4819
            cache_info->cache_filename);
4863
4825
      break;
4864
4826
  }
4865
4827
  if ((cache_info->debug != MagickFalse) &&
4866
 
      (QuantumTick((MagickOffsetType) nexus_info->region.y,cache_info->rows) != MagickFalse))
4867
 
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),
4868
 
      "%s[%.20gx%.20g%+.20g%+.20g]",cache_info->filename,(double)
4869
 
      nexus_info->region.width,(double) nexus_info->region.height,(double)
4870
 
      nexus_info->region.x,(double) nexus_info->region.y);
 
4828
      (QuantumTick(nexus_info->region.y,cache_info->rows) != MagickFalse))
 
4829
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s[%lux%lu%+ld%+ld]",
 
4830
      cache_info->filename,nexus_info->region.width,nexus_info->region.height,
 
4831
      nexus_info->region.x,nexus_info->region.y);
4871
4832
  return(MagickTrue);
4872
4833
}
4873
4834
 
5051
5012
  assert(cache_info->signature == MagickSignature);
5052
5013
  if (cache_info->type == UndefinedCache)
5053
5014
    return((PixelPacket *) NULL);
5054
 
  nexus_info->region=(*region);
5055
 
  if ((cache_info->type != DiskCache) && (cache_info->type != PingCache) &&
5056
 
      (image->clip_mask == (Image *) NULL) && (image->mask == (Image *) NULL))
 
5015
  nexus_info->region.width=region->width == 0UL ? 1UL : region->width;
 
5016
  nexus_info->region.height=region->height == 0UL ? 1UL : region->height;
 
5017
  nexus_info->region.x=region->x;
 
5018
  nexus_info->region.y=region->y;
 
5019
  if ((cache_info->type != DiskCache) && (image->clip_mask == (Image *) NULL) &&
 
5020
      (image->mask == (Image *) NULL))
5057
5021
    {
5058
 
      ssize_t
 
5022
      long
5059
5023
        x,
5060
5024
        y;
5061
5025
 
5062
 
      x=nexus_info->region.x+(ssize_t) nexus_info->region.width-1;
5063
 
      y=nexus_info->region.y+(ssize_t) nexus_info->region.height-1;
5064
 
      if (((nexus_info->region.x >= 0) && (x < (ssize_t) cache_info->columns) &&
5065
 
           (nexus_info->region.y >= 0) && (y < (ssize_t) cache_info->rows)) &&
 
5026
      x=nexus_info->region.x+nexus_info->region.width-1;
 
5027
      y=nexus_info->region.y+nexus_info->region.height-1;
 
5028
      if (((nexus_info->region.x >= 0) && (x < (long) cache_info->columns) &&
 
5029
           (nexus_info->region.y >= 0) && (y < (long) cache_info->rows)) &&
5066
5030
          ((nexus_info->region.height == 1UL) ||
5067
5031
           ((nexus_info->region.x == 0) &&
5068
5032
           ((nexus_info->region.width == cache_info->columns) ||
5261
5225
  CacheInfo
5262
5226
    *cache_info;
5263
5227
 
5264
 
  ssize_t
 
5228
  long
5265
5229
    id;
5266
5230
 
5267
5231
  MagickBooleanType
5269
5233
 
5270
5234
  cache_info=(CacheInfo *) image->cache;
5271
5235
  id=GetOpenMPThreadId();
5272
 
  assert(id < (ssize_t) cache_info->number_threads);
 
5236
  assert(id < (long) cache_info->number_threads);
5273
5237
  status=SyncAuthenticPixelCacheNexus(image,cache_info->nexus_info[id],
5274
5238
    exception);
5275
5239
  return(status);
5363
5327
  register const IndexPacket
5364
5328
    *restrict p;
5365
5329
 
5366
 
  register ssize_t
 
5330
  register long
5367
5331
    y;
5368
5332
 
5369
 
  size_t
 
5333
  unsigned long
5370
5334
    rows;
5371
5335
 
5372
5336
  if (cache_info->debug != MagickFalse)
5400
5364
          rows=1UL;
5401
5365
        }
5402
5366
      q=cache_info->indexes+offset;
5403
 
      for (y=0; y < (ssize_t) rows; y++)
 
5367
      for (y=0; y < (long) rows; y++)
5404
5368
      {
5405
5369
        (void) CopyMagickMemory(q,p,(size_t) length);
5406
5370
        p+=nexus_info->region.width;
5426
5390
          rows=1UL;
5427
5391
        }
5428
5392
      number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
5429
 
      for (y=0; y < (ssize_t) rows; y++)
 
5393
      for (y=0; y < (long) rows; y++)
5430
5394
      {
5431
5395
        count=WritePixelCacheRegion(cache_info,cache_info->offset+number_pixels*
5432
5396
          sizeof(PixelPacket)+offset*sizeof(*p),length,
5436
5400
        p+=nexus_info->region.width;
5437
5401
        offset+=cache_info->columns;
5438
5402
      }
5439
 
      if (y < (ssize_t) rows)
 
5403
      if (y < (long) rows)
5440
5404
        {
5441
5405
          ThrowFileException(exception,CacheError,"UnableToWritePixelCache",
5442
5406
            cache_info->cache_filename);
5448
5412
      break;
5449
5413
  }
5450
5414
  if ((cache_info->debug != MagickFalse) &&
5451
 
      (QuantumTick((MagickOffsetType) nexus_info->region.y,cache_info->rows) != MagickFalse))
5452
 
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),
5453
 
      "%s[%.20gx%.20g%+.20g%+.20g]",cache_info->filename,(double)
5454
 
      nexus_info->region.width,(double) nexus_info->region.height,(double)
5455
 
      nexus_info->region.x,(double) nexus_info->region.y);
 
5415
      (QuantumTick(nexus_info->region.y,cache_info->rows) != MagickFalse))
 
5416
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s[%lux%lu%+ld%+ld]",
 
5417
      cache_info->filename,nexus_info->region.width,nexus_info->region.height,
 
5418
      nexus_info->region.x,nexus_info->region.y);
5456
5419
  return(MagickTrue);
5457
5420
}
5458
5421
 
5498
5461
  register const PixelPacket
5499
5462
    *restrict p;
5500
5463
 
5501
 
  register ssize_t
 
5464
  register long
5502
5465
    y;
5503
5466
 
5504
 
  size_t
 
5467
  unsigned long
5505
5468
    rows;
5506
5469
 
5507
5470
  if (cache_info->debug != MagickFalse)
5533
5496
          rows=1UL;
5534
5497
        }
5535
5498
      q=cache_info->pixels+offset;
5536
 
      for (y=0; y < (ssize_t) rows; y++)
 
5499
      for (y=0; y < (long) rows; y++)
5537
5500
      {
5538
5501
        (void) CopyMagickMemory(q,p,(size_t) length);
5539
5502
        p+=nexus_info->region.width;
5558
5521
          length=number_pixels;
5559
5522
          rows=1UL;
5560
5523
        }
5561
 
      for (y=0; y < (ssize_t) rows; y++)
 
5524
      for (y=0; y < (long) rows; y++)
5562
5525
      {
5563
5526
        count=WritePixelCacheRegion(cache_info,cache_info->offset+offset*
5564
5527
          sizeof(*p),length,(const unsigned char *) p);
5567
5530
        p+=nexus_info->region.width;
5568
5531
        offset+=cache_info->columns;
5569
5532
      }
5570
 
      if (y < (ssize_t) rows)
 
5533
      if (y < (long) rows)
5571
5534
        {
5572
5535
          ThrowFileException(exception,CacheError,"UnableToWritePixelCache",
5573
5536
            cache_info->cache_filename);
5579
5542
      break;
5580
5543
  }
5581
5544
  if ((cache_info->debug != MagickFalse) &&
5582
 
      (QuantumTick((MagickOffsetType) nexus_info->region.y,cache_info->rows) != MagickFalse))
5583
 
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),
5584
 
      "%s[%.20gx%.20g%+.20g%+.20g]",cache_info->filename,(double)
5585
 
      nexus_info->region.width,(double) nexus_info->region.height,(double)
5586
 
      nexus_info->region.x,(double) nexus_info->region.y);
 
5545
      (QuantumTick(nexus_info->region.y,cache_info->rows) != MagickFalse))
 
5546
    (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s[%lux%lu%+ld%+ld]",
 
5547
      cache_info->filename,nexus_info->region.width,nexus_info->region.height,
 
5548
      nexus_info->region.x,nexus_info->region.y);
5587
5549
  return(MagickTrue);
5588
5550
}