ext/RMagick/rmimage.c in rmagick-2.6.0 vs ext/RMagick/rmimage.c in rmagick-2.7.0
- old
+ new
@@ -1,6 +1,6 @@
-/* $Id: rmimage.c,v 1.319 2008/09/10 22:16:58 rmagick Exp $ */
+/* $Id: rmimage.c,v 1.322 2008/09/28 00:23:10 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2008 by Timothy P. Hunter
| Name: rmimage.c
| Author: Tim Hunter
| Purpose: Image class method definitions for RMagick
@@ -567,61 +567,11 @@
return(VALUE)0;
#endif
}
-
/*
- Method: Image#affinity(affinity_image, dither_method=RiemersmaDitherMethod)
- Purpose: Call AffinityImage
- Notes: Immediate - modifies image in-place
-*/
-VALUE
-Image_affinity(int argc, VALUE *argv, VALUE self)
-{
-#if defined(HAVE_AFFINITYIMAGE)
- Image *image, *affinity_image;
- QuantizeInfo quantize_info;
-
- image = rm_check_frozen(self);
- if (argc > 0)
- {
- volatile VALUE t = rm_cur_image(argv[0]);
- affinity_image = rm_check_destroyed(t);
- }
-
- GetQuantizeInfo(&quantize_info);
-
- switch (argc)
- {
- case 2:
- VALUE_TO_ENUM(argv[1], quantize_info.dither_method, DitherMethod);
- quantize_info.dither = MagickTrue;
- break;
- case 1:
- break;
- default:
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
- break;
- }
-
-
- (void) AffinityImage(&quantize_info, image, affinity_image);
- rm_check_image_exception(image, RetainOnError);
-
- return self;
-#else
- self = self;
- argc = argc;
- argv = argv;
- rm_not_implemented();
- return(VALUE)0;
-#endif
-}
-
-
-/*
Method: Image#affine_transform(affine_matrix)
Purpose: transforms an image as dictated by the affine matrix argument
Returns: a new image
*/
VALUE
@@ -6249,12 +6199,12 @@
volatile VALUE map_obj, map_arg;
unsigned int dither = MagickFalse;
image = rm_check_destroyed(self);
-#if defined(HAVE_AFFINITYIMAGE)
- rb_warning("Image#map is deprecated. Use Image#affinity instead");
+#if defined(HAVE_REMAPIMAGE)
+ rb_warning("Image#map is deprecated. Use Image#remap instead");
#endif
switch (argc)
{
case 2:
@@ -7825,11 +7775,11 @@
case 5:
quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
case 4:
quantize_info.tree_depth = NUM2UINT(argv[3]);
case 3:
-#if defined(HAVE_TYPE_DITHERMETHOD)
+#if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
{
VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
}
@@ -8245,10 +8195,62 @@
return rm_image_new(new_image);
}
/*
+ Method: Image#remap(remap_image, dither_method=RiemersmaDitherMethod)
+ Purpose: Call RemapImage
+ Notes: Immediate - modifies image in-place
+*/
+VALUE
+Image_remap(int argc, VALUE *argv, VALUE self)
+{
+#if defined(HAVE_REMAPIMAGE) || defined(HAVE_AFFINITYIMAGE)
+ Image *image, *remap_image;
+ QuantizeInfo quantize_info;
+
+ image = rm_check_frozen(self);
+ if (argc > 0)
+ {
+ volatile VALUE t = rm_cur_image(argv[0]);
+ remap_image = rm_check_destroyed(t);
+ }
+
+ GetQuantizeInfo(&quantize_info);
+
+ switch (argc)
+ {
+ case 2:
+ VALUE_TO_ENUM(argv[1], quantize_info.dither_method, DitherMethod);
+ quantize_info.dither = MagickTrue;
+ break;
+ case 1:
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
+ break;
+ }
+
+#if defined(HAVE_REMAPIMAGE)
+ (void) RemapImage(&quantize_info, image, remap_image);
+#else
+ (void) AffinityImage(&quantize_info, image, remap_image);
+#endif
+ rm_check_image_exception(image, RetainOnError);
+
+ return self;
+#else
+ self = self;
+ argc = argc;
+ argv = argv;
+ rm_not_implemented();
+ return(VALUE)0;
+#endif
+}
+
+
+/*
Method: Image#rendering_intent=
Purpose: get rendering_intent
*/
VALUE
Image_rendering_intent(VALUE self)
@@ -10849,11 +10851,11 @@
const MagickInfo *magick_info, *magick_info2;
ExceptionInfo exception;
char magic[MaxTextExtent];
size_t magic_l;
size_t prefix_l;
- void *p;
+ char *p;
// Convert arg to string. If an exception occurs raise an error condition.
file = rb_rescue(rb_String, file, file_arg_rescue, file);
filename = rm_str2cstr(file, &filename_l);
@@ -10870,10 +10872,10 @@
// ignore it.
p = memchr(filename, ':', (size_t)filename_l);
if (p)
{
memset(magic, '\0', sizeof(magic));
- magic_l = p - (void *)filename;
+ magic_l = p - filename;
memcpy(magic, filename, magic_l);
GetExceptionInfo(&exception);
magick_info = GetMagickInfo(magic, &exception);
CHECK_EXCEPTION();