From fefefd872848d8931eec52eea863891847fae6d9 Mon Sep 17 00:00:00 2001 From: u338_steven Date: Sun, 23 Feb 2014 10:53:16 +0900 Subject: [PATCH] Fixed build error with ImageMagick 6.8.8 (removed deprecated functions) Fixed build error with Windows x64 Fixed test failures --- doc/constants.html | 12 +- doc/ex/mask.rb | 2 +- doc/image2.html | 2 +- doc/image3.html | 4 +- doc/info.html | 2 +- doc/struct.html | 4 +- examples/histogram.rb | 2 +- examples/identify.rb | 8 +- ext/RMagick/extconf.rb | 119 ++++--------- ext/RMagick/rmagick.c | 9 +- ext/RMagick/rmagick.h | 62 +------ ext/RMagick/rmdraw.c | 22 --- ext/RMagick/rmenum.c | 36 +--- ext/RMagick/rmfill.c | 71 -------- ext/RMagick/rmilist.c | 52 +----- ext/RMagick/rmimage.c | 354 +++++---------------------------------- ext/RMagick/rminfo.c | 6 +- ext/RMagick/rmmain.c | 99 +---------- ext/RMagick/rmpixel.c | 8 +- ext/RMagick/rmstruct.c | 2 +- ext/RMagick/rmutil.c | 9 - lib/RMagick.rb | 10 +- test/Image2.rb | 3 +- test/Image3.rb | 10 +- test/ImageList2.rb | 2 +- test/Image_attributes.rb | 4 +- test/Import_Export.rb | 2 +- test/Info.rb | 8 +- test/Pixel.rb | 4 +- test/all_basic.rb | 7 +- 30 files changed, 162 insertions(+), 773 deletions(-) diff --git a/doc/constants.html b/doc/constants.html index 04e596d88..abdf3f1bb 100644 --- a/doc/constants.html +++ b/doc/constants.html @@ -38,7 +38,7 @@ } /* - * Modify .simple_table for the QuantumRange/QuantumDepth table. + * Modify .simple_table for the QuantumRange/MAGICKCORE_QUANTUM_DEPTH table. * The major differences are the centered text and the auto width. */ #maxrgb { @@ -196,15 +196,15 @@

Constants

Same as QuantumRange.
-
QuantumDepth
+
MAGICKCORE_QUANTUM_DEPTH
The number of bits in a quantum. The relationship between - QuantumDepth and QuantumRange is summarized in this table. + MAGICKCORE_QUANTUM_DEPTH and QuantumRange is summarized in this table. - + @@ -229,6 +229,10 @@

Constants

QuantumDepthMAGICKCORE_QUANTUM_DEPTH QuantumRange
+
QuantumDepth (deprecated)
+ +
Same as MAGICKCORE_QUANTUM_DEPTH.
+
Version
The RMagick version string. This has the form:
diff --git a/doc/ex/mask.rb b/doc/ex/mask.rb index e60bb2813..956181e27 100644 --- a/doc/ex/mask.rb +++ b/doc/ex/mask.rb @@ -31,6 +31,6 @@ # Use the #level method to darken the image under the black part of the mask. -img = img.level(0, Magick::MaxRGB, 0.50) +img = img.level(0, Magick::QuantumRange, 0.50) img.write('mask.jpg') diff --git a/doc/image2.html b/doc/image2.html index afd4b9b82..72e8a4e51 100644 --- a/doc/image2.html +++ b/doc/image2.html @@ -2231,7 +2231,7 @@

Example

pack, but it does demonstrate the use of a string pixels argument. Note that this example assumes that ImageMagick is configured with - QuantumDepth=8.

+ MAGICKCORE_QUANTUM_DEPTH=8.

 hat = Image.read("Flower_Hat.jpg").first
 pixels = hat.export_pixels(0, 0, hat.columns, hat.rows, "RGB")
diff --git a/doc/image3.html b/doc/image3.html
index ac3354b8f..6cb23c716 100644
--- a/doc/image3.html
+++ b/doc/image3.html
@@ -2134,7 +2134,7 @@ 

Arguments

depth
The desired depth (must be no greater than QuantumDepth)
+ "constants.html">MAGICKCORE_QUANTUM_DEPTH)

Returns

@@ -3287,7 +3287,7 @@

Returns

Example

-

threshold(MaxRGB*0.55)

+

threshold(QuantumRange*0.55)

Description

Arguments

Either 8, 16, or 32. You can specify 16 and 32 only when - ImageMagick was compiled with a QuantumDepth that allows these + ImageMagick was compiled with a MAGICKCORE_QUANTUM_DEPTH that allows these depth values.

Use depth to specify the depth of CMYK, GRAY, diff --git a/doc/struct.html b/doc/struct.html index 76e492d3c..bbf9e2a82 100644 --- a/doc/struct.html +++ b/doc/struct.html @@ -817,7 +817,7 @@

to_color

pixel.to_color(compliance=AllCompliance, matte=false, depth=QuantumDepth, depth=MAGICKCORE_QUANTUM_DEPTH, hex=false) -> string

