ext/RMagick/rmutil.c in rmagick-1.9.0 vs ext/RMagick/rmutil.c in rmagick-1.9.1
- old
+ new
@@ -1,6 +1,6 @@
-/* $Id: rmutil.c,v 1.53 2005/06/21 22:55:01 rmagick Exp $ */
+/* $Id: rmutil.c,v 1.57 2005/09/07 21:51:45 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2005 by Timothy P. Hunter
| Name: rmutil.c
| Author: Tim Hunter
| Purpose: Utility functions for RMagick
@@ -9,11 +9,11 @@
#include "rmagick.h"
#include <errno.h>
static const char *Compliance_Const_Name(ComplianceType *);
static const char *StyleType_Const_Name(StyleType);
-static const char *StretchType_Const_Name(StretchType);
+static const char *StretchType_name(StretchType);
static void Color_Name_to_PixelPacket(PixelPacket *, VALUE);
static VALUE Enum_type_values(VALUE);
static VALUE Enum_type_inspect(VALUE);
/*
@@ -189,11 +189,11 @@
* Purpose: called when `rb_str_to_str' raised an exception below
*/
static VALUE
rescue_not_str(VALUE arg)
{
- rb_raise(rb_eArgError, "argument must be a number or a string in the form 'NN%' (%s given)",
+ rb_raise(rb_eTypeError, "argument must be a number or a string in the form 'NN%' (%s given)",
rb_class2name(CLASS_OF(arg)));
}
/*
* Extern: rm_percentage(obj)
@@ -1072,11 +1072,198 @@
compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
name = Compliance_Const_Name(&compliance);
return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
}
+
/*
+ External: CompositeOperator_new
+ Purpose: Construct a CompositeOperator enum object for the specified value
+*/
+VALUE
+CompositeOperator_new(CompositeOperator op)
+{
+ const char *name;
+
+ switch (op)
+ {
+ default:
+ case UndefinedCompositeOp:
+ name = "UndefinedCompositeOp";
+ break;
+ case NoCompositeOp:
+ name = "NoCompositeOp";
+ break;
+ case AddCompositeOp:
+ name = "AddCompositeOp";
+ break;
+ case AtopCompositeOp:
+ name = "AtopCompositeOp";
+ break;
+ case BumpmapCompositeOp:
+ name = "BumpmapCompositeOp";
+ break;
+ case ClearCompositeOp:
+ name = "ClearCompositeOp";
+ break;
+#if defined(HAVE_COLORDODGECOMPOSITEOP)
+ case ColorBurnCompositeOp:
+ name = "ColorBurnCompositeOp";
+ break;
+ case BlendCompositeOp:
+ name = "BlendCompositeOp";
+ break;
+ case ColorDodgeCompositeOp:
+ name = "ColorDodgeCompositeOp";
+ break;
+ case ExclusionCompositeOp:
+ name = "ExclusionCompositeOp";
+ break;
+ case HardLightCompositeOp:
+ name = "HardLightCompositeOp";
+ break;
+ case SoftLightCompositeOp:
+ name = "SoftLightCompositeOp";
+ break;
+#endif
+ case ColorizeCompositeOp:
+ name = "ColorizeCompositeOp";
+ break;
+ case CopyBlueCompositeOp:
+ name = "CopyBlueCompositeOp";
+ break;
+ case CopyCompositeOp:
+ name = "CopyCompositeOp";
+ break;
+#if defined(HAVE_COPYCYANCOMPOSITEOP) // CYMK added 5.5.7
+ case CopyCyanCompositeOp:
+ name = "CopyCyanCompositeOp";
+ break;
+ case CopyMagentaCompositeOp:
+ name = "CopyMagentaCompositeOp";
+ break;
+ case CopyYellowCompositeOp:
+ name = "CopyYellowCompositeOp";
+ break;
+ case CopyBlackCompositeOp:
+ name = "CopyBlackCompositeOp";
+ break;
+#endif
+ case CopyGreenCompositeOp:
+ name = "CopyGreenCompositeOp";
+ break;
+ case CopyOpacityCompositeOp:
+ name = "CopyOpacityCompositeOp";
+ break;
+ case CopyRedCompositeOp:
+ name = "CopyRedCompositeOp";
+ break;
+ case DarkenCompositeOp:
+ name = "DarkenCompositeOp";
+ break;
+#if defined(HAVE_DSTCOMPOSITEOP)
+ case DstAtopCompositeOp:
+ name = "DstAtopCompositeOp";
+ break;
+ case DstCompositeOp:
+ name = "DstCompositeOp";
+ break;
+ case DstInCompositeOp:
+ name = "DstInCompositeOp";
+ break;
+ case DstOutCompositeOp:
+ name = "DstOutCompositeOp";
+ break;
+ case DstOverCompositeOp:
+ name = "DstOverCompositeOp";
+ break;
+#endif
+ case DifferenceCompositeOp:
+ name = "DifferenceCompositeOp";
+ break;
+ case DisplaceCompositeOp:
+ name = "DisplaceCompositeOp";
+ break;
+ case DissolveCompositeOp:
+ name = "DissolveCompositeOp";
+ break;
+ case HueCompositeOp:
+ name = "HueCompositeOp";
+ break;
+ case InCompositeOp:
+ name = "InCompositeOp";
+ break;
+ case LightenCompositeOp:
+ name = "LightenCompositeOp";
+ break;
+ case LuminizeCompositeOp:
+ name = "LuminizeCompositeOp";
+ break;
+ case MinusCompositeOp:
+ name = "MinusCompositeOp";
+ break;
+ case ModulateCompositeOp:
+ name = "ModulateCompositeOp";
+ break;
+ case MultiplyCompositeOp:
+ name = "MultiplyCompositeOp";
+ break;
+ case OutCompositeOp:
+ name = "OutCompositeOp";
+ break;
+ case OverCompositeOp:
+ name = "OverCompositeOp";
+ break;
+ case OverlayCompositeOp:
+ name = "OverlayCompositeOp";
+ break;
+ case PlusCompositeOp:
+ name = "PlusCompositeOp";
+ break;
+#if defined(HAVE_REPLACECOMPOSITEOP) // Added 5.5.8
+ case ReplaceCompositeOp:
+ name = "ReplaceCompositeOp";
+ break;
+#endif
+ case SaturateCompositeOp:
+ name = "SaturateCompositeOp";
+ break;
+ case ScreenCompositeOp:
+ name = "ScreenCompositeOp";
+ break;
+#if defined(HAVE_DSTCOMPOSITEOP)
+ case SrcAtopCompositeOp:
+ name = "SrcAtopCompositeOp";
+ break;
+ case SrcCompositeOp:
+ name = "SrcCompositeOp";
+ break;
+ case SrcInCompositeOp:
+ name = "SrcInCompositeOp";
+ break;
+ case SrcOutCompositeOp:
+ name = "SrcOutCompositeOp";
+ break;
+ case SrcOverCompositeOp:
+ name = "SrcOverCompositeOp";
+ break;
+#endif
+ case SubtractCompositeOp:
+ name = "SubtractCompositeOp";
+ break;
+ case ThresholdCompositeOp:
+ name = "ThresholdCompositeOp";
+ break;
+ case XorCompositeOp:
+ name = "XorCompositeOp";
+ break;
+ }
+
+ return rm_enum_new(Class_CompositeOperator, ID2SYM(rb_intern(name)), INT2FIX(op));
+}
+
+/*
* External: CompressionType_new
Purpose: Construct a CompressionTYpe enum object for the specified value
*/
VALUE
CompressionType_new(CompressionType ct)
@@ -1120,11 +1307,40 @@
return rm_enum_new(Class_CompressionType, ID2SYM(rb_intern(name)), INT2FIX(ct));
}
/*
- External: FilterTypes#new
+ External: DisposeType.new
+ Purpose: Construct a DisposeType enum object for the specified value..new
+*/
+VALUE
+DisposeType_new(DisposeType type)
+{
+ const char *name;
+
+ switch(type)
+ {
+ default:
+ case UndefinedDispose:
+ name = "UndefinedDispose";
+ break;
+ case BackgroundDispose:
+ name = "BackgroundDispose";
+ break;
+ case NoneDispose:
+ name = "NoneDispose";
+ break;
+ case PreviousDispose:
+ name = "PreviousDispose";
+ break;
+ }
+
+ return rm_enum_new(Class_DisposeType, ID2SYM(rb_intern(name)), INT2FIX(type));
+}
+
+/*
+ External: FilterTypes.new
Purpose: Construct an FilterTypes enum object for the specified value
*/
VALUE
FilterTypes_new(FilterTypes type)
{
@@ -1187,11 +1403,11 @@
}
/*
- External: EndianType#new
+ External: EndianType.new
Purpose: Construct an EndianType enum object
*/
VALUE
EndianType_new(EndianType type)
{
@@ -1214,11 +1430,11 @@
return rm_enum_new(Class_EndianType, ID2SYM(rb_intern(name)), INT2FIX(type));
}
/*
- External: ImageType#new
+ External: ImageType.new
Purpose: Construct an ImageType enum object for the specified value
*/
VALUE
ImageType_new(ImageType type)
{
@@ -1786,11 +2002,11 @@
static VALUE
StretchType_new(StretchType stretch)
{
const char *name;
- name = StretchType_Const_Name(stretch);
+ name = StretchType_name(stretch);
return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
}
/*
@@ -1933,11 +2149,11 @@
"encoding=%s, foundry=%s, format=%s",
ti.name,
ti.description,
ti.family,
StyleType_Const_Name(ti.style),
- StretchType_Const_Name(ti.stretch),
+ StretchType_name(ti.stretch),
weight,
ti.encoding ? ti.encoding : "",
ti.foundry ? ti.foundry : "",
ti.format ? ti.format : "");
@@ -2363,16 +2579,58 @@
return rb_funcall(Class_Statistics, ID_new, 4, red, green, blue, opacity);
}
#endif // HAVE_GETIMAGESTATISTICS
+/*
+ Extern: StorageType_name
+ Purpose: Return the string representation of a StorageType value
+*/
+const char *
+StorageType_name(StorageType type)
+{
+ const char *name;
+ switch (type)
+ {
+ default:
+ case UndefinedPixel:
+ name = "UndefinedPixel";
+ break;
+ case CharPixel:
+ name = "CharPixel";
+ break;
+ case DoublePixel:
+ name = "DoublePixel";
+ break;
+ case FloatPixel:
+ name = "FloatPixel";
+ break;
+ case IntegerPixel:
+ name = "IntegerPixel";
+ break;
+ case LongPixel:
+ name = "LongPixel";
+ break;
+#if defined(HAVE_QUANTUMPIXEL)
+ case QuantumPixel:
+ name = "QuantumPixel";
+ break;
+#endif
+ case ShortPixel:
+ name = "ShortPixel";
+ break;
+ }
+
+ return name;
+}
+
/*
- Static: StretchType_Const_Name
+ Static: StretchType_name
Purpose: Return the string representation of a StretchType value
*/
static const char *
-StretchType_Const_Name(StretchType stretch)
+StretchType_name(StretchType stretch)
{
switch (stretch)
{
case NormalStretch:
return "NormalStretch";