]> granicus.if.org Git - imagemagick/blobdiff - wand/magick-property.c
(no commit message)
[imagemagick] / wand / magick-property.c
index 3f7ff2d1ea37792c2cd1e9224b576fb24e3fdcdb..4bacb563517d9ec66deec214e7dbfb708f538c8e 100644 (file)
@@ -23,7 +23,7 @@
 %                                 August 2003                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -324,14 +324,14 @@ WandExport CompressionType MagickGetCompression(MagickWand *wand)
 %
 %  The format of the MagickGetCompressionQuality method is:
 %
-%      unsigned long MagickGetCompressionQuality(MagickWand *wand)
+%      size_t MagickGetCompressionQuality(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetCompressionQuality(MagickWand *wand)
+WandExport size_t MagickGetCompressionQuality(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -589,7 +589,7 @@ WandExport char *MagickGetImageArtifact(MagickWand *wand,const char *artifact)
 %  The format of the MagickGetImageArtifacts method is:
 %
 %      char *MagickGetImageArtifacts(MagickWand *wand,
-%        const char *pattern,unsigned long *number_artifacts)
+%        const char *pattern,size_t *number_artifacts)
 %
 %  A description of each parameter follows:
 %
@@ -601,7 +601,7 @@ WandExport char *MagickGetImageArtifact(MagickWand *wand,const char *artifact)
 %
 */
 WandExport char **MagickGetImageArtifacts(MagickWand *wand,
-  const char *pattern,unsigned long *number_artifacts)
+  const char *pattern,size_t *number_artifacts)
 {
   char
     **artifacts;
@@ -609,7 +609,7 @@ WandExport char **MagickGetImageArtifacts(MagickWand *wand,
   const char
     *artifact;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -637,7 +637,7 @@ WandExport char **MagickGetImageArtifacts(MagickWand *wand,
     if ((*artifact != '[') &&
         (GlobExpression(artifact,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             artifacts=(char **) ResizeQuantumMemory(artifacts,length,
@@ -656,7 +656,7 @@ WandExport char **MagickGetImageArtifacts(MagickWand *wand,
     artifact=GetNextImageProperty(wand->images);
   }
   artifacts[i]=(char *) NULL;
-  *number_artifacts=(unsigned long) i;
+  *number_artifacts=(size_t) i;
   return(artifacts);
 }
 \f
@@ -718,7 +718,7 @@ WandExport unsigned char *MagickGetImageProfile(MagickWand *wand,
     return((unsigned char *) NULL);
   (void) CopyMagickMemory(datum,GetStringInfoDatum(profile),
     GetStringInfoLength(profile));
-  *length=(unsigned long) GetStringInfoLength(profile);
+  *length=(size_t) GetStringInfoLength(profile);
   return(datum);
 }
 \f
@@ -741,7 +741,7 @@ WandExport unsigned char *MagickGetImageProfile(MagickWand *wand,
 %  The format of the MagickGetImageProfiles method is:
 %
 %      char *MagickGetImageProfiles(MagickWand *wand,
-%        unsigned long *number_profiles)
+%        size_t *number_profiles)
 %
 %  A description of each parameter follows:
 %
@@ -753,7 +753,7 @@ WandExport unsigned char *MagickGetImageProfile(MagickWand *wand,
 %
 */
 WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
-  unsigned long *number_profiles)
+  size_t *number_profiles)
 {
   char
     **profiles;
@@ -761,7 +761,7 @@ WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
   const char
     *property;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -789,7 +789,7 @@ WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
     if ((*property != '[') &&
         (GlobExpression(property,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             profiles=(char **) ResizeQuantumMemory(profiles,length,
@@ -808,7 +808,7 @@ WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
     property=GetNextImageProfile(wand->images);
   }
   profiles[i]=(char *) NULL;
-  *number_profiles=(unsigned long) i;
+  *number_profiles=(size_t) i;
   return(profiles);
 }
 \f
@@ -878,7 +878,7 @@ WandExport char *MagickGetImageProperty(MagickWand *wand,const char *property)
 %  The format of the MagickGetImageProperties method is:
 %
 %      char *MagickGetImageProperties(MagickWand *wand,
-%        const char *pattern,unsigned long *number_properties)
+%        const char *pattern,size_t *number_properties)
 %
 %  A description of each parameter follows:
 %
@@ -890,7 +890,7 @@ WandExport char *MagickGetImageProperty(MagickWand *wand,const char *property)
 %
 */
 WandExport char **MagickGetImageProperties(MagickWand *wand,
-  const char *pattern,unsigned long *number_properties)
+  const char *pattern,size_t *number_properties)
 {
   char
     **properties;
@@ -898,7 +898,7 @@ WandExport char **MagickGetImageProperties(MagickWand *wand,
   const char
     *property;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -926,7 +926,7 @@ WandExport char **MagickGetImageProperties(MagickWand *wand,
     if ((*property != '[') &&
         (GlobExpression(property,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             properties=(char **) ResizeQuantumMemory(properties,length,
@@ -945,7 +945,7 @@ WandExport char **MagickGetImageProperties(MagickWand *wand,
     property=GetNextImageProperty(wand->images);
   }
   properties[i]=(char *) NULL;
-  *number_properties=(unsigned long) i;
+  *number_properties=(size_t) i;
   return(properties);
 }
 \f
@@ -1079,7 +1079,7 @@ WandExport char *MagickGetOption(MagickWand *wand,const char *key)
 %
 %  The format of the MagickGetOptions method is:
 %
-%      char *MagickGetOptions(MagickWand *wand,unsigned long *number_options)
+%      char *MagickGetOptions(MagickWand *wand,size_t *number_options)
 %
 %  A description of each parameter follows:
 %
@@ -1091,7 +1091,7 @@ WandExport char *MagickGetOption(MagickWand *wand,const char *key)
 %
 */
 WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
-  unsigned long *number_options)
+  size_t *number_options)
 {
   char
     **options;
@@ -1099,7 +1099,7 @@ WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
   const char
     *option;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1126,7 +1126,7 @@ WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
     if ((*option != '[') &&
         (GlobExpression(option,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             options=(char **) ResizeQuantumMemory(options,length,
@@ -1145,7 +1145,7 @@ WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
     option=GetNextImageOption(wand->image_info);
   }
   options[i]=(char *) NULL;
-  *number_options=(unsigned long) i;
+  *number_options=(size_t) i;
   return(options);
 }
 \f
@@ -1221,7 +1221,7 @@ WandExport const char *MagickGetPackageName(void)
 %  The format of the MagickGetPage method is:
 %
 %      MagickBooleanType MagickGetPage(const MagickWand *wand,
-%        unsigned long *width,unsigned long *height,long *x,long *y)
+%        size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 %
 %  A description of each parameter follows:
 %
@@ -1237,7 +1237,7 @@ WandExport const char *MagickGetPackageName(void)
 %
 */
 WandExport MagickBooleanType MagickGetPage(const MagickWand *wand,
-  unsigned long *width,unsigned long *height,long *x,long *y)
+  size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 {
   RectangleInfo
     geometry;
@@ -1303,14 +1303,14 @@ WandExport double MagickGetPointsize(MagickWand *wand)
 %
 %  The format of the MagickGetQuantumDepth method is:
 %
-%      const char *MagickGetQuantumDepth(unsigned long *depth)
+%      const char *MagickGetQuantumDepth(size_t *depth)
 %
 %  A description of each parameter follows:
 %
 %    o depth: the quantum depth is returned as a number.
 %
 */
-WandExport const char *MagickGetQuantumDepth(unsigned long *depth)
+WandExport const char *MagickGetQuantumDepth(size_t *depth)
 {
   return(GetMagickQuantumDepth(depth));
 }
@@ -1331,14 +1331,14 @@ WandExport const char *MagickGetQuantumDepth(unsigned long *depth)
 %
 %  The format of the MagickGetQuantumRange method is:
 %
-%      const char *MagickGetQuantumRange(unsigned long *range)
+%      const char *MagickGetQuantumRange(size_t *range)
 %
 %  A description of each parameter follows:
 %
 %    o range: the quantum range is returned as a number.
 %
 */
-WandExport const char *MagickGetQuantumRange(unsigned long *range)
+WandExport const char *MagickGetQuantumRange(size_t *range)
 {
   return(GetMagickQuantumRange(range));
 }
@@ -1372,6 +1372,59 @@ WandExport const char *MagickGetReleaseDate(void)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   M a g i c k G e t R e s o l u t i o n                                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickGetResolution() gets the image X and Y resolution.
+%
+%  The format of the MagickGetResolution method is:
+%
+%      MagickBooleanType MagickGetResolution(const MagickWand *wand,double *x,
+%        double *y)
+%
+%  A description of each parameter follows:
+%
+%    o wand: the magick wand.
+%
+%    o x: the x-resolution.
+%
+%    o y: the y-resolution.
+%
+*/
+WandExport MagickBooleanType MagickGetResolution(const MagickWand *wand,
+  double *x,double *y)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == WandSignature);
+  if (wand->debug != MagickFalse)
+    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
+  *x=72.0;
+  *y=72.0;
+  if (wand->image_info->density != (char *) NULL)
+    {
+      GeometryInfo
+        geometry_info;
+
+      MagickStatusType
+        flags;
+
+      flags=ParseGeometry(wand->image_info->density,&geometry_info);
+      *x=geometry_info.rho;
+      *y=geometry_info.sigma;
+      if ((flags & SigmaValue) == MagickFalse)
+        *y=(*x);
+    }
+  return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k G e t R e s o u r c e                                         %
 %                                                                             %
 %                                                                             %
@@ -1437,7 +1490,7 @@ WandExport MagickSizeType MagickGetResourceLimit(const ResourceType type)
 %  The format of the MagickGetSamplingFactors method is:
 %
 %      double *MagickGetSamplingFactor(MagickWand *wand,
-%        unsigned long *number_factors)
+%        size_t *number_factors)
 %
 %  A description of each parameter follows:
 %
@@ -1447,7 +1500,7 @@ WandExport MagickSizeType MagickGetResourceLimit(const ResourceType type)
 %
 */
 WandExport double *MagickGetSamplingFactors(MagickWand *wand,
-  unsigned long *number_factors)
+  size_t *number_factors)
 {
   double
     *sampling_factors;
@@ -1455,7 +1508,7 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (MagickWand *) NULL);
@@ -1488,7 +1541,7 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
     sampling_factors[i]=StringToDouble(p);
     i++;
   }
-  *number_factors=(unsigned long) i;
+  *number_factors=(size_t) i;
   return(sampling_factors);
 }
 \f
@@ -1508,7 +1561,7 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
 %  The format of the MagickGetSize method is:
 %
 %      MagickBooleanType MagickGetSize(const MagickWand *wand,
-%        unsigned long *columns,unsigned long *rows)
+%        size_t *columns,size_t *rows)
 %
 %  A description of each parameter follows:
 %
@@ -1520,7 +1573,7 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickGetSize(const MagickWand *wand,
-  unsigned long *columns,unsigned long *rows)
+  size_t *columns,size_t *rows)
 {
   RectangleInfo
     geometry;
@@ -1553,7 +1606,7 @@ WandExport MagickBooleanType MagickGetSize(const MagickWand *wand,
 %  The format of the MagickGetSizeOffset method is:
 %
 %      MagickBooleanType MagickGetSizeOffset(const MagickWand *wand,
-%        long *offset)
+%        ssize_t *offset)
 %
 %  A description of each parameter follows:
 %
@@ -1563,7 +1616,7 @@ WandExport MagickBooleanType MagickGetSize(const MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickGetSizeOffset(const MagickWand *wand,
-  long *offset)
+  ssize_t *offset)
 {
   RectangleInfo
     geometry;
@@ -1625,14 +1678,14 @@ WandExport ImageType MagickGetType(MagickWand *wand)
 %
 %  The format of the MagickGetVersion method is:
 %
-%      const char *MagickGetVersion(unsigned long *version)
+%      const char *MagickGetVersion(size_t *version)
 %
 %  A description of each parameter follows:
 %
 %    o version: the ImageMagick version is returned as a number.
 %
 */
-WandExport const char *MagickGetVersion(unsigned long *version)
+WandExport const char *MagickGetVersion(size_t *version)
 {
   return(GetMagickVersion(version));
 }
@@ -1908,7 +1961,7 @@ WandExport MagickBooleanType MagickSetCompression(MagickWand *wand,
 %  The format of the MagickSetCompressionQuality method is:
 %
 %      MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
-%        const unsigned long quality)
+%        const size_t quality)
 %
 %  A description of each parameter follows:
 %
@@ -1918,7 +1971,7 @@ WandExport MagickBooleanType MagickSetCompression(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
-  const unsigned long quality)
+  const size_t quality)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -1944,7 +1997,7 @@ WandExport MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
 %  The format of the MagickSetDepth method is:
 %
 %      MagickBooleanType MagickSetDepth(MagickWand *wand,
-%        const unsigned long depth)
+%        const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -1954,7 +2007,7 @@ WandExport MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetDepth(MagickWand *wand,
-  const unsigned long depth)
+  const size_t depth)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -2159,7 +2212,7 @@ WandExport MagickBooleanType MagickSetGravity(MagickWand *wand,
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   status=SetImageOption(wand->image_info,"gravity",MagickOptionToMnemonic(
-    MagickGravityOptions,(long) type));
+    MagickGravityOptions,(ssize_t) type));
   return(status);
 }
 \f
@@ -2382,7 +2435,7 @@ WandExport MagickBooleanType MagickSetInterpolateMethod(MagickWand *wand,
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   status=SetImageOption(wand->image_info,"interpolate",
-    MagickOptionToMnemonic(MagickInterpolateOptions,(long) method));
+    MagickOptionToMnemonic(MagickInterpolateOptions,(ssize_t) method));
   return(status);
 }
 \f
@@ -2476,8 +2529,8 @@ WandExport MagickBooleanType MagickSetOrientation(MagickWand *wand,
 %  The format of the MagickSetPage method is:
 %
 %      MagickBooleanType MagickSetPage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -2493,8 +2546,8 @@ WandExport MagickBooleanType MagickSetOrientation(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetPage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   char
     geometry[MaxTextExtent];
@@ -2503,8 +2556,8 @@ WandExport MagickBooleanType MagickSetPage(MagickWand *wand,
   assert(wand->signature == WandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-  (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
-    width,height,x,y);
+  (void) FormatMagickString(geometry,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
+    (double) width,(double) height,(double) x,(double) y);
   (void) CloneString(&wand->image_info->page,geometry);
   return(MagickTrue);
 }
@@ -2725,7 +2778,7 @@ WandExport MagickBooleanType MagickSetResolution(MagickWand *wand,
 %  The format of the MagickSetSamplingFactors method is:
 %
 %      MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
-%        const unsigned long number_factors,const double *sampling_factors)
+%        const size_t number_factors,const double *sampling_factors)
 %
 %  A description of each parameter follows:
 %
@@ -2738,12 +2791,12 @@ WandExport MagickBooleanType MagickSetResolution(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
-  const unsigned long number_factors,const double *sampling_factors)
+  const size_t number_factors,const double *sampling_factors)
 {
   char
     sampling_factor[MaxTextExtent];
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (MagickWand *) NULL);
@@ -2755,7 +2808,7 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
       RelinquishMagickMemory(wand->image_info->sampling_factor);
   if (number_factors == 0)
     return(MagickTrue);
-  for (i=0; i < (long) (number_factors-1); i++)
+  for (i=0; i < (ssize_t) (number_factors-1); i++)
   {
     (void) FormatMagickString(sampling_factor,MaxTextExtent,"%g,",
       sampling_factors[i]);
@@ -2785,7 +2838,7 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
 %  The format of the MagickSetSize method is:
 %
 %      MagickBooleanType MagickSetSize(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2797,7 +2850,7 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   char
     geometry[MaxTextExtent];
@@ -2806,7 +2859,8 @@ WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
   assert(wand->signature == WandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-  (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu",columns,rows);
+  (void) FormatMagickString(geometry,MaxTextExtent,"%.20gx%.20g",(double)
+    columns,(double) rows);
   (void) CloneString(&wand->image_info->size,geometry);
   return(MagickTrue);
 }
@@ -2828,8 +2882,8 @@ WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
 %  The format of the MagickSetSizeOffset method is:
 %
 %      MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,
-%        const long offset)
+%        const size_t columns,const size_t rows,
+%        const ssize_t offset)
 %
 %  A description of each parameter follows:
 %
@@ -2843,7 +2897,7 @@ WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows,const long offset)
+  const size_t columns,const size_t rows,const ssize_t offset)
 {
   char
     geometry[MaxTextExtent];
@@ -2852,8 +2906,8 @@ WandExport MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
   assert(wand->signature == WandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-  (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld",columns,rows,
-    offset);
+  (void) FormatMagickString(geometry,MaxTextExtent,"%.20gx%.20g%+.20g",
+    (double) columns,(double) rows,(double) offset);
   (void) CloneString(&wand->image_info->size,geometry);
   return(MagickTrue);
 }