@@ -851,7 +851,7 @@
Arguments
An image depth. The default is the quantum depth used when ImageMagick was compiled. The values 16 and 32 can be used only when ImageMagick was compiled with the - appropriate QuantumDepth.
+ appropriate MAGICKCORE_QUANTUM_DEPTH.
hex
diff --git a/examples/histogram.rb b/examples/histogram.rb index d50fff09d..b7a42a93f 100644 --- a/examples/histogram.rb +++ b/examples/histogram.rb @@ -302,7 +302,7 @@ def histogram(fg='white', bg='black') # Give the user something to look at while we're working. name = File.basename(filename).sub(/\..*?$/,'') -$defout.sync = true +$stdout.sync = true printf "Creating #{name}_Histogram.miff" timer = Thread.new do diff --git a/examples/identify.rb b/examples/identify.rb index 47bdd6f4c..edf32c20a 100644 --- a/examples/identify.rb +++ b/examples/identify.rb @@ -15,7 +15,7 @@ def identify puts "\tEndianess: #{endian}\n" puts "\tColorspace: #{colorspace}\n" puts "\tChannelDepth:\n" - color_space = gray? ? Magick::GrayColorspace : colorspace + color_space = gray? ? Magick::GRAYColorspace : colorspace case color_space when Magick::RGBColorspace puts "\t\tRed: #{channel_depth(Magick::RedChannel)}-bits\n" @@ -28,11 +28,11 @@ def identify puts "\t\tYellow: #{channel_depth(Magick::YellowChannel)}-bits\n" puts "\t\tBlack: #{channel_depth(Magick::BlackChannel)}-bits\n" puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte - when Magick::GrayColorspace + when Magick::GRAYColorspace puts "\t\tGray: #{channel_depth(Magick::GrayChannel)}-bits\n" puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte end - scale = Magick::QuantumRange / (Magick::QuantumRange >> (Magick::QuantumDepth-channel_depth)) + scale = Magick::QuantumRange / (Magick::QuantumRange >> (Magick::MAGICKCORE_QUANTUM_DEPTH-channel_depth)) puts "\tChannel statistics:\n" case color_space when Magick::RGBColorspace @@ -72,7 +72,7 @@ def identify puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[1]/scale, channel_extrema(Magick::BlackChannel)[1]/Magick::QuantumRange) puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[0]/scale, channel_mean(Magick::BlackChannel)[0]/Magick::QuantumRange) puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[1]/scale, channel_mean(Magick::BlackChannel)[1]/Magick::QuantumRange) - when Magick::GrayColorspace + when Magick::GRAYColorspace puts "\t\tGray:\n" puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[0]/scale, channel_extrema(Magick::GrayChannel)[0]/Magick::QuantumRange) puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[1]/scale, channel_extrema(Magick::GrayChannel)[1]/Magick::QuantumRange) diff --git a/ext/RMagick/extconf.rb b/ext/RMagick/extconf.rb index b6a1f04ea..151e91277 100644 --- a/ext/RMagick/extconf.rb +++ b/ext/RMagick/extconf.rb @@ -1,7 +1,7 @@ require "mkmf" require "date" -RMAGICK_VERS = "0.0.0" +RMAGICK_VERS = "2.13.2" MIN_RUBY_VERS = "1.8.5" MIN_RUBY_VERS_NO = MIN_RUBY_VERS.tr(".","").to_i MIN_IM_VERS = "6.4.9" @@ -46,6 +46,19 @@ def exit_failure(msg) end +def set_imagemagick_path_for_mingw() + path = ENV['PATH'].split(File::PATH_SEPARATOR) + path.each do |dir| + lib = File.join(dir, "lib") + lib_file = File.join(lib, "CORE_RL_magick_.lib") + if File.exists?(lib_file) + include = File.join(dir, "include") + $CPPFLAGS = %Q{-I"#{include}"} + $LDFLAGS = %Q{-L"#{lib}"} + break + end + end +end # Seems like lots of people have multiple versions of ImageMagick installed. @@ -152,6 +165,14 @@ def check_partial_imagemagick_versions() $magick_version = `Magick-config --version`.chomp + # Ensure ImageMagick is not configured for HDRI + unless checking_for("HDRI disabled version of ImageMagick") do + not (`Magick-config --version`["HDRI"]) + end + exit_failure "\nCan't install RMagick #{RMAGICK_VERS}."+ + "\nRMagick does not work when ImageMagick is configured for High Dynamic Range Images."+ + "\nDon't use the --enable-hdri option when configuring ImageMagick.\n" + end # Save flags $CFLAGS = ENV["CFLAGS"].to_s + " " + `Magick-config --cflags`.chomp @@ -164,7 +185,8 @@ def check_partial_imagemagick_versions() `convert -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-\d+ / abort "Unable to get ImageMagick version" unless $1 $magick_version = $1 - $LOCAL_LIBS = '-lCORE_RL_magick_ -lX11' + set_imagemagick_path_for_mingw() + $LOCAL_LIBS = '-lCORE_RL_magick_' else # mswin @@ -175,7 +197,7 @@ def check_partial_imagemagick_versions() $CPPFLAGS = %Q{-I"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include" -I"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\include"} # The /link option is required by the Makefile but causes warnings in the mkmf.log file. $LDFLAGS = %Q{/link /LIBPATH:"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib" /LIBPATH:"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\lib" /LIBPATH:"C:\\ruby\\lib"} - $LOCAL_LIBS = 'CORE_RL_magick_.lib X11.lib' + $LOCAL_LIBS = 'CORE_RL_magick_.lib' end @@ -206,40 +228,17 @@ def check_partial_imagemagick_versions() have_func("snprintf", headers) - ["AcquireImage", # 6.4.1 - "AffinityImage", # 6.4.3-6 - "AffinityImages", # 6.4.3-6 - "AutoGammaImageChannel", # 6.5.5-1 + ["AutoGammaImageChannel", # 6.5.5-1 "AutoLevelImageChannel", # 6.5.5-1 "BlueShiftImage", # 6.5.4-3 + "ColorMatrixImage", # 6.? "ConstituteComponentTerminus", # 6.5.7-9 - "DeskewImage", # 6.4.2-5 - "EncipherImage", # 6.3.8-6 - "EqualizeImageChannel", # 6.3.6-9 - "FloodfillPaintImage", # 6.3.7 - "FunctionImageChannel", # 6.4.8-8 - "GetAuthenticIndexQueue", # 6.4.5-6 - "GetAuthenticPixels", # 6.4.5-6 - "GetImageAlphaChannel", # 6.3.9-2 - "GetVirtualPixels", # 6.4.5-6 - "LevelImageColors", # 6.4.2 + "EvaluateImages", # 6.? "LevelColorsImageChannel", # 6.5.6-4 - "LevelizeImageChannel", # 6.4.2 - "LiquidRescaleImage", # 6.3.8-2 "MagickLibAddendum", # 6.5.9-1 - "OpaquePaintImageChannel", # 6.3.7-10 - "QueueAuthenticPixels", # 6.4.5-6 - "RemapImage", # 6.4.4-0 - "RemoveImageArtifact", # 6.3.6 "SelectiveBlurImageChannel", # 6.5.0-3 - "SetImageAlphaChannel", # 6.3.6-9 - "SetImageArtifact", # 6.3.6 - "SetMagickMemoryMethods", # 6.4.1 - "SparseColorImage", # 6.3.6-? - "SyncAuthenticPixels", # 6.4.5-6 + "StatisticImage", # 6.? "TransformImageColorspace", # 6.5.1 - "TransparentPaintImage", # 6.3.7-10 - "TransparentPaintImageChroma" # 6.4.5-6 ].each do |func| have_func(func, headers) end @@ -273,12 +272,7 @@ def check_partial_imagemagick_versions() have_struct_member("Image", "type", headers) # ??? -have_struct_member("DrawInfo", "kerning", headers) # 6.4.7-8 have_struct_member("DrawInfo", "interline_spacing", headers) # 6.5.5-8 -have_struct_member("DrawInfo", "interword_spacing", headers) # 6.4.8-0 -have_type("DitherMethod", headers) # 6.4.2 -have_type("MagickFunction", headers) # 6.4.8-8 -have_type("ImageLayerMethod", headers) # 6.3.6 replaces MagickLayerMethod have_type("long double", headers) #have_type("unsigned long long", headers) #have_type("uint64_t", headers) @@ -288,8 +282,7 @@ def check_partial_imagemagick_versions() #check_sizeof("Image *", headers) -have_enum_values("AlphaChannelType", ["CopyAlphaChannel", # 6.4.3-7 - "BackgroundAlphaChannel"], headers) # 6.5.2-5 +have_enum_values("AlphaChannelType", ["BackgroundAlphaChannel"], headers) # 6.5.2-5 have_enum_values("CompositeOperator", ["BlurCompositeOp", # 6.5.3-7 "DistortCompositeOp", # 6.5.3-10 "LinearBurnCompositeOp", # 6.5.4-3 @@ -298,57 +291,19 @@ def check_partial_imagemagick_versions() "PegtopLightCompositeOp", # 6.5.4-3 "PinLightCompositeOp", # 6.5.4-3 "VividLightCompositeOp"], headers) # 6.5.4-3 -have_enum_values("CompressionType", ["DXT1Compression", # 6.3.9-3 - "DXT3Compression", # 6.3.9-3 - "DXT5Compression", # 6.3.9-3 - "ZipSCompression", # 6.5.5-4 +have_enum_values("CompressionType", ["ZipSCompression", # 6.5.5-4 "PizCompression", # 6.5.5-4 "Pxr24Compression", # 6.5.5-4 "B44Compression", # 6.5.5-4 "B44ACompression"], headers) # 6.5.5-4 -have_enum_values("DistortImageMethod", ["BarrelDistortion", # 6.4.2-5 - "BarrelInverseDistortion", # 6.4.3-8 - "BilinearForwardDistortion", # 6.5.1-2 - "BilinearReverseDistortion", # 6.5.1-2 - "DePolarDistortion", # 6.4.2-6 - "PolarDistortion", # 6.4.2-6 - "PolynomialDistortion", # 6.4.2-4 - "ShepardsDistortion"], headers) # 6.4.2-4 -have_enum_value("DitherMethod", "NoDitherMethod", headers) # 6.4.3 -have_enum_values("FilterTypes", ["KaiserFilter", # 6.3.6 - "WelshFilter", # 6.3.6-4 - "ParzenFilter", # 6.3.6-4 - "LagrangeFilter", # 6.3.7-2 - "BohmanFilter", # 6.3.7-2 - "BartlettFilter", # 6.3.7-2 - "SentinelFilter"], headers) # 6.3.7-2 -have_enum_values("MagickEvaluateOperator", ["PowEvaluateOperator", # 6.4.1-9 - "LogEvaluateOperator", # 6.4.2 - "ThresholdEvaluateOperator", # 6.4.3 - "ThresholdBlackEvaluateOperator", # 6.4.3 - "ThresholdWhiteEvaluateOperator", # 6.4.3 - "GaussianNoiseEvaluateOperator", # 6.4.3 - "ImpulseNoiseEvaluateOperator", # 6.4.3 - "LaplacianNoiseEvaluateOperator", # 6.4.3 - "MultiplicativeNoiseEvaluateOperator", # 6.4.3 - "PoissonNoiseEvaluateOperator", # 6.4.3 - "UniformNoiseEvaluateOperator", # 6.4.3 - "CosineEvaluateOperator", # 6.4.8-5 - "SineEvaluateOperator", # 6.4.8-5 - "AddModulusEvaluateOperator"], # 6.4.8-5 - headers) +have_enum_values("DistortImageMethod", ["BilinearForwardDistortion", # 6.5.1-2 + "BilinearReverseDistortion"], # 6.5.1-2 + headers) have_enum_values("MagickFunction", ["ArcsinFunction", # 6.5.2-8 - "ArctanFunction", # 6.5.2-8 - "PolynomialFunction", # 6.4.8-8 - "SinusoidFunction"], headers) # 6.4.8-8 -have_enum_values("ImageLayerMethod", ["FlattenLayer", # 6.3.6-2 - "MergeLayer", # 6.3.6 - "MosaicLayer", # 6.3.6-2 - "TrimBoundsLayer" ], headers) # 6.4.3-8 -have_enum_values("VirtualPixelMethod", ["HorizontalTileVirtualPixelMethod", # 6.4.2-6 - "VerticalTileVirtualPixelMethod", # 6.4.2-6 - "HorizontalTileEdgeVirtualPixelMethod", # 6.5.0-1 + "ArctanFunction"], headers) # 6.5.2-8 + +have_enum_values("VirtualPixelMethod", ["HorizontalTileEdgeVirtualPixelMethod", # 6.5.0-1 "VerticalTileEdgeVirtualPixelMethod", # 6.5.0-1 "CheckerTileVirtualPixelMethod"], # 6.5.0-1 headers) diff --git a/ext/RMagick/rmagick.c b/ext/RMagick/rmagick.c index 661f95fce..1a675dd42 100644 --- a/ext/RMagick/rmagick.c +++ b/ext/RMagick/rmagick.c @@ -33,7 +33,8 @@ VALUE Magick_colors(VALUE class) { const ColorInfo **color_info_list; - unsigned long number_colors, x; + size_t number_colors; + unsigned long x; volatile VALUE ary; ExceptionInfo exception; @@ -82,7 +83,8 @@ VALUE Magick_fonts(VALUE class) { const TypeInfo **type_info; - unsigned long number_types, x; + size_t number_types; + unsigned long x; volatile VALUE ary; ExceptionInfo exception; @@ -166,7 +168,8 @@ VALUE Magick_init_formats(VALUE class) { const MagickInfo **magick_info; - unsigned long number_formats, x; + size_t number_formats; + unsigned long x; volatile VALUE formats; ExceptionInfo exception; diff --git a/ext/RMagick/rmagick.h b/ext/RMagick/rmagick.h index 8aa6f3faf..fda196738 100644 --- a/ext/RMagick/rmagick.h +++ b/ext/RMagick/rmagick.h @@ -53,7 +53,6 @@ #include "extconf.h" - //! For quoting preprocessor symbols #define Q2(q) #q //! For quoting preprocessor symbols @@ -66,19 +65,18 @@ DATA_PTR(_obj_) = (void *)(_new_);\ } while(0) - // Handle Quantum <-> Ruby Numeric object conversion -#if (QuantumDepth == 8 || QuantumDepth == 16) +#if (MAGICKCORE_QUANTUM_DEPTH == 8 || MAGICKCORE_QUANTUM_DEPTH == 16) #define QUANTUM2NUM(q) INT2FIX((q)) /**< Quantum -> Ruby Numeric conversion */ #define NUM2QUANTUM(n) (Quantum)NUM2UINT((n)) /**< Quantum <- Ruby Numeric conversion */ -#elif (QuantumDepth == 32) +#elif (MAGICKCORE_QUANTUM_DEPTH == 32) #define QUANTUM2NUM(q) UINT2NUM((q)) /**< Quantum -> Ruby Numeric conversion */ #define NUM2QUANTUM(n) (Quantum)NUM2UINT((n)) /**< Quntum <- Ruby Numeric conversion */ -#elif (QuantumDepth == 64) +#elif (MAGICKCORE_QUANTUM_DEPTH == 64) #define QUANTUM2NUM(q) ULL2NUM((q)) /**< Quantum -> Ruby Numeric conversion */ #define NUM2QUANTUM(n) (Quantum)NUM2ULL((n)) /**< Quntum <- Ruby Numeric conversion */ #else -#error Specified QuantumDepth is not supported. +#error Specified MAGICKCORE_QUANTUM_DEPTH is not supported. #endif //! Convert user-supplied objects to Quantum #define APP2QUANTUM(n) rm_app2quantum((n)) @@ -169,26 +167,10 @@ #define MagickLibSubversion MagickLibAddendum #endif -/** IM 6.4.1 replaced AllocateImage with AcquireImage. - * Both have the same signature. - */ -#if !defined(HAVE_ACQUIREIMAGE) -#define AcquireImage(info) AllocateImage(info) -#endif - -// ImageLayerMethod replaced MagickLayerMethod starting with 6.3.6 -#if defined(HAVE_TYPE_IMAGELAYERMETHOD) #define LAYERMETHODTYPE ImageLayerMethod /**< layer method */ #define CLASS_LAYERMETHODTYPE Class_ImageLayerMethod /**< layer method class */ #define LAYERMETHODTYPE_NAME ImageLayerMethod_name /**< layer method name */ #define LAYERMETHODTYPE_NEW ImageLayerMethod_new /**< new layer method */ -#else -#define LAYERMETHODTYPE MagickLayerMethod /**< layer method */ -#define CLASS_LAYERMETHODTYPE Class_MagickLayerMethod /**< layer method class */ -#define LAYERMETHODTYPE_NAME MagickLayerMethod_name /**< layer method name */ -#define LAYERMETHODTYPE_NEW MagickLayerMethod_new /**< new layer method */ -#endif - typedef ImageInfo Info; /**< Make type name match class name */ typedef PixelPacket Pixel; /**< Make type name match class name */ @@ -289,48 +271,20 @@ typedef enum _QuantumExpressionOperator RShiftQuantumOperator, /**< rshift */ SubtractQuantumOperator, /**< subtract */ XorQuantumOperator, /**< xor */ -#if defined(HAVE_ENUM_POWEVALUATEOPERATOR) PowQuantumOperator, /**< pow */ -#endif -#if defined(HAVE_ENUM_LOGEVALUATEOPERATOR) LogQuantumOperator, /**< log */ -#endif -#if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR) ThresholdQuantumOperator, /**< threshold */ -#endif -#if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR) ThresholdBlackQuantumOperator, /**< threshold black */ -#endif -#if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR) ThresholdWhiteQuantumOperator, /**< threshold white */ -#endif -#if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR) GaussianNoiseQuantumOperator, /**< gaussian noise */ -#endif -#if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR) ImpulseNoiseQuantumOperator, /**< impulse noise */ -#endif -#if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR) LaplacianNoiseQuantumOperator, /**< laplacian noise */ -#endif -#if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR) MultiplicativeNoiseQuantumOperator, /**< multiplicative noise */ -#endif -#if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR) PoissonNoiseQuantumOperator, /**< poisson noise */ -#endif -#if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR) UniformNoiseQuantumOperator, /**< uniform noise */ -#endif -#if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR) CosineQuantumOperator, /**< cosine */ -#endif -#if defined(HAVE_ENUM_SINEEVALUATEOPERATOR) SineQuantumOperator, /**< sine */ -#endif -#if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR) AddModulusQuantumOperator /**< add modulus */ -#endif } QuantumExpressionOperator ; @@ -391,9 +345,7 @@ EXTERN VALUE Class_CompressionType; EXTERN VALUE Class_DecorationType; EXTERN VALUE Class_DisposeType; EXTERN VALUE Class_DistortImageMethod; -#if defined(HAVE_TYPE_DITHERMETHOD) EXTERN VALUE Class_DitherMethod; -#endif EXTERN VALUE Class_EndianType; EXTERN VALUE Class_FilterTypes; EXTERN VALUE Class_GravityType; @@ -408,9 +360,7 @@ EXTERN VALUE Class_PaintMethod; EXTERN VALUE Class_PreviewType; EXTERN VALUE Class_RenderingIntent; EXTERN VALUE Class_ResolutionType; -#if defined(HAVE_SPARSECOLORIMAGE) EXTERN VALUE Class_SparseColorMethod; -#endif EXTERN VALUE Class_SpreadMethod; EXTERN VALUE Class_StorageType; EXTERN VALUE Class_StretchType; @@ -634,9 +584,9 @@ Pixel_##_cmyk_channel_(VALUE self) \ #define END_ENUM } //! Define a Magick module constant -#if QuantumDepth == 64 +#if MAGICKCORE_QUANTUM_DEPTH == 64 #define DEF_CONST(constant) rb_define_const(Module_Magick, #constant, ULL2NUM(constant)) -#else // QuantumDepth == 8, 16, 32 +#else // MAGICKCORE_QUANTUM_DEPTH == 8, 16, 32 #define DEF_CONST(constant) rb_define_const(Module_Magick, #constant, UINT2NUM(constant)) #endif diff --git a/ext/RMagick/rmdraw.c b/ext/RMagick/rmdraw.c index db4a30cff..aacebc98c 100644 --- a/ext/RMagick/rmdraw.c +++ b/ext/RMagick/rmdraw.c @@ -402,19 +402,12 @@ Draw_gravity_eq(VALUE self, VALUE grav) VALUE Draw_kerning_eq(VALUE self, VALUE kerning) { -#if defined(HAVE_ST_KERNING) Draw *draw; rb_check_frozen(self); Data_Get_Struct(self, Draw, draw); draw->info->kerning = NUM2DBL(kerning); return self; -#else - rm_not_implemented(); - return (VALUE)0; - self = self; - kerning = kerning; -#endif } @@ -466,19 +459,12 @@ Draw_interline_spacing_eq(VALUE self, VALUE spacing) VALUE Draw_interword_spacing_eq(VALUE self, VALUE spacing) { -#if defined(HAVE_ST_INTERWORD_SPACING) Draw *draw; rb_check_frozen(self); Data_Get_Struct(self, Draw, draw); draw->info->interword_spacing = NUM2DBL(spacing); return self; -#else - rm_not_implemented(); - return (VALUE)0; - self = self; - spacing = spacing; -#endif } @@ -631,12 +617,8 @@ Draw_marshal_dump(VALUE self) // rb_hash_aset(ddraw, CSTR2SYM("render"), draw->info->render ? Qtrue : Qfalse); internal // rb_hash_aset(ddraw, CSTR2SYM("element_reference"), Qnil); // not used yet // rb_hash_aset(ddraw, CSTR2SYM("debug"), draw->info->debug ? Qtrue : Qfalse); -#if defined(HAVE_ST_KERNING) rb_hash_aset(ddraw, CSTR2SYM("kerning"), rb_float_new(draw->info->kerning)); -#endif -#if defined(HAVE_ST_INTERWORD_SPACING) rb_hash_aset(ddraw, CSTR2SYM("interword_spacing"), rb_float_new(draw->info->interword_spacing)); -#endif // Non-DrawInfo fields rb_hash_aset(ddraw, CSTR2SYM("primitives"), draw->primitives); @@ -716,12 +698,8 @@ Draw_marshal_load(VALUE self, VALUE ddraw) draw->info->clip_units = FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units"))); draw->info->opacity = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("opacity"))); -#if defined(HAVE_ST_KERNING) draw->info->kerning = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("kerning"))); -#endif -#if defined(HAVE_ST_INTERWORD_SPACING) draw->info->interword_spacing = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("interword_spacing"))); -#endif draw->primitives = rb_hash_aref(ddraw, CSTR2SYM("primitives")); diff --git a/ext/RMagick/rmenum.c b/ext/RMagick/rmenum.c index c3ca72b10..a65e5a64c 100644 --- a/ext/RMagick/rmenum.c +++ b/ext/RMagick/rmenum.c @@ -408,8 +408,8 @@ ColorspaceType_new(ColorspaceType cs) case HSBColorspace: name = "HSBColorspace"; break; - case LABColorspace: - name = "LABColorspace"; + case LabColorspace: + name = "LabColorspace"; break; case Rec601YCbCrColorspace: name = "Rec601YCbCrColorspace"; @@ -573,15 +573,9 @@ CompressionType_name(CompressionType ct) ENUM_TO_NAME(B44ACompression) #endif ENUM_TO_NAME(BZipCompression) -#if defined(HAVE_ENUM_DXT1COMPRESSION) ENUM_TO_NAME(DXT1Compression) -#endif -#if defined(HAVE_ENUM_DXT3COMPRESSION) ENUM_TO_NAME(DXT3Compression) -#endif -#if defined(HAVE_ENUM_DXT5COMPRESSION) ENUM_TO_NAME(DXT5Compression) -#endif ENUM_TO_NAME(FaxCompression) ENUM_TO_NAME(Group4Compression) ENUM_TO_NAME(JPEGCompression) @@ -689,29 +683,15 @@ FilterTypes_name(FilterTypes type) ENUM_TO_NAME(LanczosFilter) ENUM_TO_NAME(BesselFilter) ENUM_TO_NAME(SincFilter) -#if defined(HAVE_ENUM_KAISERFILTER) ENUM_TO_NAME(KaiserFilter) -#endif -#if defined(HAVE_ENUM_WELSHFILTER) ENUM_TO_NAME(WelshFilter) -#endif -#if defined(HAVE_ENUM_PARZENFILTER) ENUM_TO_NAME(ParzenFilter) -#endif -#if defined(HAVE_ENUM_LAGRANGEFILTER) ENUM_TO_NAME(LagrangeFilter) -#endif -#if defined(HAVE_ENUM_BOHMANFILTER) ENUM_TO_NAME(BohmanFilter) -#endif -#if defined(HAVE_ENUM_BARTLETTFILTER) ENUM_TO_NAME(BartlettFilter) -#endif -#if defined(HAVE_ENUM_SENTINELFILTER) // not a real filter name - defeat gcc warning message case SentinelFilter: break; -#endif } return "UndefinedFilter"; @@ -978,18 +958,10 @@ LAYERMETHODTYPE_NAME(LAYERMETHODTYPE method) ENUM_TO_NAME(RemoveDupsLayer) ENUM_TO_NAME(RemoveZeroLayer) ENUM_TO_NAME(CompositeLayer) -#if defined(HAVE_ENUM_MERGELAYER) ENUM_TO_NAME(MergeLayer) -#endif -#if defined(HAVE_ENUM_MOSAICLAYER) ENUM_TO_NAME(MosaicLayer) -#endif -#if defined(HAVE_ENUM_FLATTENLAYER) ENUM_TO_NAME(FlattenLayer) -#endif -#if defined(HAVE_ENUM_TRIMBOUNDSLAYER) ENUM_TO_NAME(TrimBoundsLayer) -#endif } return "UndefinedLayer"; @@ -1187,12 +1159,8 @@ VirtualPixelMethod_name(VirtualPixelMethod method) ENUM_TO_NAME(BlackVirtualPixelMethod) ENUM_TO_NAME(GrayVirtualPixelMethod) ENUM_TO_NAME(WhiteVirtualPixelMethod) -#if defined(HAVE_ENUM_HORIZONTALTILEVIRTUALPIXELMETHOD) ENUM_TO_NAME(HorizontalTileVirtualPixelMethod) -#endif -#if defined(HAVE_ENUM_VERTICALTILEVIRTUALPIXELMETHOD) ENUM_TO_NAME(VerticalTileVirtualPixelMethod) -#endif #if defined(HAVE_ENUM_HORIZONTALTILEEDGEVIRTUALPIXELMETHOD) ENUM_TO_NAME(HorizontalTileEdgeVirtualPixelMethod) #endif diff --git a/ext/RMagick/rmfill.c b/ext/RMagick/rmfill.c index da3d683d1..0805c3ad4 100644 --- a/ext/RMagick/rmfill.c +++ b/ext/RMagick/rmfill.c @@ -119,11 +119,9 @@ point_fill( double steps, distance; unsigned long x, y; MagickRealType red_step, green_step, blue_step; -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif steps = sqrt((double)((image->columns-x0)*(image->columns-x0) + (image->rows-y0)*(image->rows-y0))); @@ -136,13 +134,8 @@ point_fill( { PixelPacket *row_pixels; -#if defined(HAVE_QUEUEAUTHENTICPIXELS) row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception); CHECK_EXCEPTION() -#else - row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1); - rm_check_image_exception(image, RetainOnError); -#endif for (x = 0; x < image->columns; x++) { distance = sqrt((double)((x-x0)*(x-x0)+(y-y0)*(y-y0))); @@ -152,18 +145,11 @@ point_fill( row_pixels[x].opacity = OpaqueOpacity; } -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif } /** @@ -188,11 +174,9 @@ vertical_fill( unsigned long x, y; PixelPacket *master; MagickRealType red_step, green_step, blue_step; -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif steps = FMAX(x1, ((long)image->columns)-x1); @@ -226,28 +210,16 @@ vertical_fill( { PixelPacket *row_pixels; -#if defined(HAVE_QUEUEAUTHENTICPIXELS) row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception); CHECK_EXCEPTION() -#else - row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1); - rm_check_image_exception(image, RetainOnError); -#endif memcpy(row_pixels, master, image->columns * sizeof(PixelPacket)); -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif xfree((void *)master); } @@ -273,11 +245,9 @@ horizontal_fill( unsigned long x, y; PixelPacket *master; MagickRealType red_step, green_step, blue_step; -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif steps = FMAX(y1, ((long)image->rows)-y1); @@ -309,26 +279,14 @@ horizontal_fill( { PixelPacket *col_pixels; -#if defined(HAVE_QUEUEAUTHENTICPIXELS) col_pixels = QueueAuthenticPixels(image, (long int)x, 0, 1, image->rows, &exception); -#else - col_pixels = SetImagePixels(image, (long int)x, 0, 1, image->rows); - rm_check_image_exception(image, RetainOnError); -#endif memcpy(col_pixels, master, image->rows * sizeof(PixelPacket)); -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif xfree((PixelPacket *)master); } @@ -361,11 +319,9 @@ v_diagonal_fill( MagickRealType red_step, green_step, blue_step; double m, b, steps = 0.0; double d1, d2; -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif // Compute the equation of the line: y=mx+b m = ((double)(y2 - y1))/((double)(x2 - x1)); @@ -407,13 +363,8 @@ v_diagonal_fill( { PixelPacket *row_pixels; -#if defined(HAVE_QUEUEAUTHENTICPIXELS) row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception); CHECK_EXCEPTION() -#else - row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1); - rm_check_image_exception(image, RetainOnError); -#endif for (x = 0; x < image->columns; x++) { double distance = (double) abs((int)(y-(m * x + b))); @@ -423,19 +374,11 @@ v_diagonal_fill( row_pixels[x].opacity = OpaqueOpacity; } -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif - } /** @@ -466,11 +409,9 @@ h_diagonal_fill( double m, b, steps = 0.0; MagickRealType red_step, green_step, blue_step; double d1, d2; -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif // Compute the equation of the line: y=mx+b m = ((double)(y2 - y1))/((double)(x2 - x1)); @@ -514,13 +455,8 @@ h_diagonal_fill( { PixelPacket *row_pixels; -#if defined(HAVE_QUEUEAUTHENTICPIXELS) row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception); CHECK_EXCEPTION() -#else - row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1); - rm_check_image_exception(image, RetainOnError); -#endif for (x = 0; x < image->columns; x++) { double distance = (double) abs((int)(x-((y-b)/m))); @@ -530,18 +466,11 @@ h_diagonal_fill( row_pixels[x].opacity = OpaqueOpacity; } -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif } /** diff --git a/ext/RMagick/rmilist.c b/ext/RMagick/rmilist.c index 53473f034..a06f815fd 100644 --- a/ext/RMagick/rmilist.c +++ b/ext/RMagick/rmilist.c @@ -133,7 +133,12 @@ ImageList_average(VALUE self) images = images_from_imagelist(self); GetExceptionInfo(&exception); +#if defined(HAVE_EVALUATEIMAGES) + new_image = EvaluateImages(images, MeanEvaluateOperator, &exception); +#else new_image = AverageImages(images, &exception); +#endif + rm_split(images); rm_check_exception(&exception, new_image, DestroyOnError); (void) DestroyExceptionInfo(&exception); @@ -322,11 +327,7 @@ ImageList_flatten_images(VALUE self) images = images_from_imagelist(self); GetExceptionInfo(&exception); -#if defined(HAVE_ENUM_FLATTENLAYER) new_image = MergeImageLayers(images, FlattenLayer, &exception); -#else - new_image = FlattenImages(images, &exception); -#endif rm_split(images); rm_check_exception(&exception, new_image, DestroyOnError); @@ -415,9 +416,8 @@ ImageList_map(int argc, VALUE *argv, VALUE self) volatile VALUE scene, new_imagelist, t; ExceptionInfo exception; -#if defined(HAVE_REMAPIMAGES) + QuantizeInfo quantize_info; rb_warning("ImageList#map is deprecated. Use ImageList#remap instead."); -#endif switch (argc) { @@ -445,7 +445,9 @@ ImageList_map(int argc, VALUE *argv, VALUE self) rm_ensure_result(new_images); // Call ImageMagick - (void) MapImages(new_images, map, dither); + GetQuantizeInfo(&quantize_info); + quantize_info.dither = dither; + (void) RemapImages(&quantize_info, new_images, map); rm_check_image_exception(new_images, DestroyOnError); // Set @scene in new ImageList object to same value as in self. @@ -575,11 +577,7 @@ ImageList_mosaic(VALUE self) GetExceptionInfo(&exception); images = images_from_imagelist(self); -#if defined(HAVE_ENUM_MOSAICLAYER) new_image = MergeImageLayers(images, MosaicLayer, &exception); -#else - new_image = MosaicImages(images, &exception); -#endif rm_split(images); rm_check_exception(&exception, new_image, DestroyOnError); @@ -612,11 +610,7 @@ ImageList_optimize_layers(VALUE self, VALUE method) new_images2 = NULL; // defeat "unused variable" message GetExceptionInfo(&exception); -#if defined(HAVE_TYPE_IMAGELAYERMETHOD) VALUE_TO_ENUM(method, mthd, ImageLayerMethod); -#else - VALUE_TO_ENUM(method, mthd, MagickLayerMethod); -#endif images = images_from_imagelist(self); switch (mthd) @@ -659,12 +653,8 @@ ImageList_optimize_layers(VALUE self, VALUE method) OptimizeImageTransparency(new_images, &exception); rm_check_exception(&exception, new_images, DestroyOnError); // mogrify supports -dither here. We don't. -#if defined(HAVE_REMAPIMAGE) GetQuantizeInfo(&quantize_info); (void) RemapImages(&quantize_info, new_images, NULL); -#else - (void) MapImages(new_images, NULL, 0); -#endif break; case OptimizePlusLayer: new_images = OptimizePlusImageLayers(images, &exception); @@ -674,26 +664,18 @@ ImageList_optimize_layers(VALUE self, VALUE method) case CompareOverlayLayer: new_images = CompareImageLayers(images, mthd, &exception); break; -#if defined(HAVE_ENUM_MOSAICLAYER) case MosaicLayer: new_images = MergeImageLayers(images, mthd, &exception); break; -#endif -#if defined(HAVE_ENUM_FLATTENLAYER) case FlattenLayer: new_images = MergeImageLayers(images, mthd, &exception); break; -#endif -#if defined(HAVE_ENUM_MERGELAYER) case MergeLayer: new_images = MergeImageLayers(images, mthd, &exception); break; -#endif -#if defined(HAVE_ENUM_TRIMBOUNDSLAYER) case TrimBoundsLayer: new_images = MergeImageLayers(images, mthd, &exception); break; -#endif default: rm_split(images); rb_raise(rb_eArgError, "undefined layer method"); @@ -941,15 +923,11 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self) case 4: quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]); case 3: -#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; } -#else - quantize_info.dither = (MagickBooleanType) RTEST(argv[2]); -#endif case 2: VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType); case 1: @@ -1013,7 +991,6 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self) VALUE ImageList_remap(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_REMAPIMAGES) || defined(HAVE_AFFINITYIMAGES) Image *images, *remap_image = NULL; QuantizeInfo quantize_info; @@ -1038,22 +1015,11 @@ ImageList_remap(int argc, VALUE *argv, VALUE self) images = images_from_imagelist(self); -#if defined(HAVE_REMAPIMAGE) (void) RemapImages(&quantize_info, images, remap_image); -#else - (void) AffinityImages(&quantize_info, images, remap_image); -#endif rm_check_image_exception(images, RetainOnError); rm_split(images); return self; -#else - self = self; - argc = argc; - argv = argv; - rm_not_implemented(); - return(VALUE)0; -#endif } diff --git a/ext/RMagick/rmimage.c b/ext/RMagick/rmimage.c index 4ecd117e5..e415b6613 100644 --- a/ext/RMagick/rmimage.c +++ b/ext/RMagick/rmimage.c @@ -591,39 +591,9 @@ Image_alpha(int argc, VALUE *argv, VALUE self) image = rm_check_frozen(self); VALUE_TO_ENUM(argv[0], alpha, AlphaChannelType); -#if defined(HAVE_SETIMAGEALPHACHANNEL) // Added in 6.3.6-9 (void) SetImageAlphaChannel(image, alpha); rm_check_image_exception(image, RetainOnError); -#else - switch (alpha) - { - case ActivateAlphaChannel: - image->matte = MagickTrue; - break; - - case DeactivateAlphaChannel: - image->matte = MagickFalse; - break; - - case ResetAlphaChannel: - if (image->matte == MagickFalse) - { - (void) SetImageOpacity(image, OpaqueOpacity); - rm_check_image_exception(image, RetainOnError); - } - break; - - case SetAlphaChannel: - (void) CompositeImage(image, CopyOpacityCompositeOp, image, 0, 0); - rm_check_image_exception(image, RetainOnError); - break; - - default: - rb_raise(rb_eArgError, "unknown AlphaChannelType value"); - break; - } -#endif return argv[0]; } @@ -646,11 +616,7 @@ VALUE Image_alpha_q(VALUE self) { Image *image = rm_check_destroyed(self); -#if defined(HAVE_GETIMAGEALPHACHANNEL) return GetImageAlphaChannel(image) ? Qtrue : Qfalse; -#else - return image->matte ? Qtrue : Qfalse; -#endif } @@ -1620,9 +1586,7 @@ special_composite(Image *image, Image *overlay, double image_pct, double overlay blend_geometry(geometry, sizeof(geometry), image_pct, overlay_pct); (void) CloneString(&overlay->geometry, geometry); -#if defined(HAVE_SETIMAGEARTIFACT) (void) SetImageArtifact(overlay,"compose:args", geometry); -#endif new_image = rm_clone_image(image); (void) CompositeImage(new_image, op, overlay, x_off, y_off); @@ -2238,7 +2202,7 @@ Image_channel_extrema(int argc, VALUE *argv, VALUE self) Image *image; ChannelType channels; ExceptionInfo exception; - unsigned long min, max; + size_t min, max; volatile VALUE ary; image = rm_check_destroyed(self); @@ -2506,7 +2470,8 @@ Image_color_histogram(VALUE self) { Image *image, *dc_copy = NULL; volatile VALUE hash, pixel; - unsigned long x, colors; + size_t colors; + unsigned long x; ColorPacket *histogram; ExceptionInfo exception; @@ -2757,7 +2722,6 @@ Image_color_flood_fill( VALUE self, VALUE target_color, VALUE fill_color new_image = rm_clone_image(image); -#if defined(HAVE_FLOODFILLPAINTIMAGE) { MagickPixelPacket target_mpp; MagickBooleanType invert; @@ -2780,9 +2744,6 @@ Image_color_flood_fill( VALUE self, VALUE target_color, VALUE fill_color (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert); } -#else - (void) ColorFloodfillImage(new_image, draw_info, target, x, y, (PaintMethod)fill_method); -#endif // No need to check for error (void) DestroyDrawInfo(draw_info); @@ -3674,11 +3635,7 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self) image = rm_clone_image(image); } -#if defined(HAVE_SETIMAGEARTIFACT) (void) SetImageArtifact(comp_image,"modify-outside-overlay", "false"); -#else - (void) SetImageAttribute(comp_image, "[modify-outside-overlay]", "false"); -#endif status = MagickTrue; columns = comp_image->columns; @@ -4421,7 +4378,6 @@ Image_density_eq(VALUE self, VALUE density_arg) VALUE Image_decipher(VALUE self, VALUE passphrase) { -#if defined(HAVE_ENCIPHERIMAGE) Image *image, *new_image; char *pf; ExceptionInfo exception; @@ -4444,12 +4400,6 @@ Image_decipher(VALUE self, VALUE passphrase) DestroyExceptionInfo(&exception); return rm_image_new(new_image); -#else - self = self; - passphrase = passphrase; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -4473,7 +4423,6 @@ Image_decipher(VALUE self, VALUE passphrase) VALUE Image_define(VALUE self, VALUE artifact, VALUE value) { -#if defined(HAVE_SETIMAGEARTIFACT) Image *image; char *key, *val; MagickBooleanType status; @@ -4498,13 +4447,6 @@ Image_define(VALUE self, VALUE artifact, VALUE value) } return value; -#else - rm_not_implemented(); - artifact = artifact; - value = value; - self = self; - return(VALUE)0; -#endif } @@ -4609,7 +4551,6 @@ Image_depth(VALUE self) VALUE Image_deskew(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_DESKEWIMAGE) Image *image, *new_image; double threshold = 40.0 * QuantumRange / 100.0; unsigned long width; @@ -4642,13 +4583,6 @@ Image_deskew(int argc, VALUE *argv, VALUE self) (void) DestroyExceptionInfo(&exception); return rm_image_new(new_image); -#else - self = self; // defeat "unused parameter" message - argv = argv; - argc = argc; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -5471,7 +5405,6 @@ Image_emboss(int argc, VALUE *argv, VALUE self) VALUE Image_encipher(VALUE self, VALUE passphrase) { -#if defined(HAVE_ENCIPHERIMAGE) Image *image, *new_image; char *pf; ExceptionInfo exception; @@ -5494,12 +5427,6 @@ Image_encipher(VALUE self, VALUE passphrase) DestroyExceptionInfo(&exception); return rm_image_new(new_image); -#else - self = self; - passphrase = passphrase; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -5615,7 +5542,6 @@ Image_equalize(VALUE self) VALUE Image_equalize_channel(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_EQUALIZEIMAGECHANNEL) Image *image, *new_image; ExceptionInfo exception; ChannelType channels; @@ -5637,13 +5563,6 @@ Image_equalize_channel(int argc, VALUE *argv, VALUE self) (void) DestroyExceptionInfo(&exception); return rm_image_new(new_image); -#else - argc = argc; - argv = argv; - self = self; - rm_not_implemented(); - return(VALUE) 0; -#endif } @@ -6196,7 +6115,7 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self) { Image *image, *target; volatile VALUE region, targ; - long x = 0L, y = 0L; + ssize_t x = 0L, y = 0L; ExceptionInfo exception; unsigned int okay; @@ -6585,12 +6504,10 @@ Image_from_blob(VALUE class, VALUE blob_arg) VALUE Image_function_channel(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_FUNCTIONIMAGECHANNEL) Image *image, *new_image; MagickFunction function; unsigned long n, nparms; - volatile double *parameters; - double *parms; + volatile double *parms; ChannelType channels; ExceptionInfo exception; @@ -6609,17 +6526,13 @@ Image_function_channel(int argc, VALUE *argv, VALUE self) switch (function) { -#if defined(HAVE_ENUM_POLYNOMIALFUNCTION) case PolynomialFunction: if (argc == 0) { rb_raise(rb_eArgError, "PolynomialFunction requires at least one argument."); } break; -#endif -#if defined(HAVE_ENUM_SINUSOIDFUNCTION) case SinusoidFunction: -#endif #if defined(HAVE_ENUM_ARCSINFUNCTION) case ArcsinFunction: #endif @@ -6637,7 +6550,7 @@ Image_function_channel(int argc, VALUE *argv, VALUE self) } nparms = argc; - parameters = parms = ALLOC_N(double, nparms); + parms = ALLOC_N(double, nparms); for (n = 0; n < nparms; n++) { @@ -6646,19 +6559,12 @@ Image_function_channel(int argc, VALUE *argv, VALUE self) GetExceptionInfo(&exception); new_image = rm_clone_image(image); - (void) FunctionImageChannel(new_image, channels, function, nparms, parms, &exception); - (void) xfree(parms); + (void) FunctionImageChannel(new_image, channels, function, nparms, (double *)parms, &exception); + (void) xfree((double *)parms); rm_check_exception(&exception, new_image, DestroyOnError); DestroyExceptionInfo(&exception); return rm_image_new(new_image); -#else - rm_not_implemented(); - return (VALUE)0; - argc = argc; - argv = argv; - self = self; -#endif } @@ -6985,11 +6891,7 @@ Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE row // Cast AcquireImagePixels to get rid of the const qualifier. We're not going // to change the pixels but I don't want to make "pixels" const. GetExceptionInfo(&exception); -#if defined(HAVE_GETVIRTUALPIXELS) pixels = GetVirtualPixels(image, x, y, columns, rows, &exception); -#else - pixels = AcquireImagePixels(image, x, y, columns, rows, &exception); -#endif CHECK_EXCEPTION() (void) DestroyExceptionInfo(&exception); @@ -7412,7 +7314,6 @@ build_inspect_string(Image *image, char *buffer, size_t len) } -#if defined(HAVE_SETIMAGEARTIFACT) if (len-1-x > 6) { size_t value_l; @@ -7427,7 +7328,6 @@ build_inspect_string(Image *image, char *buffer, size_t len) x += value_l; } } -#endif assert(x < (int)(len-1)); buffer[x] = '\0'; @@ -7708,7 +7608,6 @@ Image_level_channel(int argc, VALUE *argv, VALUE self) VALUE Image_level_colors(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_LEVELIMAGECOLORS) || defined(HAVE_LEVELCOLORSIMAGECHANNEL) Image *image, *new_image; MagickPixelPacket black_color, white_color; ChannelType channels; @@ -7773,14 +7672,6 @@ Image_level_colors(int argc, VALUE *argv, VALUE self) } return rm_image_new(new_image); - -#else - rm_not_implemented(); - self = self; - argc = argc; - argv = argv; - return(VALUE)0; -#endif } @@ -7808,7 +7699,6 @@ Image_level_colors(int argc, VALUE *argv, VALUE self) VALUE Image_levelize_channel(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_LEVELIZEIMAGECHANNEL) Image *image, *new_image; ChannelType channels; double black_point, white_point; @@ -7848,13 +7738,6 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self) rb_raise(rb_eRuntimeError, "LevelizeImageChannel failed for unknown reason."); } return rm_image_new(new_image); -#else - rm_not_implemented(); - self = self; - argc = argc; - argv = argv; - return(VALUE)0; -#endif } @@ -7912,7 +7795,6 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self) 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; @@ -7943,13 +7825,6 @@ Image_liquid_rescale(int argc, VALUE *argv, VALUE self) 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 } @@ -8134,11 +8009,10 @@ Image_map(int argc, VALUE *argv, VALUE self) volatile VALUE map_obj, map_arg; unsigned int dither = MagickFalse; - image = rm_check_destroyed(self); - -#if defined(HAVE_REMAPIMAGE) + QuantizeInfo quantize_info; rb_warning("Image#map is deprecated. Use Image#remap instead"); -#endif + + image = rm_check_destroyed(self); switch (argc) { @@ -8156,7 +8030,9 @@ Image_map(int argc, VALUE *argv, VALUE self) map_obj = rm_cur_image(map_arg); map = rm_check_destroyed(map_obj); - (void) MapImage(new_image, map, dither); + GetQuantizeInfo(&quantize_info); + quantize_info.dither=dither; + (void) RemapImage(&quantize_info, new_image, map); rm_check_image_exception(new_image, DestroyOnError); return rm_image_new(new_image); @@ -8374,18 +8250,11 @@ Image_mask(int argc, VALUE *argv, VALUE self) } // The following section is copied from mogrify.c (6.2.8-8) -#if defined(HAVE_SYNCAUTHENTICPIXELS) GetExceptionInfo(&exception); -#endif for (y = 0; y < (long) clip_mask->rows; y++) { -#if defined(HAVE_GETAUTHENTICPIXELS) q = GetAuthenticPixels(clip_mask, 0, y, clip_mask->columns, 1, &exception); rm_check_exception(&exception, clip_mask, DestroyOnError); -#else - q = GetImagePixels(clip_mask, 0, y, clip_mask->columns, 1); - rm_check_image_exception(clip_mask, DestroyOnError); -#endif if (!q) { break; @@ -8402,17 +8271,10 @@ Image_mask(int argc, VALUE *argv, VALUE self) q += 1; } -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(clip_mask, &exception); rm_check_exception(&exception, clip_mask, DestroyOnError); -#else - SyncImagePixels(clip_mask); - rm_check_image_exception(clip_mask, DestroyOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) (void) DestroyExceptionInfo(&exception); -#endif SetImageStorageClass(clip_mask, DirectClass); rm_check_image_exception(clip_mask, DestroyOnError); @@ -8473,7 +8335,6 @@ Image_matte(VALUE self) VALUE Image_matte_eq(VALUE self, VALUE matte) { -#if defined(HAVE_SETIMAGEALPHACHANNEL) VALUE alpha_channel_type; if (RTEST(matte)) @@ -8486,11 +8347,6 @@ Image_matte_eq(VALUE self, VALUE matte) } return Image_alpha_eq(self, alpha_channel_type); -#else - Image *image = rm_check_frozen(self); - image->matte = RTEST(matte) ? MagickTrue : MagickFalse; - return matte; -#endif } @@ -8574,7 +8430,6 @@ Image_matte_flood_fill(VALUE self, VALUE color, VALUE opacity, VALUE x_obj, VALU new_image = rm_clone_image(image); -#if defined(HAVE_FLOODFILLPAINTIMAGE) { DrawInfo *draw_info; MagickPixelPacket target_mpp; @@ -8605,9 +8460,6 @@ Image_matte_flood_fill(VALUE self, VALUE color, VALUE opacity, VALUE x_obj, VALU (void) FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert); } -#else - (void) MatteFloodfillImage(new_image, target, op, x, y, method); -#endif rm_check_image_exception(new_image, DestroyOnError); return rm_image_new(new_image); @@ -8651,8 +8503,11 @@ Image_median_filter(int argc, VALUE *argv, VALUE self) } GetExceptionInfo(&exception); - +#if defined(HAVE_STATISTICIMAGE) + new_image = StatisticImage(image, MedianStatistic, (size_t)radius, (size_t)radius, &exception); +#else new_image = MedianFilterImage(image, radius, &exception); +#endif rm_check_exception(&exception, new_image, DestroyOnError); (void) DestroyExceptionInfo(&exception); @@ -9364,11 +9219,7 @@ Image_opaque(VALUE self, VALUE target, VALUE fill) Color_to_MagickPixelPacket(image, &target_pp, target); Color_to_MagickPixelPacket(image, &fill_pp, fill); -#if defined(HAVE_OPAQUEPAINTIMAGECHANNEL) okay = OpaquePaintImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse); -#else - okay = PaintOpaqueImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp); -#endif rm_check_image_exception(new_image, DestroyOnError); if (!okay) @@ -9406,7 +9257,6 @@ Image_opaque(VALUE self, VALUE target, VALUE fill) VALUE Image_opaque_channel(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_OPAQUEPAINTIMAGECHANNEL) Image *image, *new_image; MagickPixelPacket target_pp, fill_pp; ChannelType channels; @@ -9461,14 +9311,6 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self) } return rm_image_new(new_image); - -#else - argc = argc; // defeat "unused parameter" messages - argv = argv; - self = self; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -9656,7 +9498,6 @@ Image_page_eq(VALUE self, VALUE rect) VALUE Image_paint_transparent(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_TRANSPARENTPAINTIMAGE) Image *image, *new_image; MagickPixelPacket color; Quantum opacity = TransparentOpacity; @@ -9703,13 +9544,6 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self) } return rm_image_new(new_image); -#else - argc = argc; // defeat "unused parameter" messages - argv = argv; - self = self; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -9802,11 +9636,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self) if (!set) { GetExceptionInfo(&exception); -#if defined(HAVE_GETVIRTUALPIXELS) old_color = *GetVirtualPixels(image, x, y, 1, 1, &exception); -#else - old_color = *AcquireImagePixels(image, x, y, 1, 1, &exception); -#endif CHECK_EXCEPTION() (void) DestroyExceptionInfo(&exception); @@ -9814,11 +9644,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self) // PseudoClass if (image->storage_class == PseudoClass) { -#if defined(HAVE_GETAUTHENTICINDEXQUEUE) IndexPacket *indexes = GetAuthenticIndexQueue(image); -#else - IndexPacket *indexes = GetIndexes(image); -#endif old_color = image->colormap[(unsigned long)*indexes]; } if (!image->matte) @@ -9848,17 +9674,10 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self) } -#if defined(HAVE_GETAUTHENTICPIXELS) || defined(HAVE_SYNCAUTHENTICPIXELS) GetExceptionInfo(&exception); -#endif -#if defined(HAVE_GETAUTHENTICPIXELS) pixel = GetAuthenticPixels(image, x, y, 1, 1, &exception); CHECK_EXCEPTION() -#else - pixel = GetImagePixels(image, x, y, 1, 1); - rm_check_image_exception(image, RetainOnError); -#endif if (pixel) { @@ -9870,17 +9689,10 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self) } *pixel = new_color; -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif -#if defined(HAVE_GETAUTHENTICPIXELS) || defined(HAVE_SYNCAUTHENTICPIXELS) (void) DestroyExceptionInfo(&exception); -#endif return Pixel_from_PixelPacket(&old_color); } @@ -10225,76 +10037,48 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self) case XorQuantumOperator: qop = XorEvaluateOperator; break; -#if defined(HAVE_ENUM_POWEVALUATEOPERATOR) case PowQuantumOperator: qop = PowEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_LOGEVALUATEOPERATOR) case LogQuantumOperator: qop = LogEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR) case ThresholdQuantumOperator: qop = ThresholdEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR) case ThresholdBlackQuantumOperator: qop = ThresholdBlackEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR) case ThresholdWhiteQuantumOperator: qop = ThresholdWhiteEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR) case GaussianNoiseQuantumOperator: qop = GaussianNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR) case ImpulseNoiseQuantumOperator: qop = ImpulseNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR) case LaplacianNoiseQuantumOperator: qop = LaplacianNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR) case MultiplicativeNoiseQuantumOperator: qop = MultiplicativeNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR) case PoissonNoiseQuantumOperator: qop = PoissonNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR) case UniformNoiseQuantumOperator: qop = UniformNoiseEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR) case CosineQuantumOperator: qop = CosineEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_SINEEVALUATEOPERATOR) case SineQuantumOperator: qop = SineEvaluateOperator; break; -#endif -#if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR) case AddModulusQuantumOperator: qop = AddModulusEvaluateOperator; break; -#endif } GetExceptionInfo(&exception); @@ -10346,15 +10130,11 @@ Image_quantize(int argc, VALUE *argv, VALUE self) case 4: quantize_info.tree_depth = NUM2UINT(argv[3]); case 3: -#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; } -#else - quantize_info.dither = (MagickBooleanType) RTEST(argv[2]); -#endif case 2: VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType); case 1: @@ -10687,6 +10467,10 @@ Image_recolor(VALUE self, VALUE color_matrix) double *matrix; ExceptionInfo exception; +#if defined(HAVE_COLORMATRIXIMAGE) + KernelInfo *kernel_info; +#endif + image = rm_check_destroyed(self); GetExceptionInfo(&exception); @@ -10702,7 +10486,19 @@ Image_recolor(VALUE self, VALUE color_matrix) order = (unsigned long)sqrt((double)(len + 1.0)); // RecolorImage sets the ExceptionInfo and returns a NULL image if an error occurs. +#if defined(HAVE_COLORMATRIXIMAGE) + kernel_info = AcquireKernelInfo("1"); + if (kernel_info == (KernelInfo *) NULL) + return((Image *) NULL); + kernel_info->width = order; + kernel_info->height = order; + kernel_info->values = (double *) matrix; + new_image = ColorMatrixImage(image, kernel_info, &exception); + kernel_info->values = (double *) NULL; + kernel_info = DestroyKernelInfo(kernel_info); +#else new_image = RecolorImage(image, order, matrix, &exception); +#endif xfree((void *)matrix); rm_check_exception(&exception, new_image, DestroyOnError); @@ -10831,7 +10627,11 @@ Image_reduce_noise(VALUE self, VALUE radius) image = rm_check_destroyed(self); GetExceptionInfo(&exception); +#if defined(HAVE_STATISTICIMAGE) + new_image = StatisticImage(image, NonpeakStatistic, (size_t)NUM2DBL(radius), (size_t)NUM2DBL(radius), &exception); +#else new_image = ReduceNoiseImage(image, NUM2DBL(radius), &exception); +#endif rm_check_exception(&exception, new_image, DestroyOnError); (void) DestroyExceptionInfo(&exception); @@ -10858,7 +10658,6 @@ Image_reduce_noise(VALUE self, VALUE radius) VALUE Image_remap(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_REMAPIMAGE) || defined(HAVE_AFFINITYIMAGE) Image *image, *remap_image; QuantizeInfo quantize_info; @@ -10884,21 +10683,10 @@ Image_remap(int argc, VALUE *argv, VALUE self) 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 } @@ -12241,7 +12029,6 @@ Image_spaceship(VALUE self, VALUE other) } -#if defined(HAVE_SPARSECOLORIMAGE) /** * Count the number of channels from the specified list are in an image. Note * that this method also removes invalid channels based on the image. @@ -12289,7 +12076,6 @@ count_channels(Image *image, ChannelType *channels) return ncolors; } -#endif /** @@ -12318,7 +12104,6 @@ count_channels(Image *image, ChannelType *channels) VALUE Image_sparse_color(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_SPARSECOLORIMAGE) Image *image, *new_image; unsigned long x, nargs, ncolors; SparseColorMethod method; @@ -12394,14 +12179,6 @@ Image_sparse_color(int argc, VALUE *argv, VALUE self) rm_ensure_result(new_image); return rm_image_new(new_image); - -#else - self = self; - argc = argc; - argv = argv; - rm_not_implemented(); - return(VALUE)0; -#endif } @@ -12714,18 +12491,11 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg // Get a pointer to the pixels. Replace the values with the PixelPackets // from the pixels argument. { -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_GETAUTHENTICPIXELS) ExceptionInfo exception; GetExceptionInfo(&exception); -#endif -#if defined(HAVE_GETAUTHENTICPIXELS) pixels = GetAuthenticPixels(image, x, y, cols, rows, &exception); CHECK_EXCEPTION() -#else - pixels = GetImagePixels(image, x, y, cols, rows); - rm_check_image_exception(image, RetainOnError); -#endif if (pixels) { @@ -12735,18 +12505,11 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg Data_Get_Struct(new_pixel, Pixel, pixel); pixels[n] = *pixel; } -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(image, &exception); CHECK_EXCEPTION() -#else - SyncImagePixels(image); - rm_check_image_exception(image, RetainOnError); -#endif } -#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_GETAUTHENTICPIXELS) DestroyExceptionInfo(&exception); -#endif } return self; @@ -12887,8 +12650,6 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj draw_info->fill_pattern = rm_clone_image(texture_image); new_image = rm_clone_image(image); - -#if defined(HAVE_FLOODFILLPAINTIMAGE) { MagickPixelPacket color_mpp; MagickBooleanType invert; @@ -12912,10 +12673,6 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert); } -#else - (void) ColorFloodfillImage(new_image, draw_info, color, x, y, method); -#endif - (void) DestroyDrawInfo(draw_info); rm_check_image_exception(new_image, DestroyOnError); @@ -13468,11 +13225,7 @@ Image_transparent(int argc, VALUE *argv, VALUE self) new_image = rm_clone_image(image); -#if defined(HAVE_TRANSPARENTPAINTIMAGE) okay = TransparentPaintImage(new_image, &color, opacity, MagickFalse); -#else - okay = PaintTransparentImage(new_image, &color, opacity); -#endif rm_check_image_exception(new_image, DestroyOnError); if (!okay) { @@ -13506,7 +13259,6 @@ Image_transparent(int argc, VALUE *argv, VALUE self) VALUE Image_transparent_chroma(int argc, VALUE *argv, VALUE self) { -#if defined(HAVE_TRANSPARENTPAINTIMAGECHROMA) Image *image, *new_image; Quantum opacity = TransparentOpacity; MagickPixelPacket low, high; @@ -13542,13 +13294,6 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self) } return rm_image_new(new_image); -#else - rm_not_implemented(); - return (VALUE)0; - argc = argc; - argv = argv; - self = self; -#endif } @@ -13874,7 +13619,6 @@ VALUE Image_image_type_eq(VALUE self, VALUE image_type) VALUE Image_undefine(VALUE self, VALUE artifact) { -#if defined(HAVE_REMOVEIMAGEARTIFACT) Image *image; char *key; long key_l; @@ -13883,12 +13627,6 @@ Image_undefine(VALUE self, VALUE artifact) key = rm_str2cstr(artifact, &key_l); (void) RemoveImageArtifact(image, key); return self; -#else - rm_not_implemented(); - artifact = artifact; - self = self; - return(VALUE)0; -#endif } @@ -14321,9 +14059,7 @@ Image_watermark(int argc, VALUE *argv, VALUE self) blend_geometry(geometry, sizeof(geometry), src_percent, dst_percent); (void) CloneString(&overlay->geometry, geometry); -#if defined(HAVE_SETIMAGEARTIFACT) (void) SetImageArtifact(overlay,"compose:args", geometry); -#endif new_image = rm_clone_image(image); (void) CompositeImage(new_image, ModulateCompositeOp, overlay, x_offset, y_offset); @@ -14497,11 +14233,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self) } -#if defined(HAVE_GETVIRTUALPIXELS) p = GetVirtualPixels(reflection, 0, y, image->columns, 1, &exception); -#else - p = AcquireImagePixels(reflection, 0, y, image->columns, 1, &exception); -#endif rm_check_exception(&exception, reflection, DestroyOnError); if (!p) { @@ -14509,11 +14241,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self) goto error; } -#if defined(HAVE_QUEUEAUTHENTICPIXELS) q = QueueAuthenticPixels(reflection, 0, y, image->columns, 1, &exception); -#else - q = SetImagePixels(reflection, 0, y, image->columns, 1); -#endif rm_check_exception(&exception, reflection, DestroyOnError); if (!q) { @@ -14528,14 +14256,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self) q[x].opacity = max(q[x].opacity, (Quantum)opacity); } - -#if defined(HAVE_SYNCAUTHENTICPIXELS) SyncAuthenticPixels(reflection, &exception); rm_check_exception(&exception, reflection, DestroyOnError); -#else - SyncImagePixels(reflection); - rm_check_image_exception(reflection, DestroyOnError); -#endif opacity += step; } diff --git a/ext/RMagick/rminfo.c b/ext/RMagick/rminfo.c index 3ef3e5607..06e60bd2b 100644 --- a/ext/RMagick/rminfo.c +++ b/ext/RMagick/rminfo.c @@ -960,11 +960,11 @@ Info_depth_eq(VALUE self, VALUE depth) switch (d) { case 8: // always okay -#if QuantumDepth == 16 || QuantumDepth == 32 || QuantumDepth == 64 +#if MAGICKCORE_QUANTUM_DEPTH == 16 || MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64 case 16: -#if QuantumDepth == 32 || QuantumDepth == 64 +#if MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64 case 32: -#if QuantumDepth == 64 +#if MAGICKCORE_QUANTUM_DEPTH == 64 case 64: #endif #endif diff --git a/ext/RMagick/rmmain.c b/ext/RMagick/rmmain.c index e5ebc92b6..810ea0dbc 100644 --- a/ext/RMagick/rmmain.c +++ b/ext/RMagick/rmmain.c @@ -30,7 +30,6 @@ static void version_constants(void); * Handle transferring ImageMagick memory allocations/frees to Ruby. * These functions have the same signature as the equivalent C functions. */ -#if defined(HAVE_SETMAGICKMEMORYMETHODS) /** * Allocate memory. * @@ -117,9 +116,6 @@ static void set_managed_memory(void) rb_define_const(Module_Magick, "MANAGED_MEMORY", Qfalse); } } -#endif - - /** @@ -138,11 +134,7 @@ Init_RMagick2(void) Module_Magick = rb_define_module("Magick"); -#if defined(HAVE_SETMAGICKMEMORYMETHODS) set_managed_memory(); -#else - rb_define_const(Module_Magick, "MANAGED_MEMORY", Qfalse); -#endif /*-----------------------------------------------------------------------*/ /* Create IDs for frequently used methods, etc. */ @@ -818,9 +810,8 @@ Init_RMagick2(void) // Miscellaneous fixed-point constants - DEF_CONST(MaxRGB); DEF_CONST(QuantumRange); - DEF_CONST(QuantumDepth); + DEF_CONST(MAGICKCORE_QUANTUM_DEPTH); DEF_CONST(OpaqueOpacity); DEF_CONST(TransparentOpacity); @@ -857,13 +848,11 @@ Init_RMagick2(void) ENUMERATOR(DeactivateAlphaChannel) ENUMERATOR(ResetAlphaChannel) /* deprecated */ ENUMERATOR(SetAlphaChannel) -#if defined(HAVE_ENUM_COPYALPHACHANNEL) ENUMERATOR(CopyAlphaChannel) ENUMERATOR(ExtractAlphaChannel) ENUMERATOR(OpaqueAlphaChannel) ENUMERATOR(ShapeAlphaChannel) ENUMERATOR(TransparentAlphaChannel) -#endif #if defined(HAVE_ENUM_BACKGROUNDALPHACHANNEL) ENUMERATOR(BackgroundAlphaChannel) #endif @@ -946,7 +935,7 @@ Init_RMagick2(void) ENUMERATOR(HSLColorspace) ENUMERATOR(HWBColorspace) ENUMERATOR(HSBColorspace) - ENUMERATOR(LABColorspace) + ENUMERATOR(LabColorspace) ENUMERATOR(Rec601LumaColorspace) ENUMERATOR(Rec601YCbCrColorspace) ENUMERATOR(Rec709LumaColorspace) @@ -1063,15 +1052,9 @@ Init_RMagick2(void) ENUMERATOR(B44ACompression) #endif ENUMERATOR(BZipCompression) -#if defined(HAVE_ENUM_DXT1COMPRESSION) ENUMERATOR(DXT1Compression) -#endif -#if defined(HAVE_ENUM_DXT3COMPRESSION) ENUMERATOR(DXT3Compression) -#endif -#if defined(HAVE_ENUM_DXT5COMPRESSION) ENUMERATOR(DXT5Compression) -#endif ENUMERATOR(FaxCompression) ENUMERATOR(Group4Compression) ENUMERATOR(JPEGCompression) @@ -1113,15 +1096,9 @@ Init_RMagick2(void) ENUMERATOR(AffineDistortion) ENUMERATOR(AffineProjectionDistortion) ENUMERATOR(ArcDistortion) -#if defined(HAVE_ENUM_POLARDISTORTION) ENUMERATOR(PolarDistortion) -#endif -#if defined(HAVE_ENUM_DEPOLARDISTORTION) ENUMERATOR(DePolarDistortion) -#endif -#if defined(HAVE_ENUM_BARRELDISTORTION) ENUMERATOR(BarrelDistortion) -#endif ENUMERATOR(BilinearDistortion) #if defined(HAVE_ENUM_BILINEARFORWARDDISTORTION) ENUMERATOR(BilinearForwardDistortion) @@ -1131,28 +1108,18 @@ Init_RMagick2(void) #endif ENUMERATOR(PerspectiveDistortion) ENUMERATOR(PerspectiveProjectionDistortion) -#if defined(HAVE_ENUM_POLYNOMIALDISTORTION) ENUMERATOR(PolynomialDistortion) -#endif ENUMERATOR(ScaleRotateTranslateDistortion) -#if defined(HAVE_ENUM_SHEPARDSDISTORTION) ENUMERATOR(ShepardsDistortion) -#endif -#if defined(HAVE_ENUM_BARRELINVERSEDISTORTION) ENUMERATOR(BarrelInverseDistortion) -#endif END_ENUM -#if defined(HAVE_TYPE_DITHERMETHOD) DEF_ENUM(DitherMethod) ENUMERATOR(UndefinedDitherMethod) -#if defined(HAVE_ENUM_NODITHERMETHOD) ENUMERATOR(NoDitherMethod) -#endif ENUMERATOR(RiemersmaDitherMethod) ENUMERATOR(FloydSteinbergDitherMethod) END_ENUM -#endif DEF_ENUM(EndianType) ENUMERATOR(UndefinedEndian) @@ -1178,24 +1145,12 @@ Init_RMagick2(void) ENUMERATOR(LanczosFilter) ENUMERATOR(BesselFilter) ENUMERATOR(SincFilter) -#if defined(HAVE_ENUM_KAISERFILTER) ENUMERATOR(KaiserFilter) -#endif -#if defined(HAVE_ENUM_WELSHFILTER) ENUMERATOR(WelshFilter) -#endif -#if defined(HAVE_ENUM_PARZENFILTER) ENUMERATOR(ParzenFilter) -#endif -#if defined(HAVE_ENUM_LAGRANGEFILTER) ENUMERATOR(LagrangeFilter) -#endif -#if defined(HAVE_ENUM_BOHMANFILTER) ENUMERATOR(BohmanFilter) -#endif -#if defined(HAVE_ENUM_BARTLETTFILTER) ENUMERATOR(BartlettFilter) -#endif END_ENUM // GravityType constants @@ -1256,7 +1211,6 @@ Init_RMagick2(void) #endif END_ENUM -#if defined(HAVE_TYPE_MAGICKFUNCTION) DEF_ENUM(MagickFunction) ENUMERATOR(UndefinedFunction) ENUMERATOR(PolynomialFunction) @@ -1268,13 +1222,8 @@ Init_RMagick2(void) ENUMERATOR(ArctanFunction) #endif END_ENUM -#endif -#if defined(HAVE_TYPE_IMAGELAYERMETHOD) DEF_ENUM(ImageLayerMethod) -#else - DEF_ENUM(MagickLayerMethod) -#endif ENUMERATOR(UndefinedLayer) ENUMERATOR(CompareAnyLayer) ENUMERATOR(CompareClearLayer) @@ -1290,18 +1239,10 @@ Init_RMagick2(void) ENUMERATOR(RemoveDupsLayer) ENUMERATOR(RemoveZeroLayer) ENUMERATOR(CompositeLayer) -#if defined(HAVE_ENUM_MERGELAYER) ENUMERATOR(MergeLayer) -#endif -#if defined(HAVE_ENUM_MOSAICLAYER) ENUMERATOR(MosaicLayer) -#endif -#if defined(HAVE_ENUM_FLATTENLAYER) ENUMERATOR(FlattenLayer) -#endif -#if defined(HAVE_ENUM_TRIMBOUNDSLAYER) ENUMERATOR(TrimBoundsLayer) -#endif END_ENUM DEF_ENUM(MetricType) @@ -1395,48 +1336,20 @@ Init_RMagick2(void) ENUMERATOR(RShiftQuantumOperator) ENUMERATOR(SubtractQuantumOperator) ENUMERATOR(XorQuantumOperator) -#if defined(HAVE_ENUM_POWEVALUATEOPERATOR) ENUMERATOR(PowQuantumOperator) -#endif -#if defined(HAVE_ENUM_LOGEVALUATEOPERATOR) ENUMERATOR(LogQuantumOperator) -#endif -#if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR) ENUMERATOR(ThresholdQuantumOperator) -#endif -#if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR) ENUMERATOR(ThresholdBlackQuantumOperator) -#endif -#if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR) ENUMERATOR(ThresholdWhiteQuantumOperator) -#endif -#if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR) ENUMERATOR(GaussianNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR) ENUMERATOR(ImpulseNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR) ENUMERATOR(LaplacianNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR) ENUMERATOR(MultiplicativeNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR) ENUMERATOR(PoissonNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR) ENUMERATOR(UniformNoiseQuantumOperator) -#endif -#if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR) ENUMERATOR(CosineQuantumOperator) -#endif -#if defined(HAVE_ENUM_SINEEVALUATEOPERATOR) ENUMERATOR(SineQuantumOperator) -#endif -#if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR) ENUMERATOR(AddModulusQuantumOperator) -#endif END_ENUM // RenderingIntent @@ -1455,7 +1368,6 @@ Init_RMagick2(void) ENUMERATOR(PixelsPerCentimeterResolution) END_ENUM -#if defined(HAVE_SPARSECOLORIMAGE) DEF_ENUM(SparseColorMethod) ENUMERATOR(UndefinedColorInterpolate) ENUMERATOR(BarycentricColorInterpolate) @@ -1464,7 +1376,6 @@ Init_RMagick2(void) ENUMERATOR(ShepardsColorInterpolate) ENUMERATOR(VoronoiColorInterpolate) END_ENUM -#endif // SpreadMethod DEF_ENUM(SpreadMethod) @@ -1523,12 +1434,8 @@ Init_RMagick2(void) ENUMERATOR(BlackVirtualPixelMethod) ENUMERATOR(GrayVirtualPixelMethod) ENUMERATOR(WhiteVirtualPixelMethod) -#if defined(HAVE_ENUM_HORIZONTALTILEVIRTUALPIXELMETHOD) ENUMERATOR(HorizontalTileVirtualPixelMethod) -#endif -#if defined(HAVE_ENUM_VERTICALTILEVIRTUALPIXELMETHOD) ENUMERATOR(VerticalTileVirtualPixelMethod) -#endif #if defined(HAVE_ENUM_HORIZONTALTILEEDGEVIRTUALPIXELMETHOD) ENUMERATOR(HorizontalTileEdgeVirtualPixelMethod) #endif @@ -1634,7 +1541,7 @@ Init_RMagick2(void) static void test_Magick_version(void) { - unsigned long version_number; + size_t version_number; const char *version_str; int x, n; ID bypass = rb_intern("RMAGICK_BYPASS_VERSION_TEST"); diff --git a/ext/RMagick/rmpixel.c b/ext/RMagick/rmpixel.c index bb1746fd0..c14eecf0f 100644 --- a/ext/RMagick/rmpixel.c +++ b/ext/RMagick/rmpixel.c @@ -962,7 +962,7 @@ Pixel_to_HSL(VALUE self) * Notes: * - Default compliance is AllCompliance * - Default matte is false - * - Default depth is QuantumDepth + * - Default depth is MAGICKCORE_QUANTUM_DEPTH * - Default hex is false * - The conversion respects the value of the 'opacity' field in the Pixel * @@ -983,7 +983,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self) ExceptionInfo exception; ComplianceType compliance = AllCompliance; unsigned int matte = MagickFalse; - unsigned int depth = QuantumDepth; + unsigned int depth = MAGICKCORE_QUANTUM_DEPTH; switch (argc) { @@ -996,10 +996,10 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self) switch (depth) { case 8: -#if QuantumDepth == 16 || QuantumDepth == 32 +#if MAGICKCORE_QUANTUM_DEPTH == 16 || MAGICKCORE_QUANTUM_DEPTH == 32 case 16: #endif -#if QuantumDepth == 32 +#if MAGICKCORE_QUANTUM_DEPTH == 32 case 32: #endif break; diff --git a/ext/RMagick/rmstruct.c b/ext/RMagick/rmstruct.c index 93eefb0d9..70f31c56b 100644 --- a/ext/RMagick/rmstruct.c +++ b/ext/RMagick/rmstruct.c @@ -347,7 +347,7 @@ Color_to_s(VALUE self) Export_ColorInfo(&ci, self); sprintf(buff, "name=%s, compliance=%s, " -#if (QuantumDepth == 32 || QuantumDepth == 64) && defined(HAVE_TYPE_LONG_DOUBLE) +#if (MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64) && defined(HAVE_TYPE_LONG_DOUBLE) "color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.opacity=%Lg ", #else "color.red=%g, color.green=%g, color.blue=%g, color.opacity=%g ", diff --git a/ext/RMagick/rmutil.c b/ext/RMagick/rmutil.c index e3e82cb90..4600d41b5 100644 --- a/ext/RMagick/rmutil.c +++ b/ext/RMagick/rmutil.c @@ -887,7 +887,6 @@ rm_set_property(Image *image, const char *property, const char *value) */ void rm_set_user_artifact(Image *images, Info *info) { -#if defined(HAVE_SETIMAGEARTIFACT) Image *image; const char *value; @@ -901,10 +900,6 @@ void rm_set_user_artifact(Image *images, Info *info) image = GetNextImageInList(image); } } -#else - images = images; - info = info; -#endif } @@ -940,7 +935,6 @@ rm_get_optional_arguments(VALUE img) } -#if defined(HAVE_SETIMAGEARTIFACT) /** * Copy image options from the Info structure to the Image structure. * @@ -966,7 +960,6 @@ static void copy_options(Image *image, Info *info) } } } -#endif /** @@ -1135,9 +1128,7 @@ void rm_sync_image_options(Image *image, Info *info) image->units = info->units; } -#if defined(HAVE_SETIMAGEARTIFACT) copy_options(image, info); -#endif } diff --git a/lib/RMagick.rb b/lib/RMagick.rb index e3b29de01..023afda9d 100644 --- a/lib/RMagick.rb +++ b/lib/RMagick.rb @@ -16,6 +16,15 @@ module Magick @exit_block_set_up = nil class << self + def const_missing(const_name) + old_const = [:MaxRGB, :QuantumDepth] + new_const = [:QuantumRange, :MAGICKCORE_QUANTUM_DEPTH] + super unless index = old_const.index(const_name) + + warn "#{old_const[index]} has been deprecated. Please use #{new_const[index]}" + const_get(new_const[index]) + end + def formats(&block) @formats ||= init_formats() if block_given? @@ -1833,7 +1842,6 @@ def shift end def slice(*args) - current = get_current() slice = @images.slice(*args) if slice ilist = self.class.new diff --git a/test/Image2.rb b/test/Image2.rb index 3a557de26..fc4277eb4 100644 --- a/test/Image2.rb +++ b/test/Image2.rb @@ -124,7 +124,6 @@ def test_convolve assert_raise(IndexError) { @img.convolve(5, kernel) } assert_raise(IndexError) { @img.convolve(order, "x") } assert_raise(TypeError) { @img.convolve(3, [1.0, 1.0, 1.0, 1.0, 'x', 1.0, 1.0, 1.0, 1.0]) } - assert_raise(Magick::ImageMagickError) { @img.convolve(2, [1.0, 1.0, 1.0, 1.0]) } end def test_convolve_channel @@ -582,7 +581,7 @@ def test_export_pixels_to_str end assert_nothing_raised do res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::LongPixel) - assert_equal(10*10*8, res.length) + assert_equal(10*10*1.size, res.length) end assert_nothing_raised do res = @img.export_pixels_to_str(0, 0, 10, 10, "I", Magick::FloatPixel) diff --git a/test/Image3.rb b/test/Image3.rb index eda7b9354..ca323bef3 100644 --- a/test/Image3.rb +++ b/test/Image3.rb @@ -10,7 +10,7 @@ Magick::GRAYColorspace, Magick::TransparentColorspace, Magick::OHTAColorspace, - Magick::LABColorspace, + Magick::LabColorspace, Magick::XYZColorspace, Magick::YCbCrColorspace, Magick::YCCColorspace, @@ -22,7 +22,6 @@ Magick::HSLColorspace, Magick::HWBColorspace, Magick::HSBColorspace, - Magick::LABColorspace, Magick::Rec601LumaColorspace, Magick::Rec601YCbCrColorspace, Magick::Rec709LumaColorspace, @@ -168,6 +167,11 @@ def test_remap end def test_resample + # From ImageMagick 6.7.9-0 + # Initialize image->x_resolution and y_resolution to 0 in image.c + # (previously they were initialized to DefaultResolution, which is 72.0). + @img.x_resolution = 72 + @img.y_resolution = 72 assert_nothing_raised { @img.resample } assert_nothing_raised { @img.resample(100) } assert_nothing_raised { @img.resample(100, 100) } @@ -406,7 +410,7 @@ def test_segment # Don't test colorspaces that require PsuedoColor images (ColorspaceTypes - [Magick::OHTAColorspace, - Magick::LABColorspace, + Magick::LabColorspace, Magick::XYZColorspace, Magick::YCbCrColorspace, Magick::YCCColorspace, diff --git a/test/ImageList2.rb b/test/ImageList2.rb index 7c530be18..e076b3327 100644 --- a/test/ImageList2.rb +++ b/test/ImageList2.rb @@ -100,7 +100,7 @@ def flatten_images end def test_from_blob - hat = File.open(FLOWER_HAT) + hat = File.open(FLOWER_HAT, 'rb') blob = hat.read assert_nothing_raised { @ilist.from_blob(blob) } assert_instance_of(Magick::Image, @ilist[0]) diff --git a/test/Image_attributes.rb b/test/Image_attributes.rb index f15f0c633..ff33b8c6d 100644 --- a/test/Image_attributes.rb +++ b/test/Image_attributes.rb @@ -287,7 +287,7 @@ def test_density end def test_depth - assert_equal(Magick::QuantumDepth, @img.depth) + assert_equal(Magick::MAGICKCORE_QUANTUM_DEPTH, @img.depth) assert_raise(NoMethodError) { @img.depth = 2 } end @@ -539,7 +539,7 @@ def test_quality def test_quantum_depth assert_nothing_raised { @img.quantum_depth } - assert_equal(Magick::QuantumDepth, @img.quantum_depth) + assert_equal(Magick::MAGICKCORE_QUANTUM_DEPTH, @img.quantum_depth) assert_raise(NoMethodError) { @img.quantum_depth = 8 } end diff --git a/test/Import_Export.rb b/test/Import_Export.rb index 73e24cba4..01269431b 100644 --- a/test/Import_Export.rb +++ b/test/Import_Export.rb @@ -42,7 +42,7 @@ def test_import_export_float def test_import_export pixels = @test.export_pixels(0, 0, @test.columns, @test.rows, "RGB") - case Magick::QuantumDepth + case Magick::MAGICKCORE_QUANTUM_DEPTH when 8 p = pixels.pack("C*") import(p, Magick::CharPixel) diff --git a/test/Info.rb b/test/Info.rb index 3d08af473..4dac67e2b 100644 --- a/test/Info.rb +++ b/test/Info.rb @@ -58,7 +58,7 @@ def test_authenticate def test_background_color assert_nothing_raised { @info.background_color = "red" } - red = Magick::Pixel.new(Magick::MaxRGB) + red = Magick::Pixel.new(Magick::QuantumRange) assert_nothing_raised { @info.background_color = red } assert_equal("red", @info.background_color) img = Magick::Image.new(20,20) { self.background_color = "red" } @@ -67,7 +67,7 @@ def test_background_color def test_border_color assert_nothing_raised { @info.border_color = "red" } - red = Magick::Pixel.new(Magick::MaxRGB) + red = Magick::Pixel.new(Magick::QuantumRange) assert_nothing_raised { @info.border_color = red } assert_equal("red", @info.border_color) img = Magick::Image.new(20,20) { self.border_color = "red" } @@ -185,7 +185,7 @@ def test_fuzz assert_nothing_raised { @info.fuzz = 50 } assert_equal(50, @info.fuzz) assert_nothing_raised { @info.fuzz = "50%" } - assert_equal(Magick::MaxRGB * 0.5, @info.fuzz) + assert_equal(Magick::QuantumRange * 0.5, @info.fuzz) end def test_gravity @@ -216,7 +216,7 @@ def test_label def test_matte_color assert_nothing_raised { @info.matte_color = "red" } - red = Magick::Pixel.new(Magick::MaxRGB) + red = Magick::Pixel.new(Magick::QuantumRange) assert_nothing_raised { @info.matte_color = red } assert_equal("red", @info.matte_color) img = Magick::Image.new(20,20) { self.matte_color = "red" } diff --git a/test/Pixel.rb b/test/Pixel.rb index 3135d68ed..a55252162 100644 --- a/test/Pixel.rb +++ b/test/Pixel.rb @@ -15,13 +15,13 @@ def test_hash hash = nil assert_nothing_raised { hash = @pixel.hash} assert_not_nil(hash) - assert_equal(-761981696, hash) + assert_equal(1385501952, hash) p = Magick::Pixel.new assert_equal(0, p.hash) p = Magick::Pixel.from_color('red') - assert_equal(-8388608, p.hash) + assert_equal(2139095040, p.hash) # Pixel.hash sacrifices the last bit of the opacity channel p = Magick::Pixel.new(0, 0, 0, 72) diff --git a/test/all_basic.rb b/test/all_basic.rb index 75e49c4a0..093e4bb83 100755 --- a/test/all_basic.rb +++ b/test/all_basic.rb @@ -11,7 +11,11 @@ module Unit class TestCase alias :_old_run_ :run def run(result, &blk) + begin method_name = RUBY_VERSION[/^1\.9|^2/] ? self.__name__ : @method_name + rescue + method_name = @method_name + end puts "Running #{method_name}" _old_run_(result, &blk) end @@ -25,7 +29,8 @@ def run(result, &blk) IMAGES_DIR = '../doc/ex/images' FILES = Dir[IMAGES_DIR+'/Button_*.gif'].sort FLOWER_HAT = IMAGES_DIR+'/Flower_Hat.jpg' -IMAGE_WITH_PROFILE = IMAGES_DIR+'/image_with_profile.jpg' +#IMAGE_WITH_PROFILE = IMAGES_DIR+'/image_with_profile.jpg' +IMAGE_WITH_PROFILE = IMAGES_DIR+'/Red_Rocks.jpg' require 'Image1.rb' require 'Image2.rb'