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

« back to all changes in this revision

Viewing changes to magick/image.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:
180
180
  image->y_resolution=DefaultResolution;
181
181
  image->units=PixelsPerInchResolution;
182
182
  GetTimerInfo(&image->timer);
183
 
  image->ping=MagickFalse;
184
183
  image->cache=AcquirePixelCache(0);
185
184
  image->blob=CloneBlobInfo((BlobInfo *) NULL);
186
185
  image->debug=IsEventLogging();
253
252
  image->border_color=image_info->border_color;
254
253
  image->matte_color=image_info->matte_color;
255
254
  image->transparent_color=image_info->transparent_color;
256
 
  image->ping=image_info->ping;
257
255
  image->progress_monitor=image_info->progress_monitor;
258
256
  image->client_data=image_info->client_data;
259
257
  if (image_info->cache != (void *) NULL)
268
266
%                                                                             %
269
267
%                                                                             %
270
268
%                                                                             %
 
269
%   A c q u i r e I m a g e C o l o r m a p                                   %
 
270
%                                                                             %
 
271
%                                                                             %
 
272
%                                                                             %
 
273
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
274
%
 
275
%  AcquireImageColormap() allocates an image colormap and initializes
 
276
%  it to a linear gray colorspace.  If the image already has a colormap,
 
277
%  it is replaced.  AcquireImageColormap() returns MagickTrue if successful,
 
278
%  otherwise MagickFalse if there is not enough memory.
 
279
%
 
280
%  The format of the AcquireImageColormap method is:
 
281
%
 
282
%      MagickBooleanType AcquireImageColormap(Image *image,
 
283
%        const unsigned long colors)
 
284
%
 
285
%  A description of each parameter follows:
 
286
%
 
287
%    o image: the image.
 
288
%
 
289
%    o colors: the number of colors in the image colormap.
 
290
%
 
291
*/
 
292
 
 
293
static inline unsigned long MagickMax(const unsigned long x,
 
294
  const unsigned long y)
 
295
{
 
296
  if (x > y)
 
297
    return(x);
 
298
  return(y);
 
299
}
 
300
 
 
301
static inline unsigned long MagickMin(const unsigned long x,
 
302
  const unsigned long y)
 
303
{
 
304
  if (x < y)
 
305
    return(x);
 
306
  return(y);
 
307
}
 
308
 
 
309
MagickExport MagickBooleanType AcquireImageColormap(Image *image,
 
310
  const unsigned long colors)
 
311
{
 
312
  register long
 
313
    i;
 
314
 
 
315
  size_t
 
316
    length;
 
317
 
 
318
  /*
 
319
    Allocate image colormap.
 
320
  */
 
321
  assert(image != (Image *) NULL);
 
322
  assert(image->signature == MagickSignature);
 
323
  if (image->debug != MagickFalse)
 
324
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
 
325
  image->colors=MagickMin(colors,MaxColormapSize);
 
326
  length=(size_t) colors;
 
327
  if (image->colormap == (PixelPacket *) NULL)
 
328
    image->colormap=(PixelPacket *) AcquireQuantumMemory(length,
 
329
      sizeof(*image->colormap));
 
330
  else
 
331
    image->colormap=(PixelPacket *) ResizeQuantumMemory(image->colormap,length,
 
332
      sizeof(*image->colormap));
 
333
  if (image->colormap == (PixelPacket *) NULL)
 
334
    ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
 
335
      image->filename);
 
336
  for (i=0; i < (long) image->colors; i++)
 
337
  {
 
338
    unsigned long
 
339
      pixel;
 
340
 
 
341
    pixel=(unsigned long) (i*(QuantumRange/MagickMax(colors-1,1)));
 
342
    image->colormap[i].red=(Quantum) pixel;
 
343
    image->colormap[i].green=(Quantum) pixel;
 
344
    image->colormap[i].blue=(Quantum) pixel;
 
345
    image->colormap[i].opacity=OpaqueOpacity;
 
346
  }
 
347
  return(SetImageStorageClass(image,PseudoClass));
 
348
}
 
