~ubuntu-branches/ubuntu/precise/imagemagick/precise

« back to all changes in this revision

Viewing changes to magick/color.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:
85
85
    blue,
86
86
    alpha;
87
87
 
88
 
  const ssize_t
 
88
  const long
89
89
    compliance;
90
90
} ColorMapInfo;
91
91
 
1085
1085
%  The format of the GetColorInfoList function is:
1086
1086
%
1087
1087
%      const ColorInfo **GetColorInfoList(const char *pattern,
1088
 
%        size_t *number_colors,ExceptionInfo *exception)
 
1088
%        unsigned long *number_colors,ExceptionInfo *exception)
1089
1089
%
1090
1090
%  A description of each parameter follows:
1091
1091
%
1119
1119
#endif
1120
1120
 
1121
1121
MagickExport const ColorInfo **GetColorInfoList(const char *pattern,
1122
 
  size_t *number_colors,ExceptionInfo *exception)
 
1122
  unsigned long *number_colors,ExceptionInfo *exception)
1123
1123
{
1124
1124
  const ColorInfo
1125
1125
    **colors;
1127
1127
  register const ColorInfo
1128
1128
    *p;
1129
1129
 
1130
 
  register ssize_t
 
1130
  register long
1131
1131
    i;
1132
1132
 
1133
1133
  /*
1135
1135
  */
1136
1136
  assert(pattern != (char *) NULL);
1137
1137
  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1138
 
  assert(number_colors != (size_t *) NULL);
 
1138
  assert(number_colors != (unsigned long *) NULL);
1139
1139
  *number_colors=0;
1140
1140
  p=GetColorInfo("*",exception);
1141
1141
  if (p == (const ColorInfo *) NULL)
1160
1160
  UnlockSemaphoreInfo(color_semaphore);
1161
1161
  qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
1162
1162
  colors[i]=(ColorInfo *) NULL;
1163
 
  *number_colors=(size_t) i;
 
1163
  *number_colors=(unsigned long) i;
1164
1164
  return(colors);
1165
1165
}
1166
1166
 
1179
1179
%
1180
1180
%  The format of the GetColorList function is:
1181
1181
%
1182
 
%      char **GetColorList(const char *pattern,size_t *number_colors,
 
1182
%      char **GetColorList(const char *pattern,unsigned long *number_colors,
1183
1183
%        ExceptionInfo *exception)
1184
1184
%
1185
1185
%  A description of each parameter follows:
1212
1212
#endif
1213
1213
 
1214
1214
MagickExport char **GetColorList(const char *pattern,
1215
 
  size_t *number_colors,ExceptionInfo *exception)
 
1215
  unsigned long *number_colors,ExceptionInfo *exception)
1216
1216
{
1217
1217
  char
1218
1218
    **colors;
1220
1220
  register const ColorInfo
1221
1221
    *p;
1222
1222
 
1223
 
  register ssize_t
 
1223
  register long
1224
1224
    i;
1225
1225
 
1226
1226
  /*
1228
1228
  */
1229
1229
  assert(pattern != (char *) NULL);
1230
1230
  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1231
 
  assert(number_colors != (size_t *) NULL);
 
1231
  assert(number_colors != (unsigned long *) NULL);
1232
1232
  *number_colors=0;
1233
1233
  p=GetColorInfo("*",exception);
1234
1234
  if (p == (const ColorInfo *) NULL)
1253
1253
  UnlockSemaphoreInfo(color_semaphore);
1254
1254
  qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
1255
1255
  colors[i]=(char *) NULL;
1256
 
  *number_colors=(size_t) i;
 
1256
  *number_colors=(unsigned long) i;
1257
1257
  return(colors);
1258
1258
}
1259
1259
 
1329
1329
  if (pixel->depth > 32)
1330
1330
    {
1331
1331
      (void) FormatMagickString(component,MaxTextExtent,"%08lX",
1332
 
        (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
 
1332
        ScaleQuantumToLong(ClampToQuantum(color)));
1333
1333
      (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1334
1334
      return;
1335
1335
    }
1404
1404
        color.depth=8;
1405
1405
    }
1406
1406
  (void) ConcatenateMagickString(tuple,MagickOptionToMnemonic(
1407
 
    MagickColorspaceOptions,(ssize_t) color.colorspace),MaxTextExtent);
 
1407
    MagickColorspaceOptions,(long) color.colorspace),MaxTextExtent);
