Permalink
Browse files

Support LiquidRescaleImage

  • Loading branch information...
rmagick
rmagick committed Jan 28, 2008
1 parent 832978f commit a348148ca2d828a6a888fdbeeb21c20380d07832
Showing with 55 additions and 4 deletions.
  1. +1 −0 ext/RMagick/extconf.rb
  2. +2 −1 ext/RMagick/rmagick.h
  3. +49 −1 ext/RMagick/rmimage.c
  4. +3 −2 ext/RMagick/rmmain.c
View
@@ -162,6 +162,7 @@ def exit_failure(msg)
"GetNextImageProperty", # 6.3.1
"IsHistogramImage", # 6.3.5
"LinearStretchImage", # 6.3.1
+ "LiquidRescaleImage", # 6.3.8-2
"MagickCoreGenesis", # 6.3.4
"OpaquePaintImageChannel", # 6.3.7-10
"PolaroidImage", # 6.3.1-6
View
@@ -1,4 +1,4 @@
-/* $Id: rmagick.h,v 1.222 2008/01/20 21:02:22 rmagick Exp $ */
+/* $Id: rmagick.h,v 1.223 2008/01/28 22:31:50 rmagick Exp $ */
/*=============================================================================
| Copyright (C) 2008 by Timothy P. Hunter
| Name: rmagick.h
@@ -860,6 +860,7 @@ extern VALUE Image_inspect(VALUE);
extern VALUE Image_level2(int, VALUE *, VALUE);
extern VALUE Image_level_channel(int, VALUE *, VALUE);
extern VALUE Image_linear_stretch(int, VALUE *, VALUE);
+extern VALUE Image_liquid_rescale(int, VALUE *, VALUE);
extern VALUE Image__load(VALUE, VALUE);
extern VALUE Image_magnify(VALUE);
extern VALUE Image_magnify_bang(VALUE);
View
@@ -1,4 +1,4 @@
-/* $Id: rmimage.c,v 1.278 2008/01/17 23:48:19 rmagick Exp $ */
+/* $Id: rmimage.c,v 1.279 2008/01/28 22:31:50 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2008 by Timothy P. Hunter
| Name: rmimage.c
@@ -5455,6 +5455,54 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
#endif
}
+
+/*
+ Method: Image#liquid_rescale(columns, rows, delta_x=0.0, rigidity=0.0)
+ Purpose: Call the LiquidRescaleImage API
+*/
+VALUE
+Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
+{
+#if defined(HAVE_LIQUIDRESCALEIMAGE)
+ Image *image, *new_image;
+ unsigned long cols, rows;
+ double delta_x = 0.0;
+ double rigidity = 0.0;
+ ExceptionInfo exception;
+
+ image = rm_check_destroyed(self);
+
+ switch (argc)
+ {
+ case 4:
+ rigidity = NUM2DBL(argv[3]);
+ case 3:
+ delta_x = NUM2DBL(argv[2]);
+ case 2:
+ rows = NUM2ULONG(argv[1]);
+ cols = NUM2ULONG(argv[0]);
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 4)", argc);
+ break;
+ }
+
+ GetExceptionInfo(&exception);
+ new_image = LiquidRescaleImage(image, cols, rows, delta_x, rigidity, &exception);
+ rm_check_exception(&exception, new_image, DestroyOnError);
+ DestroyExceptionInfo(&exception);
+ rm_ensure_result(new_image);
+
+ return rm_image_new(new_image);
+#else
+ argc = argc; // defeat "unused parameter" messages
+ argv = argv;
+ self = self;
+ rm_not_implemented();
+ return(VALUE)0;
+#endif
+}
+
/*
Method: Image._load
Purpose: implement marshalling
View
@@ -1,4 +1,4 @@
-/* $Id: rmmain.c,v 1.235 2008/01/19 16:22:25 rmagick Exp $ */
+/* $Id: rmmain.c,v 1.236 2008/01/28 22:31:50 rmagick Exp $ */
/*============================================================================\
| Copyright (C) 2008 by Timothy P. Hunter
| Name: rmmain.c
@@ -565,6 +565,7 @@ Init_RMagick2(void)
rb_define_method(Class_Image, "level2", Image_level2, -1);
rb_define_method(Class_Image, "level_channel", Image_level_channel, -1);
rb_define_method(Class_Image, "linear_stretch", Image_linear_stretch, -1);
+ rb_define_method(Class_Image, "liquid_rescale", Image_liquid_rescale, -1);
rb_define_method(Class_Image, "magnify", Image_magnify, 0);
rb_define_method(Class_Image, "magnify!", Image_magnify_bang, 0);
rb_define_method(Class_Image, "map", Image_map, -1);
@@ -1686,7 +1687,7 @@ static void version_constants(void)
rb_define_const(Module_Magick, "Version", str);
sprintf(long_version,
- "This is %s ($Date: 2008/01/19 16:22:25 $) Copyright (C) 2008 by Timothy P. Hunter\n"
+ "This is %s ($Date: 2008/01/28 22:31:50 $) Copyright (C) 2008 by Timothy P. Hunter\n"
"Built with %s\n"
"Built for %s\n"
"Web page: http://rmagick.rubyforge.org\n"

0 comments on commit a348148

Please sign in to comment.