349
 
 
350
/*
 
351
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
352
%                                                                             %
 
353
%                                                                             %
 
354
%                                                                             %
271
355
%   A c q u i r e I m a g e I n f o                                           %
272
356
%                                                                             %
273
357
%                                                                             %
389
473
  Image
390
474
    *append_image;
391
475
 
 
476
  long
 
477
    n,
 
478
    x_offset,
 
479
    y,
 
480
    y_offset;
 
481
 
392
482
  MagickBooleanType
393
483
    matte,
394
484
    proceed,
395
485
    status;
396
486
 
397
 
  MagickOffsetType
398
 
    n;
399
 
 
400
487
  RectangleInfo
401
488
    geometry;
402
489
 
403
490
  register const Image
404
491
    *next;
405
492
 
406
 
  size_t
 
493
  unsigned long
407
494
    height,
408
495
    number_images,
409
496
    width;
410
497
 
411
 
  ssize_t
412
 
    x_offset,
413
 
    y,
414
 
    y_offset;
415
 
 
416
498
  /*
417
499
    Ensure the image have the same column width.
418
500
  */
461
543
  x_offset=0;
462
544
  y_offset=0;
463
545
  append_view=AcquireCacheView(append_image);
464
 
  for (n=0; n < (MagickOffsetType) number_images; n++)
 
546
  for (n=0; n < (long) number_images; n++)
465
547
  {
466
548
    SetGeometry(append_image,&geometry);
467
549
    GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
473
555
#if defined(MAGICKCORE_OPENMP_SUPPORT)
474
556
    #pragma omp parallel for schedule(dynamic,4) shared(status)
475
557
#endif
476
 
    for (y=0; y < (ssize_t) image->rows; y++)
 
558
    for (y=0; y < (long) image->rows; y++)
477
559
    {
478
560
      MagickBooleanType
479
561
        sync;
487
569
      register IndexPacket
488
570
        *restrict append_indexes;
489
571
 
490
 
      register ssize_t
 
572
      register long
491
573
        x;
492
574
 
493
575
      register PixelPacket
505
587
        }
506
588
      indexes=GetCacheViewVirtualIndexQueue(image_view);
507
589
      append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
508
 
      for (x=0; x < (ssize_t) image->columns; x++)
 
590
      for (x=0; x < (long) image->columns; x++)
509
591
      {
510
592
        SetRedPixelComponent(q,GetRedPixelComponent(p));
511
593
        SetGreenPixelComponent(q,GetGreenPixelComponent(p));
520
602
      }
521
603
      sync=SyncCacheViewAuthenticPixels(append_view,exception);
522
604
      if (sync == MagickFalse)
523
 
        status=MagickFalse;
 
605
        continue;
524
606
    }
525
607
    image_view=DestroyCacheView(image_view);
526
608
    proceed=SetImageProgress(image,AppendImageTag,n,number_images);
528
610
      break;
529
611
    if (stack == MagickFalse)
530
612
      {
531
 
        x_offset+=(ssize_t) image->columns;
 
613
        x_offset+=image->columns;
532
614
        y_offset=0;
533
615
      }
534
616
    else
535
617
      {
536
618
        x_offset=0;
537
 
        y_offset+=(ssize_t) image->rows;
 
619
        y_offset+=image->rows;
538
620
      }
539
621
    image=GetNextImageInList(image);
540
622
  }
699
781
%
700
782
%  The format of the CloneImage method is:
701
783
%
702
 