1408
1408
  if (color.matte != MagickFalse)
1409
1409
    (void) ConcatenateMagickString(tuple,"a",MaxTextExtent);
1410
1410
  (void) ConcatenateMagickString(tuple,"(",MaxTextExtent);
1562
1562
%  The format of the IsImageSimilar method is:
1563
1563
%
1564
1564
%      MagickBooleanType IsImageSimilar(const Image *image,
1565
 
%        const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
 
1565
%        const Image *target_image,long *x_offset,long *y_offset,
1566
1566
%        ExceptionInfo *exception)
1567
1567
%
1568
1568
%  A description of each parameter follows:
1581
1581
%
1582
1582
*/
1583
1583
MagickExport MagickBooleanType IsImageSimilar(const Image *image,
1584
 
  const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
 
1584
  const Image *target_image,long *x_offset,long *y_offset,
1585
1585
  ExceptionInfo *exception)
1586
1586
{
1587
1587
#define SearchImageText  "  Searching image...  "
1590
1590
    *image_view,
1591
1591
    *target_view;
1592
1592
 
1593
 
  ssize_t
 
1593
  long
1594
1594
    j,
1595
1595
    y;
1596
1596
 
1609
1609
    *indexes,
1610
1610
    *target_indexes;
1611
1611
 
1612
 
  register ssize_t
 
1612
  register long
1613
1613
    i,
1614
1614
    x;
1615
1615
 
1619
1619
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1620
1620
  assert(target_image != (Image *) NULL);
1621
1621
  assert(target_image->signature == MagickSignature);
1622
 
  assert(x_offset != (ssize_t *) NULL);
1623
 
  assert(y_offset != (ssize_t *) NULL);
 
1622
  assert(x_offset != (long *) NULL);
 
1623
  assert(y_offset != (long *) NULL);
1624
1624
  assert(exception != (ExceptionInfo *) NULL);
1625
1625
  x=0;
1626
1626
  GetMagickPixelPacket(image,&pixel);
1627
1627
  GetMagickPixelPacket(image,&target);
1628
1628
  image_view=AcquireCacheView(image);
1629
1629
  target_view=AcquireCacheView(target_image);
1630
 
  for (y=(*y_offset); y < (ssize_t) image->rows; y++)
 
1630
  for (y=(*y_offset); y < (long) image->rows; y++)
1631
1631
  {
1632
 
    for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
 
1632
    for (x=y == 0 ? *x_offset : 0; x < (long) image->columns; x++)
1633
1633
    {
1634
 
      for (j=0; j < (ssize_t) target_image->rows; j++)
 
1634
      for (j=0; j < (long) target_image->rows; j++)
1635
1635
      {
1636
 
        for (i=0; i < (ssize_t) target_image->columns; i++)
 
1636
        for (i=0; i < (long) target_image->columns; i++)
1637
1637
        {
1638
1638
          p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
1639
1639
          indexes=GetCacheViewVirtualIndexQueue(image_view);
1644
1644
          if (IsMagickColorSimilar(&pixel,&target) == MagickFalse)
1645
1645
            break;
1646
1646
        }
1647
 
        if (i < (ssize_t) target_image->columns)
 
1647
        if (i < (long) target_image->columns)
1648
1648
          break;
1649
1649
      }
1650
 
      if (j == (ssize_t) target_image->rows)
 
1650
      if (j == (long) target_image->rows)
1651
1651
        break;
1652
1652
    }
1653
 
    if (x < (ssize_t) image->columns)
 
1653
    if (x < (long) image->columns)
1654
1654
      break;
1655
1655
    if (image->progress_monitor != (MagickProgressMonitor) NULL)
1656
1656
      {
1657
1657
        MagickBooleanType
1658
1658
          proceed;
1659
1659
 
1660
 
        proceed=SetImageProgress(image,SearchImageText,(MagickOffsetType) y,
1661
 
          image->rows);
 
1660
        proceed=SetImageProgress(image,SearchImageText,y,image->rows);
1662
1661
        if (proceed == MagickFalse)
1663
1662
          status=MagickFalse;
1664
1663
      }
1667
1666
  image_view=DestroyCacheView(image_view);
1668
1667
  *x_offset=x;
1669
1668
  *y_offset=y;
1670
 
  return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
 
1669
  return(y < (long) image->rows ? MagickTrue : MagickFalse);
1671
1670
}
1672
1671
 
1673
1672
/*
1851
1850
  const ColorInfo
1852
1851
    **color_info;
1853
1852
 
1854
 
  register ssize_t
 
1853
  register long
1855
1854
    i;
1856
1855
 
1857
 
  size_t
 
1856
  unsigned long
1858
1857
    number_colors;
1859
1858
 
1860
1859
  /*
1866
1865
  if (color_info == (const ColorInfo **) NULL)
1867
1866
    return(MagickFalse);
1868
1867
  path=(const char *) NULL;
1869
 
  for (i=0; i < (ssize_t) number_colors; i++)
 
1868
  for (i=0; i < (long) number_colors; i++)
1870
1869
  {
1871
1870
    if (color_info[i]->stealth != MagickFalse)
1872
1871
      continue;
1914
1913
%  The format of the LoadColorList method is:
1915
1914
%
1916
1915
%      MagickBooleanType LoadColorList(const char *xml,const char *filename,
1917
 
%        const size_t depth,ExceptionInfo *exception)
 
1916
%        const unsigned long depth,ExceptionInfo *exception)
1918
1917
%
1919
1918
%  A description of each parameter follows:
1920
1919
%
1928
1927
%
1929
1928
*/
1930
1929
static MagickBooleanType LoadColorList(const char *xml,const char *filename,
1931
 
  const size_t depth,ExceptionInfo *exception)
 
1930
  const unsigned long depth,ExceptionInfo *exception)