%      Image *CloneImage(const Image *image,const size_t columns,
703
 
%        const size_t rows,const MagickBooleanType orphan,
 
784
%      Image *CloneImage(const Image *image,const unsigned long columns,
 
785
%        const unsigned long rows,const MagickBooleanType orphan,
704
786
%        ExceptionInfo *exception)
705
787
%
706
788
%  A description of each parameter follows:
717
799
%    o exception: return any errors or warnings in this structure.
718
800
%
719
801
*/
720
 
MagickExport Image *CloneImage(const Image *image,const size_t columns,
721
 
  const size_t rows,const MagickBooleanType detach,
 
802
MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
 
803
  const unsigned long rows,const MagickBooleanType detach,
722
804
  ExceptionInfo *exception)
723
805
{
724
806
  Image
791
873
    clone_image->blob=ReferenceBlob(image->blob);
792
874
  else
793
875
    clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
794
 
  clone_image->ping=image->ping;
795
876
  clone_image->debug=IsEventLogging();
796
877
  clone_image->semaphore=AllocateSemaphoreInfo();
797
878
  if ((columns == 0) && (rows == 0))
809
890
      return(clone_image);
810
891
    }
811
892
  scale=(MagickRealType) columns/(MagickRealType) image->columns;
812
 
  clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
813
 
  clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
814
 
  clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
 
893
  clone_image->page.width=(unsigned long) (scale*image->page.width+0.5);
 
894
  clone_image->page.x=(long) (scale*image->page.x+0.5);
 
895
  clone_image->tile_offset.x=(long) (scale*image->tile_offset.x+0.5);
815
896
  scale=(MagickRealType) rows/(MagickRealType) image->rows;
816
 
  clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
817
 
  clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
818
 
  clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
 
897
  clone_image->page.height=(unsigned long) (scale*image->page.height+0.5);
 
898
  clone_image->page.y=(long) (image->page.y*scale+0.5);
 
899
  clone_image->tile_offset.y=(long) (scale*image->tile_offset.y+0.5);
819
900
  clone_image->columns=columns;
820
901
  clone_image->rows=rows;
821
902
  clone_image->cache=ClonePixelCache(image->cache);
973
1054
  Image
974
1055
    *combine_image;
975
1056
 
 
1057
  long
 
1058
    progress,
 
1059
    y;
 
1060
 
976
1061
  MagickBooleanType
977
1062
    status;
978
1063
 
979
 
  MagickOffsetType
980
 
    progress;
981
 
 
982
 
  ssize_t
983
 
    y;
984
 
 
985
1064
  /*
986
1065
    Ensure the image are the same size.
987
1066
  */
1017
1096
#if defined(MAGICKCORE_OPENMP_SUPPORT)
1018
1097
  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
1019
1098
#endif
1020
 
  for (y=0; y < (ssize_t) combine_image->rows; y++)
 
1099
  for (y=0; y < (long) combine_image->rows; y++)
1021
1100
  {
1022
1101
    CacheView
1023
1102
      *image_view;
1031
1110
    register const PixelPacket
1032
1111
      *restrict p;
1033
1112
 
1034
 
    register ssize_t
 
1113
    register long
1035
1114
      x;
1036
1115
 
1037
1116
    register PixelPacket
1054
1133
        if (p == (const PixelPacket *) NULL)
1055
1134
          continue;
1056
1135
        q=pixels;
1057
 
        for (x=0; x < (ssize_t) combine_image->columns; x++)
 
1136
        for (x=0; x < (long) combine_image->columns; x++)
1058
1137
        {
1059
1138
          SetRedPixelComponent(q,PixelIntensityToQuantum(p));
1060
1139
          p++;
1070
1149
        if (p == (const PixelPacket *) NULL)
1071
1150
          continue;
1072
1151
        q=pixels;
1073
 
        for (x=0; x < (ssize_t) combine_image->columns; x++)
 
1152
        for (x=0; x < (long) combine_image->columns; x++)
1074
1153
        {
1075
1154
          SetGreenPixelComponent(q,PixelIntensityToQuantum(p));
1076
1155
          p++;
1086
1165
        if (p == (const PixelPacket *) NULL)
1087
1166
          continue;
1088
1167
        q=pixels;
1089
 
        for (x=0; x < (ssize_t) combine_image->columns; x++)
 
1168
        for (x=0; x < (long) combine_image->columns; x++)
1090
1169
        {
1091
1170
          SetBluePixelComponent(q,PixelIntensityToQuantum(p));
1092
1171
          p++;
1102
1181
        if (p == (const PixelPacket *) NULL)
1103
1182
          continue;
1104
1183
        q=pixels;
1105
 
        for (x=0; x < (ssize_t) combine_image->columns; x++)
 
1184
        for (x=0; x < (long) combine_image->columns; x++)
1106
1185
        {
1107
1186
          SetOpacityPixelComponent(q,PixelIntensityToQuantum(p));
1108
1187
          p++;
1122
1201
        if (p == (const PixelPacket *) NULL)
1123
1202
          continue;
1124
1203
        indexes=GetCacheViewAuthenticIndexQueue(combine_view);
1125
 
        for (x=0; x < (ssize_t) combine_image->columns; x++)
 
1204
        for (x=0; x < (long) combine_image->columns; x++)
1126
1205
        {
1127
1206
          indexes[x]=PixelIntensityToQuantum(p);
1128
1207
          p++;
1561
1640
%
1562
1641
%  The format of the GetReferenceCount method is:
1563
1642
%
1564
 
%      ssize_t GetImageReferenceCount(Image *image)
 
1643
%      long GetImageReferenceCount(Image *image)
1565
1644
%
1566
1645
%  A description of each parameter follows:
1567
1646
%
1568
1647
%    o image: the image.
1569
1648
%
1570
1649
*/
1571
 
MagickExport ssize_t GetImageReferenceCount(Image *image)
 
1650
MagickExport long GetImageReferenceCount(Image *image)
1572
1651
{
1573
 
  ssize_t
 
1652
  long
1574
1653
    reference_count;
1575
1654
 
1576
1655
  assert(image != (Image *) NULL);
1676
1755
      }
1677
1756
    if (*q == '0')
1678
1757
      {
1679
 
        ssize_t
 
1758
        long
1680
1759
          value;
1681
1760
 
1682
 
        value=(ssize_t) strtol(q,&q,10);
 
1761
        value=strtol(q,&q,10);
1683
1762
      }
1684
1763
    switch (*q)
1685
1764
    {
1708
1787
        const char
1709
1788
          *value;
1710
1789
 
1711
 
        ssize_t
 
1790
        long
1712
1791
          depth;
1713
1792
 
1714
1793
        register char
1715
1794
          *r;
1716
1795
 
1717
 
        register ssize_t
 
1796
        register long
1718
1797
          i;
1719
1798
 
1720
1799
        /*
1812
1891
  CacheView
1813
1892
    *image_view;
1814
1893
 
1815
 
  ssize_t
 
1894
  long
1816
1895
    y;
1817
1896
 
1818
1897
  MagickBooleanType
1831
1910
#if defined(MAGICKCORE_OPENMP_SUPPORT)
1832
1911
  #pragma omp parallel for schedule(dynamic,4) shared(status)
1833
1912
#endif
1834
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
1913
  for (y=0; y < (long) image->rows; y++)
1835
1914
  {
1836
1915
    MagickPixelPacket
1837
1916
      pixel;
1842
1921
    register const PixelPacket
1843
1922
      *p;
1844
1923
 
1845
 
    register ssize_t
 
1924
    register long
1846
1925
      x;
1847
1926
 
1848
1927
    if (status == MagickFalse)
1855
1934
      }
1856
1935
    indexes=GetCacheViewVirtualIndexQueue(image_view);
1857
1936
    pixel=zero;
1858
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
1937
    for (x=0; x < (long) image->columns; x++)
1859
1938
    {
1860
1939
      SetMagickPixelPacket(image,p,indexes+x,&pixel);
1861
1940
      if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1881
1960
        }
1882
1961
      p++;
1883
1962
    }
1884
 
    if (x < (ssize_t) image->columns)
 
1963
    if (x < (long) image->columns)
1885
1964
      status=MagickFalse;
1886
1965
  }
1887
1966
  image_view=DestroyCacheView(image_view);
2040
2119
%  The format of the NewMagickImage method is:
2041
2120
%
2042
2121
%      Image *NewMagickImage(const ImageInfo *image_info,
2043
 
%        const size_t width,const size_t height,
 
2122
%        const unsigned long width,const unsigned long height,
2044
2123
%        const MagickPixelPacket *background)
2045
2124
%
2046
2125
%  A description of each parameter follows:
2055
2134
%
2056
2135
*/
2057
2136
MagickExport Image *NewMagickImage(const ImageInfo *image_info,
2058
 
  const size_t width,const size_t height,
 
2137
  const unsigned long width,const unsigned long height,
2059
2138
  const MagickPixelPacket *background)
2060
2139
{
2061
2140
  CacheView
2067
2146
  Image
2068
2147
    *image;
2069
2148
 
2070
 
  ssize_t
 
2149
  long
2071
2150
    y;
2072
2151
 
2073
2152
  MagickBooleanType
2091
2170
#if defined(MAGICKCORE_OPENMP_SUPPORT)
2092
2171
  #pragma omp parallel for schedule(dynamic,4) shared(status)
2093
2172
#endif
2094
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
2173
  for (y=0; y < (long) image->rows; y++)
2095
2174
  {
2096
2175
    register IndexPacket
2097
2176
      *restrict indexes;
2098
2177
 
2099
 
    register ssize_t
 
2178
    register long
2100
2179
      x;
2101
2180
 
2102
2181
    register PixelPacket
2111
2190
        continue;
2112
2191
      }
2113
2192
    indexes=GetCacheViewAuthenticIndexQueue(image_view);
2114
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
2193
    for (x=0; x < (long) image->columns; x++)
2115
2194
    {
2116
2195
      SetPixelPacket(image,background,q,indexes+x);
2117
2196
      q++;
2269
2348
  ExceptionInfo
2270
2349
    *exception;
2271
2350
 
 
2351
  long
 
2352
    progress,
 
2353
    y;
 
2354
 
2272
2355
  MagickBooleanType
2273
2356
    status;
2274
2357
 
2275
 
  MagickOffsetType
2276
 
    progress;
2277
 
 
2278
 
  ssize_t
2279
 
    y;
2280
 
 
2281
2358
  assert(image != (Image *) NULL);
2282
2359
  assert(image->signature == MagickSignature);
2283
2360
  if (image->debug != MagickFalse)
2288
2365
    Separate image channels.
2289
2366
  */
2290
2367
  status=MagickTrue;
2291
 
  if (channel == GrayChannels)
 
2368
  if ( channel == GrayChannels )
2292
2369
    image->matte=MagickTrue;
2293
2370
  progress=0;
2294
2371
  exception=(&image->exception);
2296
2373
#if defined(MAGICKCORE_OPENMP_SUPPORT)
2297
2374
  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
2298
2375
#endif
2299
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
2376
  for (y=0; y < (long) image->rows; y++)
2300
2377
  {
2301
2378
    register IndexPacket
2302
2379
      *restrict indexes;
2303
2380
 
2304
 
    register ssize_t
 
2381
    register long
2305
2382
      x;
2306
2383
 
2307
2384
    register PixelPacket
2320
2397
    {
2321
2398
      case RedChannel:
2322
2399
      {
2323
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2400
        for (x=0; x < (long) image->columns; x++)
2324
2401
        {
2325
2402
          q->green=q->red;
2326
2403
          q->blue=q->red;
2330
2407
      }
2331
2408
      case GreenChannel:
2332
2409
      {
2333
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2410
        for (x=0; x < (long) image->columns; x++)
2334
2411
        {
2335
2412
          q->red=q->green;
2336
2413
          q->blue=q->green;
2340
2417
      }
2341
2418
      case BlueChannel:
2342
2419
      {
2343
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2420
        for (x=0; x < (long) image->columns; x++)
2344
2421
        {
2345
2422
          q->red=q->blue;
2346
2423
          q->green=q->blue;
2350
2427
      }
2351
2428
      case OpacityChannel:
2352
2429
      {
2353
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2430
        for (x=0; x < (long) image->columns; x++)
2354
2431
        {
2355
2432
          q->red=q->opacity;
2356
2433
          q->green=q->opacity;
2364
2441
        if ((image->storage_class != PseudoClass) &&
2365
2442
            (image->colorspace != CMYKColorspace))
2366
2443
          break;
2367
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2444
        for (x=0; x < (long) image->columns; x++)
2368
2445
        {
2369
2446
          q->red=indexes[x];
2370
2447
          q->green=indexes[x];
2375
2452
      }
2376
2453
      case TrueAlphaChannel:
2377
2454
      {
2378
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2455
        for (x=0; x < (long) image->columns; x++)
2379
2456
        {
2380
2457
          q->red=(Quantum) GetAlphaPixelComponent(q);
2381
2458
          q->green=(Quantum) GetAlphaPixelComponent(q);
2386
2463
      }
2387
2464
      case GrayChannels:
2388
2465
      {
2389
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2466
        for (x=0; x < (long) image->columns; x++)
2390
2467
        {
2391
2468
          q->opacity=(Quantum) (QuantumRange-PixelIntensityToQuantum(q));
2392
2469
          q++;
2412
2489
      }
2413
2490
  }
2414
2491
  image_view=DestroyCacheView(image_view);
2415
 
  if (channel != GrayChannels)
 
2492
  if ( channel != GrayChannels )
2416
2493
    image->matte=MagickFalse;
2417
2494
  (void) SetImageColorspace(image,RGBColorspace);
2418
2495
  return(status);
2551
2628
      IndexPacket
2552
2629
        index;
2553
2630
 
2554
 
      ssize_t
 
2631
      long
2555
2632
        y;
2556
2633
 
2557
2634
      MagickBooleanType
2583
2660
      #if defined(MAGICKCORE_OPENMP_SUPPORT)
2584
2661
        #pragma omp parallel for schedule(dynamic,4) shared(status)
2585
2662
      #endif
2586
 
      for (y=0; y < (ssize_t) image->rows; y++)
 
2663
      for (y=0; y < (long) image->rows; y++)
2587
2664
      {
2588
2665
        register IndexPacket
2589
2666
          *restrict indexes;
2590
2667
 
2591
 
        register ssize_t
 
2668
        register long
2592
2669
          x;
2593
2670
 
2594
2671
        register PixelPacket
2603
2680
            status=MagickFalse;
2604
2681
            continue;
2605
2682
          }
2606
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2683
        for (x=0; x < (long) image->columns; x++)
2607
2684
        {
2608
2685
          if (q->opacity == TransparentOpacity)
2609
2686
            {
2616
2693
        if (image->colorspace == CMYKColorspace)
2617
2694
          {
2618
2695
            indexes=GetCacheViewAuthenticIndexQueue(image_view);
2619
 
            for (x=0; x < (ssize_t) image->columns; x++)
 
2696
            for (x=0; x < (long) image->columns; x++)
2620
2697
              indexes[x]=index;
2621
2698
          }
2622
2699
        if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2660
2737
      image->matte=MagickFalse;
2661
2738
      break;
2662
2739
    }
2663
 
    case ResetAlphaChannel: /* deprecated */
 
2740
    case ResetAlphaChannel:
2664
2741
    case OpaqueAlphaChannel:
2665
2742
    {
2666
2743
      status=SetImageOpacity(image,OpaqueOpacity);
2723
2800
  IndexPacket
2724
2801
    index;
2725
2802
 
2726
 
  ssize_t
 
2803
  long
2727
2804
    y;
2728
2805
 
2729
2806
  MagickBooleanType
2759
2836
#if defined(MAGICKCORE_OPENMP_SUPPORT)
2760
2837
  #pragma omp parallel for schedule(dynamic,4) shared(status)
2761
2838
#endif
2762
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
2839
  for (y=0; y < (long) image->rows; y++)
2763
2840
  {
2764
2841
    register IndexPacket
2765
2842
      *restrict indexes;
2766
2843
 
2767
 
    register ssize_t
 
2844
    register long
2768
2845
      x;
2769
2846
 
2770
2847
    register PixelPacket
2778
2855
        status=MagickFalse;
2779
2856
        continue;
2780
2857
      }
2781
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
2858
    for (x=0; x < (long) image->columns; x++)
2782
2859
      *q++=pixel;
2783
2860
    if (image->colorspace == CMYKColorspace)
2784
2861
      {
2785
2862
        indexes=GetCacheViewAuthenticIndexQueue(image_view);
2786
 
        for (x=0; x < (ssize_t) image->columns; x++)
 
2863
        for (x=0; x < (long) image->columns; x++)
2787
2864
          indexes[x]=index;
2788
2865
      }
2789
2866
    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2798
2875
%                                                                             %
2799
2876
%                                                                             %
2800
2877
%                                                                             %
2801
 
%   S e t I m a g e C o l o r                                                 %
2802
 
%                                                                             %
2803
 
%                                                                             %
2804
 
%                                                                             %
2805
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2806
 
%
2807
 
%  SetImageColor() set the entire image canvas to the specified color.
2808
 
%
2809
 
%  The format of the SetImageColor method is:
2810
 
%
2811
 
%      MagickBooleanType SetImageColor(Image *image,
2812
 
%        const MagickPixelPacket *color)
2813
 
%
2814
 
%  A description of each parameter follows:
2815
 
%
2816
 
%    o image: the image.
2817
 
%
2818
 
%    o background: the image color.
2819
 
%
2820
 
*/
2821
 
MagickExport MagickBooleanType SetImageColor(Image *image,
2822
 
  const MagickPixelPacket *color)
2823
 
{
2824
 
  CacheView
2825
 
    *image_view;
2826
 
 
2827
 
  ExceptionInfo
2828
 
    *exception;
2829
 
 
2830
 
  ssize_t
2831
 
    y;
2832
 
 
2833
 
  MagickBooleanType
2834
 
    status;
2835
 
 
2836
 
  assert(image != (Image *) NULL);
2837
 
  if (image->debug != MagickFalse)
2838
 
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2839
 
  assert(image->signature == MagickSignature);
2840
 
  assert(color != (const MagickPixelPacket *) NULL);
2841
 
  image->colorspace=color->colorspace;
2842
 
  image->matte=color->matte;
2843
 
  image->fuzz=color->fuzz;
2844
 
  image->depth=color->depth;
2845
 
  status=MagickTrue;
2846
 
  exception=(&image->exception);
2847
 
  image_view=AcquireCacheView(image);
2848
 
#if defined(MAGICKCORE_OPENMP_SUPPORT)
2849
 
  #pragma omp parallel for schedule(dynamic,4) shared(status)
2850
 
#endif
2851
 
  for (y=0; y < (ssize_t) image->rows; y++)
2852
 
  {
2853
 
    register IndexPacket
2854
 
      *restrict indexes;
2855
 
 
2856
 
    register ssize_t
2857
 
      x;
2858
 
 
2859
 
    register PixelPacket
2860
 
      *restrict q;
2861
 
 
2862
 
    if (status == MagickFalse)
2863
 
      continue;
2864
 
    q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2865
 
    if (q == (PixelPacket *) NULL)
2866
 
      {
2867
 
        status=MagickFalse;
2868
 
        continue;
2869
 
      }
2870
 
    indexes=GetCacheViewAuthenticIndexQueue(image_view);
2871
 
    for (x=0; x < (ssize_t) image->columns; x++)
2872
 
    {
2873
 
      SetPixelPacket(image,color,q,indexes+x);
2874
 
      q++;
2875
 
    }
2876
 
    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2877
 
      status=MagickFalse;
2878
 
  }
2879
 
  image_view=DestroyCacheView(image_view);
2880
 
  return(status);
2881
 
}
2882
 
 
2883
 
/*
2884
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2885
 
%                                                                             %
2886
 
%                                                                             %
2887
 
%                                                                             %
2888
2878
%   S e t I m a g e S t o r a g e C l a s s                                   %
2889
2879
%                                                                             %
2890
2880
%                                                                             %
2986
2976
%  The format of the SetImageExtent method is:
2987
2977
%
2988
2978
%      MagickBooleanType SetImageExtent(Image *image,
2989
 
%        const size_t columns,const size_t rows)
 
2979
%        const unsigned long columns,const unsigned long rows)
2990
2980
%
2991
2981
%  A description of each parameter follows:
2992
2982
%
2998
2988
%
2999
2989
*/
3000
2990
MagickExport MagickBooleanType SetImageExtent(Image *image,
3001
 
  const size_t columns,const size_t rows)
 
2991
  const unsigned long columns,const unsigned long rows)
3002
2992
{
3003
2993
  Cache
3004
2994
    cache;
3104
3094
            }
3105
3095
          else
3106
3096
            {
3107
 
              size_t
 
3097
              unsigned long
3108
3098
                first,
3109
3099
                last;
3110
3100
 
3117
3107
                while ((isspace((int) ((unsigned char) *p)) != 0) ||
3118
3108
                       (*p == ','))
3119
3109
                  p++;
3120
 
                first=(size_t) strtol(p,&q,10);
 
3110
                first=(unsigned long) strtol(p,&q,10);
3121
3111
                last=first;
3122
3112
                while (isspace((int) ((unsigned char) *q)) != 0)
3123
3113
                  q++;
3124
3114
                if (*q == '-')
3125
 
                  last=(size_t) strtol(q+1,&q,10);
 
3115
                  last=(unsigned long) strtol(q+1,&q,10);
3126
3116
                if (first > last)
3127
3117
                  Swap(first,last);
3128
3118
                if (first < image_info->scene)
3172
3162
      MagickFormatType
3173
3163
        format_type;
3174
3164
 
3175
 
      register ssize_t
 
3165
      register long
3176
3166
        i;
3177
3167
 
3178
3168
      static const char
3507
3497
  ExceptionInfo
3508
3498
    *exception;
3509
3499
 
3510
 
  ssize_t
 
3500
  long
3511
3501
    y;
3512
3502
 
3513
3503
  MagickBooleanType
3524
3514
#if defined(MAGICKCORE_OPENMP_SUPPORT)
3525
3515
  #pragma omp parallel for schedule(dynamic,4) shared(status)
3526
3516
#endif
3527
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
3517
  for (y=0; y < (long) image->rows; y++)
3528
3518
  {
3529
 
    register ssize_t
 
3519
    register long
3530
3520
      x;
3531
3521
 
3532
3522
    register PixelPacket
3540
3530
        status=MagickFalse;
3541
3531
        continue;
3542
3532
      }
3543
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
3533
    for (x=0; x < (long) image->columns; x++)
3544
3534
    {
3545
3535
      SetOpacityPixelComponent(q,opacity);
3546
3536
      q++;
3824
3814
*/
3825
3815
 
3826
3816
static inline IndexPacket PushColormapIndex(Image *image,
3827
 
  const size_t index,MagickBooleanType *range_exception)
 
3817
  const unsigned long index,MagickBooleanType *range_exception)
3828
3818
{
3829
3819
  if (index < image->colors)
3830
3820
    return((IndexPacket) index);
3840
3830
  ExceptionInfo
3841
3831
    *exception;
3842
3832
 
3843
 
  ssize_t
 
3833
  long
3844
3834
    y;
3845
3835
 
3846
3836
  MagickBooleanType
3860
3850
#if defined(MAGICKCORE_OPENMP_SUPPORT)
3861
3851
  #pragma omp parallel for schedule(dynamic,4) shared(status)
3862
3852
#endif
3863
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
3853
  for (y=0; y < (long) image->rows; y++)
3864
3854
  {
3865
3855
    IndexPacket
3866
3856
      index;
3871
3861
    register IndexPacket
3872
3862
      *restrict indexes;
3873
3863
 
3874
 
    register ssize_t
 
3864
    register long
3875
3865
      x;
3876
3866
 
3877
3867
    register PixelPacket
3886
3876
        continue;
3887
3877
      }
3888
3878
    indexes=GetCacheViewAuthenticIndexQueue(image_view);
3889
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
3879
    for (x=0; x < (long) image->columns; x++)
3890
3880
    {
3891
 
      index=PushColormapIndex(image,(size_t) indexes[x],
 
3881
      index=PushColormapIndex(image,(unsigned long) indexes[x],
3892
3882
        &range_exception);
3893
 
      pixel=image->colormap[(ssize_t) index];
 
3883
      pixel=image->colormap[(long) index];
3894
3884
      q->red=pixel.red;
3895
3885
      q->green=pixel.green;
3896
3886
      q->blue=pixel.blue;
3897
 
      if (image->matte != MagickFalse)
3898
 
        q->opacity=pixel.opacity;
3899
3887
      q++;
3900
3888
    }
3901
3889
    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3971
3959
  MagickStatusType
3972
3960
    flags;
3973
3961
 
3974
 
  ResolutionType
3975
 
    units;
3976
 
 
3977
3962
  /*
3978
3963
    Sync image options.
3979
3964
  */
4030
4015
      flags=ParseGeometry(option,&geometry_info);
4031
4016
      if ((flags & GreaterValue) != 0)
4032
4017
        {
4033
 
          if (image->delay > (size_t) floor(geometry_info.rho+0.5))
4034
 
            image->delay=(size_t) floor(geometry_info.rho+0.5);
 
4018
          if (image->delay > (unsigned long) (geometry_info.rho+0.5))
 
4019
            image->delay=(unsigned long) (geometry_info.rho+0.5);
4035
4020
        }
4036
4021
      else
4037
4022
        if ((flags & LessValue) != 0)
4038
4023
          {
4039
 
            if (image->delay < (size_t) floor(geometry_info.rho+0.5))
4040
 
              image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
 
4024
            if (image->delay < (unsigned long) (geometry_info.rho+0.5))
 
4025
              image->ticks_per_second=(long) (geometry_info.sigma+0.5);
4041
4026
          }
4042
4027
        else
4043
 
          image->delay=(size_t) floor(geometry_info.rho+0.5);
 
4028
          image->delay=(unsigned long) (geometry_info.rho+0.5);
4044
4029
      if ((flags & SigmaValue) != 0)
4045
 
        image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
 
4030
        image->ticks_per_second=(long) (geometry_info.sigma+0.5);
4046
4031
    }
4047
4032
  option=GetImageOption(image_info,"density");
4048
4033
  if (option != (const char *) NULL)
4165
4150
      option);
4166
4151
  option=GetImageOption(image_info,"units");
4167
4152
  if (option != (const char *) NULL)
4168
 
    units=(ResolutionType) ParseMagickOption(MagickResolutionOptions,
 
4153
    image->units=(ResolutionType) ParseMagickOption(MagickResolutionOptions,
4169
4154
      MagickFalse,option);
4170
 
  else
4171
 
    units = image_info->units;
4172
 
  if (units != UndefinedResolution)
 
4155
  if (image_info->units != UndefinedResolution)
4173
4156
    {
4174
 
      if (image->units != units)
 
4157
      if (image->units != image_info->units)
4175
4158
        switch (image->units)
4176
4159
        {
4177
4160
          case PixelsPerInchResolution:
4178
4161
          {
4179
 
            if (units == PixelsPerCentimeterResolution)
 
4162
            if (image_info->units == PixelsPerCentimeterResolution)
4180
4163
              {
4181
4164
                image->x_resolution/=2.54;
4182
4165
                image->y_resolution/=2.54;
4185
4168
          }
4186
4169
          case PixelsPerCentimeterResolution:
4187
4170
          {
4188
 
            if (units == PixelsPerInchResolution)
 
4171
            if (image_info->units == PixelsPerInchResolution)
4189
4172
              {
4190
 
                image->x_resolution=(double) ((size_t) (100.0*2.54*
4191
 
                  image->x_resolution+0.5))/100.0;
4192
 
                image->y_resolution=(double) ((size_t) (100.0*2.54*
4193
 
                  image->y_resolution+0.5))/100.0;
 
4173
                image->x_resolution*=2.54;
 
4174
                image->y_resolution*=2.54;
4194
4175
              }
4195
4176
            break;
4196
4177
          }
4197
4178
          default:
4198
4179
            break;
4199
4180
        }
4200
 
      image->units=units;
 
4181
      image->units=image_info->units;
4201
4182
    }
4202
4183
  option=GetImageOption(image_info,"white-point");
4203
4184
  if (option != (const char *) NULL)