1932
1931
{
1933
1932
  char
1934
1933
    keyword[MaxTextExtent],
2074
2073
          }
2075
2074
        if (LocaleCompare((char *) keyword,"compliance") == 0)
2076
2075
          {
2077
 
            ssize_t
 
2076
            long
2078
2077
              compliance;
2079
2078
 
2080
2079
            compliance=color_info->compliance;
2158
2157
  MagickStatusType
2159
2158
    status;
2160
2159
 
2161
 
  register ssize_t
 
2160
  register long
2162
2161
    i;
2163
2162
 
2164
2163
  /*
2176
2175
        }
2177
2176
    }
2178
2177
  scale=(MagickRealType) ScaleCharToQuantum(1);
2179
 
  for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
 
2178
  for (i=0; i < (long) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
2180
2179
  {
2181
2180
    ColorInfo
2182
2181
      *color_info;
2371
2370
  GeometryInfo
2372
2371
    geometry_info;
2373
2372
 
2374
 
  ssize_t
 
2373
  long
2375
2374
    type;
2376
2375
 
2377
2376
  MagickRealType
2383
2382
  register const ColorInfo
2384
2383
    *p;
2385
2384
 
2386
 
  register ssize_t
 
2385
  register long
2387
2386
    i;
2388
2387
 
2389
2388
  /*
2408
2407
      QuantumAny
2409
2408
        range;
2410
2409
 
2411
 
      size_t
 
2410
      unsigned long
2412
2411
        depth,
2413
2412
        n;
2414
2413
 
2425
2424
            pixel.red=pixel.green;
2426
2425
            pixel.green=pixel.blue;
2427
2426
            pixel.blue=0;
2428
 
            for (i=(ssize_t) (n/3-1); i >= 0; i--)
 
2427
            for (i=(long) (n/3-1); i >= 0; i--)
2429
2428
            {
2430
2429
              c=(*name++);
2431
2430
              pixel.blue<<=4;
2457
2456
            pixel.green=pixel.blue;
2458
2457
            pixel.blue=pixel.opacity;
2459
2458
            pixel.opacity=0;
2460
 
            for (i=(ssize_t) (n/4-1); i >= 0; i--)
 
2459
            for (i=(long) (n/4-1); i >= 0; i--)
2461
2460
            {
2462
2461
              c=(*name++);
2463
2462
              pixel.opacity<<=4;
2657
2656
  if (compliance == XPMCompliance)
2658
2657
    {
2659
2658
      pixel.matte=MagickFalse;
2660
 
      pixel.depth=(size_t) MagickMin(1.0*image->depth,16.0);
 
2659
      pixel.depth=(unsigned long) MagickMin(1.0*image->depth,16.0);
2661
2660
      GetColorTuple(&pixel,MagickTrue,name);
2662
2661
      return(MagickTrue);
2663
2662
    }