rmagick 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +32 -6
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +9 -9
  6. data/.rubocop_todo.yml +351 -17
  7. data/.travis.yml +14 -1
  8. data/CHANGELOG.md +55 -0
  9. data/CONTRIBUTING.md +11 -18
  10. data/README.textile +2 -2
  11. data/Rakefile +1 -1
  12. data/before_install_linux.sh +56 -19
  13. data/doc/ex/sparse_color.rb +5 -0
  14. data/doc/magick.html +9 -4
  15. data/doc/rvg.html +2 -2
  16. data/doc/rvgtut.html +1 -1
  17. data/examples/histogram.rb +1 -1
  18. data/ext/RMagick/extconf.rb +90 -264
  19. data/ext/RMagick/rmagick.c +28 -6
  20. data/ext/RMagick/rmagick.h +53 -199
  21. data/ext/RMagick/rmdraw.c +52 -70
  22. data/ext/RMagick/rmenum.c +332 -274
  23. data/ext/RMagick/rmfill.c +62 -112
  24. data/ext/RMagick/rmilist.c +27 -62
  25. data/ext/RMagick/rmimage.c +424 -634
  26. data/ext/RMagick/rminfo.c +46 -37
  27. data/ext/RMagick/rmkinfo.c +47 -42
  28. data/ext/RMagick/rmmain.c +125 -180
  29. data/ext/RMagick/rmmontage.c +5 -5
  30. data/ext/RMagick/rmpixel.c +133 -62
  31. data/ext/RMagick/rmstruct.c +14 -181
  32. data/ext/RMagick/rmutil.c +195 -111
  33. data/lib/rmagick/version.rb +2 -3
  34. data/lib/rvg/deep_equal.rb +1 -1
  35. data/lib/rvg/misc.rb +4 -4
  36. data/lib/rvg/units.rb +2 -2
  37. data/rmagick.gemspec +2 -2
  38. data/spec/rmagick/ImageList1_spec.rb +2 -2
  39. data/spec/rmagick/draw_spec.rb +4 -4
  40. data/spec/rmagick/image/composite_spec.rb +6 -1
  41. data/spec/rmagick/image/properties_spec.rb +8 -8
  42. data/test/Draw.rb +414 -0
  43. data/test/Enum.rb +76 -0
  44. data/test/Fill.rb +93 -0
  45. data/test/Image1.rb +9 -1
  46. data/test/Image2.rb +14 -4
  47. data/test/Image3.rb +73 -3
  48. data/test/ImageList1.rb +22 -9
  49. data/test/ImageList2.rb +41 -9
  50. data/test/Image_attributes.rb +45 -8
  51. data/test/Info.rb +102 -6
  52. data/test/Magick.rb +8 -1
  53. data/test/PolaroidOptions.rb +23 -0
  54. data/test/test_all_basic.rb +4 -0
  55. metadata +28 -8
  56. data/.hound.yml +0 -2
  57. data/wercker.yml +0 -10
@@ -11,7 +11,6 @@
11
11
  ******************************************************************************/
12
12
 
13
13
  #include "rmagick.h"
14
- #include "magick/xwindow.h" // XImageInfo
15
14
 
16
15
  /** Method that effects an image */
17
16
  typedef Image *(effector_t)(const Image *, const double, const double, ExceptionInfo *);
@@ -591,40 +590,8 @@ Image_alpha(int argc, VALUE *argv, VALUE self)
591
590
  image = rm_check_frozen(self);
592
591
  VALUE_TO_ENUM(argv[0], alpha, AlphaChannelType);
593
592
 
594
- #if defined(HAVE_SETIMAGEALPHACHANNEL)
595
- // Added in 6.3.6-9
596
593
  (void) SetImageAlphaChannel(image, alpha);
597
594
  rm_check_image_exception(image, RetainOnError);
598
- #else
599
- switch (alpha)
600
- {
601
- case ActivateAlphaChannel:
602
- image->matte = MagickTrue;
603
- break;
604
-
605
- case DeactivateAlphaChannel:
606
- image->matte = MagickFalse;
607
- break;
608
-
609
- case ResetAlphaChannel:
610
- if (image->matte == MagickFalse)
611
- {
612
- (void) SetImageOpacity(image, OpaqueOpacity);
613
- rm_check_image_exception(image, RetainOnError);
614
- }
615
- break;
616
-
617
- case SetAlphaChannel:
618
- (void) CompositeImage(image, CopyOpacityCompositeOp, image, 0, 0);
619
- rm_check_image_exception(image, RetainOnError);
620
- break;
621
-
622
- default:
623
- rb_raise(rb_eArgError, "unknown AlphaChannelType value");
624
- break;
625
- }
626
- #endif
627
-
628
595
  return argv[0];
629
596
  }
630
597
 
@@ -646,11 +613,7 @@ VALUE
646
613
  Image_alpha_q(VALUE self)
647
614
  {
648
615
  Image *image = rm_check_destroyed(self);
649
- #if defined(HAVE_GETIMAGEALPHACHANNEL)
650
616
  return GetImageAlphaChannel(image) ? Qtrue : Qfalse;
651
- #else
652
- return image->matte ? Qtrue : Qfalse;
653
- #endif
654
617
  }
655
618
 
656
619
 
@@ -672,6 +635,7 @@ Image_alpha_eq(VALUE self, VALUE type)
672
635
  {
673
636
  VALUE argv[1];
674
637
  argv[0] = type;
638
+ rb_warning("Image#alpha= is deprecated; use Image#alpha.");
675
639
  Image_alpha(1, argv, self);
676
640
  return type;
677
641
  }
@@ -922,15 +886,7 @@ auto_channel(int argc, VALUE *argv, VALUE self, MagickBooleanType (*fp)(Image *,
922
886
  VALUE
923
887
  Image_auto_gamma_channel(int argc, VALUE *argv, VALUE self)
924
888
  {
925
- #if defined(HAVE_AUTOGAMMAIMAGECHANNEL)
926
889
  return auto_channel(argc, argv, self, AutoGammaImageChannel);
927
- #else
928
- rm_not_implemented();
929
- return (VALUE) 0;
930
- argc = argc;
931
- argv = argv;
932
- self = self;
933
- #endif
934
890
  }
935
891
 
936
892
 
@@ -951,15 +907,7 @@ Image_auto_gamma_channel(int argc, VALUE *argv, VALUE self)
951
907
  VALUE
952
908
  Image_auto_level_channel(int argc, VALUE *argv, VALUE self)
953
909
  {
954
- #if defined(HAVE_AUTOLEVELIMAGECHANNEL)
955
910
  return auto_channel(argc, argv, self, AutoLevelImageChannel);
956
- #else
957
- rm_not_implemented();
958
- return (VALUE)0;
959
- argc = argc;
960
- argv = argv;
961
- self = self;
962
- #endif
963
911
  }
964
912
 
965
913
 
@@ -1081,7 +1029,7 @@ VALUE
1081
1029
  Image_background_color(VALUE self)
1082
1030
  {
1083
1031
  Image *image = rm_check_destroyed(self);
1084
- return rm_pixelpacket_to_color_name(image, &image->background_color);
1032
+ return rm_pixelcolor_to_color_name(image, &image->background_color);
1085
1033
  }
1086
1034
 
1087
1035
 
@@ -1099,7 +1047,7 @@ VALUE
1099
1047
  Image_background_color_eq(VALUE self, VALUE color)
1100
1048
  {
1101
1049
  Image *image = rm_check_frozen(self);
1102
- Color_to_PixelPacket(&image->background_color, color);
1050
+ Color_to_PixelColor(&image->background_color, color);
1103
1051
  return self;
1104
1052
  }
1105
1053
 
@@ -1220,6 +1168,7 @@ Image_bilevel_channel(int argc, VALUE *argv, VALUE self)
1220
1168
  {
1221
1169
  Image *image, *new_image;
1222
1170
  ChannelType channels;
1171
+ double threshold;
1223
1172
 
1224
1173
  image = rm_check_destroyed(self);
1225
1174
  channels = extract_channels(&argc, argv);
@@ -1233,9 +1182,10 @@ Image_bilevel_channel(int argc, VALUE *argv, VALUE self)
1233
1182
  rb_raise(rb_eArgError, "no threshold specified");
1234
1183
  }
1235
1184
 
1185
+ threshold = NUM2DBL(argv[0]);
1236
1186
  new_image = rm_clone_image(image);
1237
1187
 
1238
- (void)BilevelImageChannel(new_image, channels, NUM2DBL(argv[0]));
1188
+ (void)BilevelImageChannel(new_image, channels, threshold);
1239
1189
  rm_check_image_exception(new_image, DestroyOnError);
1240
1190
 
1241
1191
  return rm_image_new(new_image);
@@ -1625,9 +1575,7 @@ special_composite(Image *image, Image *overlay, double image_pct, double overlay
1625
1575
 
1626
1576
  blend_geometry(geometry, sizeof(geometry), image_pct, overlay_pct);
1627
1577
  (void) CloneString(&overlay->geometry, geometry);
1628
- #if defined(HAVE_SETIMAGEARTIFACT)
1629
1578
  (void) SetImageArtifact(overlay,"compose:args", geometry);
1630
- #endif
1631
1579
 
1632
1580
  new_image = rm_clone_image(image);
1633
1581
  (void) CompositeImage(new_image, op, overlay, x_off, y_off);
@@ -1727,7 +1675,6 @@ Image_blend(int argc, VALUE *argv, VALUE self)
1727
1675
  VALUE
1728
1676
  Image_blue_shift(int argc, VALUE *argv, VALUE self)
1729
1677
  {
1730
- #if defined(HAVE_BLUESHIFTIMAGE)
1731
1678
  Image *image, *new_image;
1732
1679
  double factor = 1.5;
1733
1680
  ExceptionInfo *exception;
@@ -1752,13 +1699,6 @@ Image_blue_shift(int argc, VALUE *argv, VALUE self)
1752
1699
  DestroyExceptionInfo(exception);
1753
1700
 
1754
1701
  return rm_image_new(new_image);
1755
- #else
1756
- rm_not_implemented();
1757
- return (VALUE)0;
1758
- argc = argc;
1759
- argv = argv;
1760
- self = self;
1761
- #endif
1762
1702
  }
1763
1703
 
1764
1704
 
@@ -1866,7 +1806,7 @@ static VALUE
1866
1806
  border(int bang, VALUE self, VALUE width, VALUE height, VALUE color)
1867
1807
  {
1868
1808
  Image *image, *new_image;
1869
- PixelPacket old_border;
1809
+ PixelColor old_border;
1870
1810
  ExceptionInfo *exception;
1871
1811
  RectangleInfo rect;
1872
1812
 
@@ -1878,7 +1818,7 @@ border(int bang, VALUE self, VALUE width, VALUE height, VALUE color)
1878
1818
 
1879
1819
  // Save current border color - we'll want to restore it afterwards.
1880
1820
  old_border = image->border_color;
1881
- Color_to_PixelPacket(&image->border_color, color);
1821
+ Color_to_PixelColor(&image->border_color, color);
1882
1822
 
1883
1823
  exception = AcquireExceptionInfo();
1884
1824
  new_image = BorderImage(image, &rect, exception);
@@ -1959,7 +1899,7 @@ VALUE
1959
1899
  Image_border_color(VALUE self)
1960
1900
  {
1961
1901
  Image *image = rm_check_destroyed(self);
1962
- return rm_pixelpacket_to_color_name(image, &image->border_color);
1902
+ return rm_pixelcolor_to_color_name(image, &image->border_color);
1963
1903
  }
1964
1904
 
1965
1905
 
@@ -1977,7 +1917,7 @@ VALUE
1977
1917
  Image_border_color_eq(VALUE self, VALUE color)
1978
1918
  {
1979
1919
  Image *image = rm_check_frozen(self);
1980
- Color_to_PixelPacket(&image->border_color, color);
1920
+ Color_to_PixelColor(&image->border_color, color);
1981
1921
  return self;
1982
1922
  }
1983
1923
 
@@ -2590,10 +2530,7 @@ Image_color_histogram(VALUE self)
2590
2530
  if (image->storage_class != DirectClass)
2591
2531
  {
2592
2532
  dc_copy = rm_clone_image(image);
2593
- (void) SyncImage(dc_copy);
2594
- magick_free(dc_copy->colormap);
2595
- dc_copy->colormap = NULL;
2596
- dc_copy->storage_class = DirectClass;
2533
+ (void) SetImageStorageClass(dc_copy, DirectClass);
2597
2534
  image = dc_copy;
2598
2535
  }
2599
2536
 
@@ -2608,18 +2545,21 @@ Image_color_histogram(VALUE self)
2608
2545
  }
2609
2546
  rb_raise(rb_eNoMemError, "not enough memory to continue");
2610
2547
  }
2611
- if (exception->severity != UndefinedException)
2548
+ if (rm_should_raise_exception(exception, DestroyExceptionRetention))
2612
2549
  {
2613
2550
  (void) RelinquishMagickMemory(histogram);
2614
- rm_check_exception(exception, dc_copy, DestroyOnError);
2615
- }
2551
+ if (dc_copy)
2552
+ {
2553
+ (void) DestroyImage(dc_copy);
2554
+ }
2616
2555
 
2617
- (void) DestroyExceptionInfo(exception);
2556
+ rm_raise_exception(exception);
2557
+ }
2618
2558
 
2619
2559
  hash = rb_hash_new();
2620
2560
  for (x = 0; x < colors; x++)
2621
2561
  {
2622
- pixel = Pixel_from_PixelPacket(&histogram[x].pixel);
2562
+ pixel = Pixel_from_PixelColor(&histogram[x].pixel);
2623
2563
  (void) rb_hash_aset(hash, pixel, ULONG2NUM((unsigned long)histogram[x].count));
2624
2564
  }
2625
2565
 
@@ -2671,6 +2611,11 @@ set_profile(VALUE self, const char *name, VALUE profile)
2671
2611
  exception = AcquireExceptionInfo();
2672
2612
  m = GetMagickInfo(name, exception);
2673
2613
  CHECK_EXCEPTION()
2614
+ if (!m)
2615
+ {
2616
+ (void) DestroyExceptionInfo(exception);
2617
+ rb_raise(rb_eArgError, "unknown name: %s", name);
2618
+ }
2674
2619
 
2675
2620
  info = CloneImageInfo(NULL);
2676
2621
  if (!info)
@@ -2690,14 +2635,21 @@ set_profile(VALUE self, const char *name, VALUE profile)
2690
2635
  profile_name = GetNextImageProfile(profile_image);
2691
2636
  while (profile_name)
2692
2637
  {
2693
- if (rm_strcasecmp(profile_name, name) == 0)
2638
+ /* Hack for versions of ImageMagick where the meta coder would change the iptc profile into an 8bim profile */
2639
+ if (rm_strcasecmp("8bim", profile_name) == 0 && rm_strcasecmp("iptc", name) == 0)
2640
+ {
2641
+ (void) ProfileImage(image, name, profile_blob, profile_length, MagickFalse);
2642
+ if (image->exception.severity >= ErrorException)
2643
+ {
2644
+ break;
2645
+ }
2646
+ }
2647
+ else if (rm_strcasecmp(profile_name, name) == 0)
2694
2648
  {
2695
2649
  profile_data = GetImageProfile(profile_image, profile_name);
2696
- if (profile)
2650
+ if (profile_data)
2697
2651
  {
2698
- (void)ProfileImage(image, profile_name, profile_data->datum
2699
- , (unsigned long)profile_data->length
2700
- , (MagickBooleanType)MagickFalse);
2652
+ (void) ProfileImage(image, name, GetStringInfoDatum(profile_data), GetStringInfoLength(profile_data), MagickFalse);
2701
2653
  if (image->exception.severity >= ErrorException)
2702
2654
  {
2703
2655
  break;
@@ -2797,18 +2749,20 @@ Image_color_flood_fill( VALUE self, VALUE target_color, VALUE fill_color
2797
2749
  , VALUE xv, VALUE yv, VALUE method)
2798
2750
  {
2799
2751
  Image *image, *new_image;
2800
- PixelPacket target;
2752
+ PixelColor target;
2801
2753
  DrawInfo *draw_info;
2802
- PixelPacket fill;
2754
+ PixelColor fill;
2803
2755
  long x, y;
2804
2756
  int fill_method;
2757
+ MagickPixel target_mpp;
2758
+ MagickBooleanType invert;
2805
2759
 
2806
2760
  image = rm_check_destroyed(self);
2807
2761
 
2808
2762
  // The target and fill args can be either a color name or
2809
2763
  // a Magick::Pixel.
2810
- Color_to_PixelPacket(&target, target_color);
2811
- Color_to_PixelPacket(&fill, fill_color);
2764
+ Color_to_PixelColor(&target, target_color);
2765
+ Color_to_PixelColor(&fill, fill_color);
2812
2766
 
2813
2767
  x = NUM2LONG(xv);
2814
2768
  y = NUM2LONG(yv);
@@ -2834,32 +2788,24 @@ Image_color_flood_fill( VALUE self, VALUE target_color, VALUE fill_color
2834
2788
 
2835
2789
  new_image = rm_clone_image(image);
2836
2790
 
2837
- #if defined(HAVE_FLOODFILLPAINTIMAGE)
2791
+ rm_init_magickpixel(new_image, &target_mpp);
2792
+ if (fill_method == FillToBorderMethod)
2838
2793
  {
2839
- MagickPixelPacket target_mpp;
2840
- MagickBooleanType invert;
2794
+ invert = MagickTrue;
2795
+ target_mpp.red = (MagickRealType) image->border_color.red;
2796
+ target_mpp.green = (MagickRealType) image->border_color.green;
2797
+ target_mpp.blue = (MagickRealType) image->border_color.blue;
2798
+ }
2799
+ else
2800
+ {
2801
+ invert = MagickFalse;
2802
+ target_mpp.red = (MagickRealType) target.red;
2803
+ target_mpp.green = (MagickRealType) target.green;
2804
+ target_mpp.blue = (MagickRealType) target.blue;
2805
+ }
2841
2806
 
2842
- GetMagickPixelPacket(new_image, &target_mpp);
2843
- if (fill_method == FillToBorderMethod)
2844
- {
2845
- invert = MagickTrue;
2846
- target_mpp.red = (MagickRealType) image->border_color.red;
2847
- target_mpp.green = (MagickRealType) image->border_color.green;
2848
- target_mpp.blue = (MagickRealType) image->border_color.blue;
2849
- }
2850
- else
2851
- {
2852
- invert = MagickFalse;
2853
- target_mpp.red = (MagickRealType) target.red;
2854
- target_mpp.green = (MagickRealType) target.green;
2855
- target_mpp.blue = (MagickRealType) target.blue;
2856
- }
2807
+ (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert);
2857
2808
 
2858
- (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert);
2859
- }
2860
- #else
2861
- (void) ColorFloodfillImage(new_image, draw_info, target, x, y, (PaintMethod)fill_method);
2862
- #endif
2863
2809
  // No need to check for error
2864
2810
 
2865
2811
  (void) DestroyDrawInfo(draw_info);
@@ -2886,7 +2832,7 @@ Image_colorize(int argc, VALUE *argv, VALUE self)
2886
2832
  Image *image, *new_image;
2887
2833
  double red, green, blue, matte;
2888
2834
  char opacity[50];
2889
- PixelPacket target;
2835
+ PixelColor target;
2890
2836
  ExceptionInfo *exception;
2891
2837
 
2892
2838
  image = rm_check_destroyed(self);
@@ -2896,7 +2842,7 @@ Image_colorize(int argc, VALUE *argv, VALUE self)
2896
2842
  red = floor(100*NUM2DBL(argv[0])+0.5);
2897
2843
  green = floor(100*NUM2DBL(argv[1])+0.5);
2898
2844
  blue = floor(100*NUM2DBL(argv[2])+0.5);
2899
- Color_to_PixelPacket(&target, argv[3]);
2845
+ Color_to_PixelColor(&target, argv[3]);
2900
2846
  sprintf(opacity, "%f/%f/%f", red, green, blue);
2901
2847
  }
2902
2848
  else if (argc == 5)
@@ -2905,7 +2851,7 @@ Image_colorize(int argc, VALUE *argv, VALUE self)
2905
2851
  green = floor(100*NUM2DBL(argv[1])+0.5);
2906
2852
  blue = floor(100*NUM2DBL(argv[2])+0.5);
2907
2853
  matte = floor(100*NUM2DBL(argv[3])+0.5);
2908
- Color_to_PixelPacket(&target, argv[4]);
2854
+ Color_to_PixelColor(&target, argv[4]);
2909
2855
  sprintf(opacity, "%f/%f/%f/%f", red, green, blue, matte);
2910
2856
  }
2911
2857
  else
@@ -2946,7 +2892,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
2946
2892
  {
2947
2893
  Image *image;
2948
2894
  unsigned long idx;
2949
- PixelPacket color, new_color;
2895
+ PixelColor color, new_color;
2950
2896
 
2951
2897
  image = rm_check_destroyed(self);
2952
2898
 
@@ -2975,7 +2921,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
2975
2921
  {
2976
2922
  rb_raise(rb_eIndexError, "index out of range");
2977
2923
  }
2978
- return rm_pixelpacket_to_color_name(image, &image->colormap[idx]);
2924
+ return rm_pixelcolor_to_color_name(image, &image->colormap[idx]);
2979
2925
  }
2980
2926
 
2981
2927
  // This is a "set" operation. Things are different.
@@ -2984,24 +2930,24 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
2984
2930
 
2985
2931
  // Replace with new color? The arg can be either a color name or
2986
2932
  // a Magick::Pixel.
2987
- Color_to_PixelPacket(&new_color, argv[1]);
2933
+ Color_to_PixelColor(&new_color, argv[1]);
2988
2934
 
2989
2935
  // Handle no colormap or current colormap too small.
2990
2936
  if (!image->colormap || idx > image->colors-1)
2991
2937
  {
2992
- PixelPacket black;
2938
+ PixelColor black;
2993
2939
  unsigned long i;
2994
2940
 
2995
2941
  memset(&black, 0, sizeof(black));
2996
2942
 
2997
2943
  if (!image->colormap)
2998
2944
  {
2999
- image->colormap = (PixelPacket *)magick_safe_malloc((idx+1), sizeof(PixelPacket));
2945
+ image->colormap = (PixelColor *)magick_safe_malloc((idx+1), sizeof(PixelColor));
3000
2946
  image->colors = 0;
3001
2947
  }
3002
2948
  else
3003
2949
  {
3004
- image->colormap = (PixelPacket *)magick_safe_realloc(image->colormap, (idx+1), sizeof(PixelPacket));
2950
+ image->colormap = (PixelColor *)magick_safe_realloc(image->colormap, (idx+1), sizeof(PixelColor));
3005
2951
  }
3006
2952
 
3007
2953
  for (i = image->colors; i < idx; i++)
@@ -3015,7 +2961,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
3015
2961
  color = image->colormap[idx];
3016
2962
  image->colormap[idx] = new_color;
3017
2963
 
3018
- return rm_pixelpacket_to_color_name(image, &color);
2964
+ return rm_pixelcolor_to_color_name(image, &color);
3019
2965
  }
3020
2966
 
3021
2967
  /**
@@ -3070,11 +3016,7 @@ Image_colorspace_eq(VALUE self, VALUE colorspace)
3070
3016
 
3071
3017
  image = rm_check_frozen(self);
3072
3018
  VALUE_TO_ENUM(colorspace, new_cs, ColorspaceType);
3073
- #if defined(HAVE_TRANSFORMIMAGECOLORSPACE)
3074
3019
  (void) TransformImageColorspace(image, new_cs);
3075
- #else
3076
- (void) SetImageColorspace(image, new_cs);
3077
- #endif
3078
3020
 
3079
3021
  return self;
3080
3022
  }
@@ -3521,9 +3463,10 @@ Image_composite_affine(VALUE self, VALUE source, VALUE affine_matrix)
3521
3463
 
3522
3464
  image = rm_check_destroyed(self);
3523
3465
  composite_image = rm_check_destroyed(source);
3524
- new_image = rm_clone_image(image);
3525
3466
 
3526
3467
  Export_AffineMatrix(&affine, affine_matrix);
3468
+ new_image = rm_clone_image(image);
3469
+
3527
3470
  (void) DrawAffineImage(new_image, composite_image, &affine);
3528
3471
  rm_check_image_exception(new_image, DestroyOnError);
3529
3472
 
@@ -3635,7 +3578,6 @@ Image_composite_channel_bang(int argc, VALUE *argv, VALUE self)
3635
3578
  VALUE
3636
3579
  Image_composite_mathematics(int argc, VALUE *argv, VALUE self)
3637
3580
  {
3638
- #if defined(HAVE_ENUM_MATHEMATICSCOMPOSITEOP)
3639
3581
  Image *composite_image;
3640
3582
  VALUE args[5];
3641
3583
  signed long x_off = 0L;
@@ -3680,14 +3622,6 @@ Image_composite_mathematics(int argc, VALUE *argv, VALUE self)
3680
3622
  args[4] = CompositeOperator_new(MathematicsCompositeOp);
3681
3623
 
3682
3624
  return composite(False, 5, args, self, DefaultChannels);
3683
-
3684
- #else
3685
- rm_not_implemented();
3686
- argc = argc;
3687
- argv = argv;
3688
- self = self;
3689
- return (VALUE)0;
3690
- #endif
3691
3625
  }
3692
3626
 
3693
3627
 
@@ -3756,11 +3690,7 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self)
3756
3690
  image = rm_clone_image(image);
3757
3691
  }
3758
3692
 
3759
- #if defined(HAVE_SETIMAGEARTIFACT)
3760
3693
  (void) SetImageArtifact(comp_image,"modify-outside-overlay", "false");
3761
- #else
3762
- (void) SetImageAttribute(comp_image, "[modify-outside-overlay]", "false");
3763
- #endif
3764
3694
 
3765
3695
  status = MagickTrue;
3766
3696
  columns = comp_image->columns;
@@ -3874,9 +3804,15 @@ Image_compression_eq(VALUE self, VALUE compression)
3874
3804
  VALUE
3875
3805
  Image_compress_colormap_bang(VALUE self)
3876
3806
  {
3807
+ MagickBooleanType okay;
3808
+
3877
3809
  Image *image = rm_check_frozen(self);
3878
- (void) CompressImageColormap(image);
3810
+ okay = CompressImageColormap(image);
3879
3811
  rm_check_image_exception(image, RetainOnError);
3812
+ if (!okay)
3813
+ {
3814
+ rb_warning("CompressImageColormap failed (probably DirectClass image)");
3815
+ }
3880
3816
 
3881
3817
  return self;
3882
3818
  }
@@ -3910,7 +3846,6 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3910
3846
  , VALUE map_arg, VALUE pixels_arg)
3911
3847
  {
3912
3848
  Image *image;
3913
- ExceptionInfo *exception;
3914
3849
  VALUE pixel, pixel0;
3915
3850
  unsigned long width, height;
3916
3851
  long x, npixels;
@@ -3978,6 +3913,7 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3978
3913
  pixel = rb_ary_entry(pixels_arg, x);
3979
3914
  if (rb_obj_is_kind_of(pixel, pixel_class) != Qtrue)
3980
3915
  {
3916
+ xfree(pixels.v);
3981
3917
  rb_raise(rb_eTypeError, "element %ld in pixel array is %s, expected %s"
3982
3918
  , x, rb_class2name(CLASS_OF(pixel)),rb_class2name(CLASS_OF(pixel0)));
3983
3919
  }
@@ -3986,6 +3922,7 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3986
3922
  pixels.f[x] = (float) NUM2DBL(pixel);
3987
3923
  if (pixels.f[x] < 0.0 || pixels.f[x] > 1.0)
3988
3924
  {
3925
+ xfree(pixels.v);
3989
3926
  rb_raise(rb_eArgError, "element %ld is out of range [0..1]: %f", x, pixels.f[x]);
3990
3927
  }
3991
3928
  }
@@ -3995,12 +3932,11 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3995
3932
  }
3996
3933
  }
3997
3934
 
3998
- exception = AcquireExceptionInfo();
3999
-
4000
3935
  // This is based on ConstituteImage in IM 5.5.7
4001
- image = AcquireImage(NULL);
3936
+ image = rm_acquire_image((ImageInfo *) NULL);
4002
3937
  if (!image)
4003
3938
  {
3939
+ xfree(pixels.v);
4004
3940
  rb_raise(rb_eNoMemError, "not enough memory to continue.");
4005
3941
  }
4006
3942
 
@@ -4014,11 +3950,6 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
4014
3950
  xfree(pixels.v);
4015
3951
  rm_check_image_exception(image, DestroyOnError);
4016
3952
 
4017
- (void) DestroyExceptionInfo(exception);
4018
- #if defined(HAVE_DESTROYCONSTITUTE) || defined(HAVE_CONSTITUTECOMPONENTTERMINUS)
4019
- DestroyConstitute();
4020
- #endif
4021
-
4022
3953
  RB_GC_GUARD(pixel);
4023
3954
  RB_GC_GUARD(pixel0);
4024
3955
  RB_GC_GUARD(pixel_class);
@@ -4279,7 +4210,16 @@ Image_convolve(VALUE self, VALUE order_arg, VALUE kernel_arg)
4279
4210
  kernel = (double *)ALLOC_N(double, order*order);
4280
4211
  for (x = 0; x < order*order; x++)
4281
4212
  {
4282
- kernel[x] = NUM2DBL(rb_ary_entry(kernel_arg, (long)x));
4213
+ VALUE element = rb_ary_entry(kernel_arg, (long)x);
4214
+ if (rm_check_num2dbl(element))
4215
+ {
4216
+ kernel[x] = NUM2DBL(element);
4217
+ }
4218
+ else
4219
+ {
4220
+ xfree((void *)kernel);
4221
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
4222
+ }
4283
4223
  }
4284
4224
 
4285
4225
  exception = AcquireExceptionInfo();
@@ -4343,7 +4283,16 @@ Image_convolve_channel(int argc, VALUE *argv, VALUE self)
4343
4283
  // Convert the kernel array argument to an array of doubles
4344
4284
  for (x = 0; x < order*order; x++)
4345
4285
  {
4346
- kernel[x] = NUM2DBL(rb_ary_entry(ary, (long)x));
4286
+ VALUE element = rb_ary_entry(ary, (long)x);
4287
+ if (rm_check_num2dbl(element))
4288
+ {
4289
+ kernel[x] = NUM2DBL(element);
4290
+ }
4291
+ else
4292
+ {
4293
+ xfree((void *)kernel);
4294
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
4295
+ }
4347
4296
  }
4348
4297
 
4349
4298
  exception = AcquireExceptionInfo();
@@ -4465,10 +4414,11 @@ Image_cycle_colormap(VALUE self, VALUE amount)
4465
4414
  Image *image, *new_image;
4466
4415
  int amt;
4467
4416
 
4468
- image = rm_check_destroyed(self);
4417
+ amt = NUM2INT(amount);
4469
4418
 
4419
+ image = rm_check_destroyed(self);
4470
4420
  new_image = rm_clone_image(image);
4471
- amt = NUM2INT(amount);
4421
+
4472
4422
  (void) CycleColormapImage(new_image, amt);
4473
4423
  // No need to check for an error
4474
4424
 
@@ -4586,7 +4536,6 @@ Image_density_eq(VALUE self, VALUE density_arg)
4586
4536
  VALUE
4587
4537
  Image_decipher(VALUE self, VALUE passphrase)
4588
4538
  {
4589
- #if defined(HAVE_ENCIPHERIMAGE)
4590
4539
  Image *image, *new_image;
4591
4540
  char *pf;
4592
4541
  ExceptionInfo *exception;
@@ -4609,12 +4558,6 @@ Image_decipher(VALUE self, VALUE passphrase)
4609
4558
  DestroyExceptionInfo(exception);
4610
4559
 
4611
4560
  return rm_image_new(new_image);
4612
- #else
4613
- self = self;
4614
- passphrase = passphrase;
4615
- rm_not_implemented();
4616
- return(VALUE)0;
4617
- #endif
4618
4561
  }
4619
4562
 
4620
4563
 
@@ -4638,7 +4581,6 @@ Image_decipher(VALUE self, VALUE passphrase)
4638
4581
  VALUE
4639
4582
  Image_define(VALUE self, VALUE artifact, VALUE value)
4640
4583
  {
4641
- #if defined(HAVE_SETIMAGEARTIFACT)
4642
4584
  Image *image;
4643
4585
  char *key, *val;
4644
4586
  MagickBooleanType status;
@@ -4663,13 +4605,6 @@ Image_define(VALUE self, VALUE artifact, VALUE value)
4663
4605
  }
4664
4606
 
4665
4607
  return value;
4666
- #else
4667
- rm_not_implemented();
4668
- artifact = artifact;
4669
- value = value;
4670
- self = self;
4671
- return(VALUE)0;
4672
- #endif
4673
4608
  }
4674
4609
 
4675
4610
 
@@ -4714,7 +4649,7 @@ VALUE
4714
4649
  Image_delete_profile(VALUE self, VALUE name)
4715
4650
  {
4716
4651
  Image *image = rm_check_frozen(self);
4717
- (void) ProfileImage(image, StringValuePtr(name), NULL, 0, MagickTrue);
4652
+ (void) DeleteImageProfile(image, StringValuePtr(name));
4718
4653
  rm_check_image_exception(image, RetainOnError);
4719
4654
 
4720
4655
  return self;
@@ -4774,7 +4709,6 @@ Image_depth(VALUE self)
4774
4709
  VALUE
4775
4710
  Image_deskew(int argc, VALUE *argv, VALUE self)
4776
4711
  {
4777
- #if defined(HAVE_DESKEWIMAGE)
4778
4712
  Image *image, *new_image;
4779
4713
  double threshold = 40.0 * QuantumRange / 100.0;
4780
4714
  unsigned long width;
@@ -4807,13 +4741,6 @@ Image_deskew(int argc, VALUE *argv, VALUE self)
4807
4741
  (void) DestroyExceptionInfo(exception);
4808
4742
 
4809
4743
  return rm_image_new(new_image);
4810
- #else
4811
- self = self; // defeat "unused parameter" message
4812
- argv = argv;
4813
- argc = argc;
4814
- rm_not_implemented();
4815
- return(VALUE)0;
4816
- #endif
4817
4744
  }
4818
4745
 
4819
4746
 
@@ -5302,13 +5229,20 @@ Image_distort(int argc, VALUE *argv, VALUE self)
5302
5229
  }
5303
5230
 
5304
5231
  npoints = RARRAY_LEN(pts);
5305
- // Allocate points array from Ruby's memory. If an error occurs Ruby will
5306
- // be able to clean it up.
5307
5232
  points = ALLOC_N(double, npoints);
5308
5233
 
5309
5234
  for (n = 0; n < npoints; n++)
5310
5235
  {
5311
- points[n] = NUM2DBL(rb_ary_entry(pts, n));
5236
+ VALUE element = rb_ary_entry(pts, n);
5237
+ if (rm_check_num2dbl(element))
5238
+ {
5239
+ points[n] = NUM2DBL(element);
5240
+ }
5241
+ else
5242
+ {
5243
+ xfree(points);
5244
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
5245
+ }
5312
5246
  }
5313
5247
 
5314
5248
  exception = AcquireExceptionInfo();
@@ -5664,7 +5598,6 @@ Image_emboss(int argc, VALUE *argv, VALUE self)
5664
5598
  VALUE
5665
5599
  Image_encipher(VALUE self, VALUE passphrase)
5666
5600
  {
5667
- #if defined(HAVE_ENCIPHERIMAGE)
5668
5601
  Image *image, *new_image;
5669
5602
  char *pf;
5670
5603
  ExceptionInfo *exception;
@@ -5687,12 +5620,6 @@ Image_encipher(VALUE self, VALUE passphrase)
5687
5620
  DestroyExceptionInfo(exception);
5688
5621
 
5689
5622
  return rm_image_new(new_image);
5690
- #else
5691
- self = self;
5692
- passphrase = passphrase;
5693
- rm_not_implemented();
5694
- return(VALUE)0;
5695
- #endif
5696
5623
  }
5697
5624
 
5698
5625
 
@@ -5808,7 +5735,6 @@ Image_equalize(VALUE self)
5808
5735
  VALUE
5809
5736
  Image_equalize_channel(int argc, VALUE *argv, VALUE self)
5810
5737
  {
5811
- #if defined(HAVE_EQUALIZEIMAGECHANNEL)
5812
5738
  Image *image, *new_image;
5813
5739
  ExceptionInfo *exception;
5814
5740
  ChannelType channels;
@@ -5830,13 +5756,6 @@ Image_equalize_channel(int argc, VALUE *argv, VALUE self)
5830
5756
  (void) DestroyExceptionInfo(exception);
5831
5757
 
5832
5758
  return rm_image_new(new_image);
5833
- #else
5834
- argc = argc;
5835
- argv = argv;
5836
- self = self;
5837
- rm_not_implemented();
5838
- return(VALUE) 0;
5839
- #endif
5840
5759
  }
5841
5760
 
5842
5761
 
@@ -6051,7 +5970,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6051
5970
  CHECK_EXCEPTION()
6052
5971
 
6053
5972
  // Should never get here...
6054
- rm_magick_error("ExportImagePixels failed with no explanation.", NULL);
5973
+ rm_magick_error("ExportImagePixels failed with no explanation.");
6055
5974
  }
6056
5975
 
6057
5976
  (void) DestroyExceptionInfo(exception);
@@ -6260,7 +6179,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6260
6179
  CHECK_EXCEPTION()
6261
6180
 
6262
6181
  // Should never get here...
6263
- rm_magick_error("ExportImagePixels failed with no explanation.", NULL);
6182
+ rm_magick_error("ExportImagePixels failed with no explanation.");
6264
6183
  }
6265
6184
 
6266
6185
  (void) DestroyExceptionInfo(exception);
@@ -6618,9 +6537,9 @@ Image_format_eq(VALUE self, VALUE magick)
6618
6537
 
6619
6538
  image = rm_check_frozen(self);
6620
6539
 
6621
- exception = AcquireExceptionInfo();
6622
-
6623
6540
  mgk = StringValuePtr(magick);
6541
+
6542
+ exception = AcquireExceptionInfo();
6624
6543
  m = GetMagickInfo(mgk, exception);
6625
6544
  CHECK_EXCEPTION()
6626
6545
 
@@ -6692,7 +6611,7 @@ Image_frame(int argc, VALUE *argv, VALUE self)
6692
6611
  switch (argc)
6693
6612
  {
6694
6613
  case 7:
6695
- Color_to_PixelPacket(&image->matte_color, argv[6]);
6614
+ Color_to_PixelColor(&image->matte_color, argv[6]);
6696
6615
  case 6:
6697
6616
  frame_info.outer_bevel = NUM2LONG(argv[5]);
6698
6617
  case 5:
@@ -6787,7 +6706,6 @@ Image_from_blob(VALUE class, VALUE blob_arg)
6787
6706
  VALUE
6788
6707
  Image_function_channel(int argc, VALUE *argv, VALUE self)
6789
6708
  {
6790
- #if defined(HAVE_FUNCTIONIMAGECHANNEL)
6791
6709
  Image *image, *new_image;
6792
6710
  MagickFunction function;
6793
6711
  unsigned long n, nparms;
@@ -6811,23 +6729,15 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
6811
6729
 
6812
6730
  switch (function)
6813
6731
  {
6814
- #if defined(HAVE_ENUM_POLYNOMIALFUNCTION)
6815
6732
  case PolynomialFunction:
6816
6733
  if (argc == 0)
6817
6734
  {
6818
6735
  rb_raise(rb_eArgError, "PolynomialFunction requires at least one argument.");
6819
6736
  }
6820
6737
  break;
6821
- #endif
6822
- #if defined(HAVE_ENUM_SINUSOIDFUNCTION)
6823
6738
  case SinusoidFunction:
6824
- #endif
6825
- #if defined(HAVE_ENUM_ARCSINFUNCTION)
6826
6739
  case ArcsinFunction:
6827
- #endif
6828
- #if defined(HAVE_ENUM_ARCTANFUNCTION)
6829
6740
  case ArctanFunction:
6830
- #endif
6831
6741
  if (argc < 1 || argc > 4)
6832
6742
  {
6833
6743
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc);
@@ -6843,7 +6753,16 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
6843
6753
 
6844
6754
  for (n = 0; n < nparms; n++)
6845
6755
  {
6846
- parms[n] = NUM2DBL(argv[n]);
6756
+ VALUE element = argv[n];
6757
+ if (rm_check_num2dbl(element))
6758
+ {
6759
+ parms[n] = NUM2DBL(element);
6760
+ }
6761
+ else
6762
+ {
6763
+ xfree(parms);
6764
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
6765
+ }
6847
6766
  }
6848
6767
 
6849
6768
  exception = AcquireExceptionInfo();
@@ -6854,13 +6773,6 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
6854
6773
  DestroyExceptionInfo(exception);
6855
6774
 
6856
6775
  return rm_image_new(new_image);
6857
- #else
6858
- rm_not_implemented();
6859
- return (VALUE)0;
6860
- argc = argc;
6861
- argv = argv;
6862
- self = self;
6863
- #endif
6864
6776
  }
6865
6777
 
6866
6778
 
@@ -6898,6 +6810,56 @@ Image_fuzz_eq(VALUE self, VALUE fuzz)
6898
6810
  }
6899
6811
 
6900
6812
 
6813
+ /**
6814
+ * Apply fx on the image.
6815
+ *
6816
+ * Ruby usage:
6817
+ * - @verbatim Image#fx(expression) @endverbatim
6818
+ * - @verbatim Image#fx(expression, channel) @endverbatim
6819
+ * - @verbatim Image#fx(expression, channel, ...) @endverbatim
6820
+ *
6821
+ * Notes:
6822
+ * - Default channel is AllChannels
6823
+ *
6824
+ * @param argc number of input arguments
6825
+ * @param argv array of input arguments
6826
+ * @param self this object
6827
+ * @return a new image
6828
+ */
6829
+ VALUE
6830
+ Image_fx(int argc, VALUE *argv, VALUE self)
6831
+ {
6832
+ Image *image, *new_image;
6833
+ char *expression;
6834
+ ChannelType channels;
6835
+ ExceptionInfo *exception;
6836
+
6837
+ image = rm_check_destroyed(self);
6838
+ channels = extract_channels(&argc, argv);
6839
+
6840
+ // There must be exactly 1 remaining argument.
6841
+ if (argc == 0)
6842
+ {
6843
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)");
6844
+ }
6845
+ else if (argc > 1)
6846
+ {
6847
+ raise_ChannelType_error(argv[argc-1]);
6848
+ }
6849
+
6850
+ expression = StringValuePtr(argv[0]);
6851
+
6852
+ exception = AcquireExceptionInfo();
6853
+ new_image = FxImageChannel(image, channels, expression, exception);
6854
+ rm_check_exception(exception, new_image, DestroyOnError);
6855
+ (void) DestroyExceptionInfo(exception);
6856
+
6857
+ rm_ensure_result(new_image);
6858
+
6859
+ return rm_image_new(new_image);
6860
+ }
6861
+
6862
+
6901
6863
  DEF_ATTR_ACCESSOR(Image, gamma, dbl)
6902
6864
 
6903
6865
 
@@ -6922,6 +6884,7 @@ Image_gamma_channel(int argc, VALUE *argv, VALUE self)
6922
6884
  {
6923
6885
  Image *image, *new_image;
6924
6886
  ChannelType channels;
6887
+ double gamma;
6925
6888
 
6926
6889
  image = rm_check_destroyed(self);
6927
6890
  channels = extract_channels(&argc, argv);
@@ -6936,9 +6899,10 @@ Image_gamma_channel(int argc, VALUE *argv, VALUE self)
6936
6899
  raise_ChannelType_error(argv[argc-1]);
6937
6900
  }
6938
6901
 
6902
+ gamma = NUM2DBL(argv[0]);
6939
6903
  new_image = rm_clone_image(image);
6940
6904
 
6941
- (void)GammaImageChannel(new_image, channels, NUM2DBL(argv[0]));
6905
+ (void)GammaImageChannel(new_image, channels, gamma);
6942
6906
  rm_check_image_exception(new_image, DestroyOnError);
6943
6907
 
6944
6908
  return rm_image_new(new_image);
@@ -6975,13 +6939,6 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
6975
6939
  {
6976
6940
  case 1:
6977
6941
  red_gamma = NUM2DBL(argv[0]);
6978
-
6979
- // Can't have all 4 gamma values == 1.0. Also, very small values
6980
- // cause ImageMagick to segv.
6981
- if (red_gamma == 1.0 || fabs(red_gamma) < 0.003)
6982
- {
6983
- rb_raise(rb_eArgError, "invalid gamma value (%f)", red_gamma);
6984
- }
6985
6942
  green_gamma = blue_gamma = red_gamma;
6986
6943
  break;
6987
6944
  case 2:
@@ -7190,11 +7147,7 @@ Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE row
7190
7147
  // Cast AcquireImagePixels to get rid of the const qualifier. We're not going
7191
7148
  // to change the pixels but I don't want to make "pixels" const.
7192
7149
  exception = AcquireExceptionInfo();
7193
- #if defined(HAVE_GETVIRTUALPIXELS)
7194
7150
  pixels = GetVirtualPixels(image, x, y, columns, rows, exception);
7195
- #else
7196
- pixels = AcquireImagePixels(image, x, y, columns, rows, exception);
7197
- #endif
7198
7151
  CHECK_EXCEPTION()
7199
7152
 
7200
7153
  (void) DestroyExceptionInfo(exception);
@@ -7260,7 +7213,30 @@ has_attribute(VALUE self, MagickBooleanType (attr_test)(const Image *, Exception
7260
7213
  VALUE
7261
7214
  Image_gray_q(VALUE self)
7262
7215
  {
7263
- return has_attribute(self, (MagickBooleanType (*)(const Image *, ExceptionInfo *))IsGrayImage);
7216
+ #if defined(HAVE_SETIMAGEGRAY)
7217
+ return has_attribute(self, (MagickBooleanType (*)(const Image *, ExceptionInfo *))SetImageGray);
7218
+ #else
7219
+ #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
7220
+ return has_attribute(self, IsGrayImage);
7221
+ #else
7222
+ // For ImageMagick 6.7
7223
+ Image *image;
7224
+ ColorspaceType colorspace;
7225
+ VALUE ret;
7226
+
7227
+ image = rm_check_destroyed(self);
7228
+ colorspace = image->colorspace;
7229
+ if (image->colorspace == sRGBColorspace || image->colorspace == TransparentColorspace) {
7230
+ // Workaround
7231
+ // If image colorspace has non-RGBColorspace, IsGrayImage() always return false.
7232
+ image->colorspace = RGBColorspace;
7233
+ }
7234
+
7235
+ ret = has_attribute(self, IsGrayImage);
7236
+ image->colorspace = colorspace;
7237
+ return ret;
7238
+ #endif
7239
+ #endif
7264
7240
  }
7265
7241
 
7266
7242
 
@@ -7449,26 +7425,38 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7449
7425
 
7450
7426
  if (stg_type == DoublePixel || stg_type == FloatPixel)
7451
7427
  {
7452
- // Get an array for double pixels. Use Ruby's memory so GC will clean up after
7453
- // us in case of an exception.
7454
7428
  fpixels = ALLOC_N(double, npixels);
7455
7429
  for (n = 0; n < npixels; n++)
7456
7430
  {
7457
- fpixels[n] = NUM2DBL(rb_ary_entry(pixel_ary, n));
7431
+ VALUE element = rb_ary_entry(pixel_ary, n);
7432
+ if (rm_check_num2dbl(element))
7433
+ {
7434
+ fpixels[n] = NUM2DBL(element);
7435
+ }
7436
+ else
7437
+ {
7438
+ xfree(fpixels);
7439
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
7440
+ }
7458
7441
  }
7459
7442
  buffer = (void *) fpixels;
7460
7443
  stg_type = DoublePixel;
7461
7444
  }
7462
7445
  else
7463
7446
  {
7464
- // Get array for Quantum pixels. Use Ruby's memory so GC will clean up after us
7465
- // in case of an exception.
7466
7447
  pixels = ALLOC_N(Quantum, npixels);
7467
7448
  for (n = 0; n < npixels; n++)
7468
7449
  {
7469
- VALUE p = rb_ary_entry(pixel_ary, n);
7470
- pixels[n] = NUM2QUANTUM(p);
7471
- RB_GC_GUARD(p);
7450
+ VALUE element = rb_ary_entry(pixel_ary, n);
7451
+ if (rm_check_num2dbl(element))
7452
+ {
7453
+ pixels[n] = NUM2DBL(element);
7454
+ }
7455
+ else
7456
+ {
7457
+ xfree(pixels);
7458
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
7459
+ }
7472
7460
  }
7473
7461
  buffer = (void *) pixels;
7474
7462
  stg_type = QuantumPixel;
@@ -7492,7 +7480,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7492
7480
  {
7493
7481
  rm_check_image_exception(image, RetainOnError);
7494
7482
  // Shouldn't get here...
7495
- rm_magick_error("ImportImagePixels failed with no explanation.", NULL);
7483
+ rm_magick_error("ImportImagePixels failed with no explanation.");
7496
7484
  }
7497
7485
 
7498
7486
  RB_GC_GUARD(pixel_arg);
@@ -7622,7 +7610,6 @@ build_inspect_string(Image *image, char *buffer, size_t len)
7622
7610
  }
7623
7611
 
7624
7612
 
7625
- #if defined(HAVE_SETIMAGEARTIFACT)
7626
7613
  if (len-1-x > 6)
7627
7614
  {
7628
7615
  size_t value_l;
@@ -7637,7 +7624,6 @@ build_inspect_string(Image *image, char *buffer, size_t len)
7637
7624
  x += value_l;
7638
7625
  }
7639
7626
  }
7640
- #endif
7641
7627
 
7642
7628
  assert(x < (int)(len-1));
7643
7629
  buffer[x] = '\0';
@@ -7757,10 +7743,10 @@ Image_iptc_profile(VALUE self)
7757
7743
  VALUE
7758
7744
  Image_iptc_profile_eq(VALUE self, VALUE profile)
7759
7745
  {
7760
- (void) Image_delete_profile(self, rb_str_new2("IPTC"));
7746
+ (void) Image_delete_profile(self, rb_str_new2("iptc"));
7761
7747
  if (profile != Qnil)
7762
7748
  {
7763
- (void) set_profile(self, "IPTC", profile);
7749
+ (void) set_profile(self, "iptc", profile);
7764
7750
  }
7765
7751
  return self;
7766
7752
  }
@@ -7918,9 +7904,8 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
7918
7904
  VALUE
7919
7905
  Image_level_colors(int argc, VALUE *argv, VALUE self)
7920
7906
  {
7921
- #if defined(HAVE_LEVELIMAGECOLORS) || defined(HAVE_LEVELCOLORSIMAGECHANNEL)
7922
7907
  Image *image, *new_image;
7923
- MagickPixelPacket black_color, white_color;
7908
+ MagickPixel black_color, white_color;
7924
7909
  ChannelType channels;
7925
7910
  ExceptionInfo *exception;
7926
7911
  MagickBooleanType invert = MagickTrue;
@@ -7930,38 +7915,27 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
7930
7915
 
7931
7916
  channels = extract_channels(&argc, argv);
7932
7917
 
7918
+ rm_init_magickpixel(image, &white_color);
7919
+ rm_init_magickpixel(image, &black_color);
7920
+
7933
7921
  switch (argc)
7934
7922
  {
7935
7923
  case 3:
7936
7924
  invert = RTEST(argv[2]);
7937
7925
 
7938
7926
  case 2:
7939
- Color_to_MagickPixelPacket(image, &white_color, argv[1]);
7940
- Color_to_MagickPixelPacket(image, &black_color, argv[0]);
7927
+ Color_to_MagickPixel(image, &white_color, argv[1]);
7928
+ Color_to_MagickPixel(image, &black_color, argv[0]);
7941
7929
  break;
7942
7930
 
7943
7931
  case 1:
7944
- Color_to_MagickPixelPacket(image, &black_color, argv[0]);
7945
- exception = AcquireExceptionInfo();
7946
-
7947
- GetMagickPixelPacket(image, &white_color);
7948
- (void) QueryMagickColor("white", &white_color, exception);
7949
- CHECK_EXCEPTION()
7950
-
7951
- DestroyExceptionInfo(exception);
7932
+ rm_set_magickpixel(&white_color, "white");
7933
+ Color_to_MagickPixel(image, &black_color, argv[0]);
7934
+ break;
7952
7935
 
7953
7936
  case 0:
7954
- exception = AcquireExceptionInfo();
7955
-
7956
- GetMagickPixelPacket(image, &white_color);
7957
- (void) QueryMagickColor("white", &white_color, exception);
7958
- CHECK_EXCEPTION()
7959
-
7960
- GetMagickPixelPacket(image, &black_color);
7961
- (void) QueryMagickColor("black", &black_color, exception);
7962
- CHECK_EXCEPTION()
7963
-
7964
- DestroyExceptionInfo(exception);
7937
+ rm_set_magickpixel(&white_color, "white");
7938
+ rm_set_magickpixel(&black_color, "black");
7965
7939
  break;
7966
7940
 
7967
7941
  default:
@@ -7971,11 +7945,7 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
7971
7945
 
7972
7946
  new_image = rm_clone_image(image);
7973
7947
 
7974
- #if defined(HAVE_LEVELCOLORSIMAGECHANNEL) // new in 6.5.6-4
7975
7948
  status = LevelColorsImageChannel(new_image, channels, &black_color, &white_color, invert);
7976
- #else
7977
- status = LevelImageColors(new_image, channels, &black_color, &white_color, invert);
7978
- #endif
7979
7949
  rm_check_image_exception(new_image, DestroyOnError);
7980
7950
  if (!status)
7981
7951
  {
@@ -7983,14 +7953,6 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
7983
7953
  }
7984
7954
 
7985
7955
  return rm_image_new(new_image);
7986
-
7987
- #else
7988
- rm_not_implemented();
7989
- self = self;
7990
- argc = argc;
7991
- argv = argv;
7992
- return(VALUE)0;
7993
- #endif
7994
7956
  }
7995
7957
 
7996
7958
 
@@ -8018,7 +7980,6 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8018
7980
  VALUE
8019
7981
  Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8020
7982
  {
8021
- #if defined(HAVE_LEVELIZEIMAGECHANNEL)
8022
7983
  Image *image, *new_image;
8023
7984
  ChannelType channels;
8024
7985
  double black_point, white_point;
@@ -8058,13 +8019,6 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8058
8019
  rb_raise(rb_eRuntimeError, "LevelizeImageChannel failed for unknown reason.");
8059
8020
  }
8060
8021
  return rm_image_new(new_image);
8061
- #else
8062
- rm_not_implemented();
8063
- self = self;
8064
- argc = argc;
8065
- argv = argv;
8066
- return(VALUE)0;
8067
- #endif
8068
8022
  }
8069
8023
 
8070
8024
 
@@ -8122,7 +8076,6 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
8122
8076
  VALUE
8123
8077
  Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
8124
8078
  {
8125
- #if defined(HAVE_LIQUIDRESCALEIMAGE)
8126
8079
  Image *image, *new_image;
8127
8080
  unsigned long cols, rows;
8128
8081
  double delta_x = 0.0;
@@ -8153,13 +8106,6 @@ Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
8153
8106
  rm_ensure_result(new_image);
8154
8107
 
8155
8108
  return rm_image_new(new_image);
8156
- #else
8157
- argc = argc; // defeat "unused parameter" messages
8158
- argv = argv;
8159
- self = self;
8160
- rm_not_implemented();
8161
- return(VALUE)0;
8162
- #endif
8163
8109
  }
8164
8110
 
8165
8111
 
@@ -8189,8 +8135,6 @@ Image__load(VALUE class, VALUE str)
8189
8135
 
8190
8136
  class = class; // Suppress "never referenced" message from icc
8191
8137
 
8192
- info = CloneImageInfo(NULL);
8193
-
8194
8138
  blob = rm_str2cstr(str, &length);
8195
8139
 
8196
8140
  // Must be as least as big as the 1st 4 fields in DumpedImage
@@ -8225,6 +8169,8 @@ Image__load(VALUE class, VALUE str)
8225
8169
  rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)");
8226
8170
  }
8227
8171
 
8172
+ info = CloneImageInfo(NULL);
8173
+
8228
8174
  memcpy(info->magick, ((DumpedImage *)blob)->magick, mi.len);
8229
8175
  info->magick[mi.len] = '\0';
8230
8176
 
@@ -8344,10 +8290,8 @@ Image_map(int argc, VALUE *argv, VALUE self)
8344
8290
  VALUE map_obj, map_arg;
8345
8291
  unsigned int dither = MagickFalse;
8346
8292
 
8347
- #if defined(HAVE_REMAPIMAGE)
8348
8293
  QuantizeInfo quantize_info;
8349
8294
  rb_warning("Image#map is deprecated. Use Image#remap instead");
8350
- #endif
8351
8295
 
8352
8296
  image = rm_check_destroyed(self);
8353
8297
 
@@ -8363,17 +8307,14 @@ Image_map(int argc, VALUE *argv, VALUE self)
8363
8307
  break;
8364
8308
  }
8365
8309
 
8366
- new_image = rm_clone_image(image);
8367
-
8368
8310
  map_obj = rm_cur_image(map_arg);
8369
8311
  map = rm_check_destroyed(map_obj);
8370
- #if defined(HAVE_REMAPIMAGE)
8312
+
8313
+ new_image = rm_clone_image(image);
8314
+
8371
8315
  GetQuantizeInfo(&quantize_info);
8372
8316
  quantize_info.dither=dither;
8373
8317
  (void) RemapImage(&quantize_info, new_image, map);
8374
- #else
8375
- (void) MapImage(new_image, map, dither);
8376
- #endif
8377
8318
  rm_check_image_exception(new_image, DestroyOnError);
8378
8319
 
8379
8320
  RB_GC_GUARD(map_obj);
@@ -8411,14 +8352,7 @@ Image_marshal_dump(VALUE self)
8411
8352
  }
8412
8353
 
8413
8354
  ary = rb_ary_new2(2);
8414
- if (image->filename)
8415
- {
8416
- rb_ary_store(ary, 0, rb_str_new2(image->filename));
8417
- }
8418
- else
8419
- {
8420
- rb_ary_store(ary, 0, Qnil);
8421
- }
8355
+ rb_ary_store(ary, 0, rb_str_new2(image->filename));
8422
8356
 
8423
8357
  exception = AcquireExceptionInfo();
8424
8358
  blob = ImageToBlob(info, image, &length, exception);
@@ -8518,7 +8452,7 @@ get_image_mask(Image *image)
8518
8452
  * @param self this object
8519
8453
  * @param mask the mask to use
8520
8454
  * @return copy of the current clip-mask or nil
8521
- * @deprecated Please use Image_mask(mask-image).
8455
+ * @deprecated This method has been deprecated. Please use Image_mask(mask-image).
8522
8456
  * @see Image_mask(mask-image)
8523
8457
  * @see get_image_mask
8524
8458
  */
@@ -8527,6 +8461,7 @@ Image_mask_eq(VALUE self, VALUE mask)
8527
8461
  {
8528
8462
  VALUE v[1];
8529
8463
  v[0] = mask;
8464
+ rb_warning("Image#mask= is deprecated; use Image#mask.");
8530
8465
  return Image_mask(1, v, self);
8531
8466
  }
8532
8467
 
@@ -8594,18 +8529,13 @@ Image_mask(int argc, VALUE *argv, VALUE self)
8594
8529
  }
8595
8530
 
8596
8531
  // The following section is copied from mogrify.c (6.2.8-8)
8597
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
8598
8532
  exception = AcquireExceptionInfo();
8599
- #endif
8533
+
8600
8534
  for (y = 0; y < (long) clip_mask->rows; y++)
8601
8535
  {
8602
- #if defined(HAVE_GETAUTHENTICPIXELS)
8603
8536
  q = GetAuthenticPixels(clip_mask, 0, y, clip_mask->columns, 1, exception);
8604
8537
  rm_check_exception(exception, clip_mask, DestroyOnError);
8605
- #else
8606
- q = GetImagePixels(clip_mask, 0, y, clip_mask->columns, 1);
8607
- rm_check_image_exception(clip_mask, DestroyOnError);
8608
- #endif
8538
+
8609
8539
  if (!q)
8610
8540
  {
8611
8541
  break;
@@ -8622,17 +8552,10 @@ Image_mask(int argc, VALUE *argv, VALUE self)
8622
8552
  q += 1;
8623
8553
  }
8624
8554
 
8625
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
8626
8555
  SyncAuthenticPixels(clip_mask, exception);
8627
8556
  rm_check_exception(exception, clip_mask, DestroyOnError);
8628
- #else
8629
- SyncImagePixels(clip_mask);
8630
- rm_check_image_exception(clip_mask, DestroyOnError);
8631
- #endif
8632
8557
  }
8633
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
8634
8558
  (void) DestroyExceptionInfo(exception);
8635
- #endif
8636
8559
 
8637
8560
  SetImageStorageClass(clip_mask, DirectClass);
8638
8561
  rm_check_image_exception(clip_mask, DestroyOnError);
@@ -8665,7 +8588,7 @@ Image_mask(int argc, VALUE *argv, VALUE self)
8665
8588
  *
8666
8589
  * @param self this object
8667
8590
  * @return the matte
8668
- * @deprecated Deprecated as of ImageMagick 6.3.6. See Image_alpha
8591
+ * @deprecated This method has been deprecated. Please use Image_alpha.
8669
8592
  * @see Image_alpha
8670
8593
  * @see Image_alpha_eq
8671
8594
  */
@@ -8675,6 +8598,7 @@ Image_matte(VALUE self)
8675
8598
  Image *image;
8676
8599
 
8677
8600
  image = rm_check_destroyed(self);
8601
+ rb_warning("Image#matte is deprecated; use Image#alpha.");
8678
8602
  return image->matte ? Qtrue : Qfalse;
8679
8603
  }
8680
8604
 
@@ -8688,14 +8612,13 @@ Image_matte(VALUE self)
8688
8612
  * @param self this object
8689
8613
  * @param matte the matte
8690
8614
  * @return the matte
8691
- * @deprecated Deprecated as of ImageMagick 6.3.6. See Image_alpha_eq
8615
+ * @deprecated This method has been deprecated. Please use Image_alpha.
8692
8616
  * @see Image_alpha_eq
8693
8617
  * @see Image_alpha
8694
8618
  */
8695
8619
  VALUE
8696
8620
  Image_matte_eq(VALUE self, VALUE matte)
8697
8621
  {
8698
- #if defined(HAVE_SETIMAGEALPHACHANNEL)
8699
8622
  VALUE alpha_channel_type;
8700
8623
 
8701
8624
  if (RTEST(matte))
@@ -8707,12 +8630,9 @@ Image_matte_eq(VALUE self, VALUE matte)
8707
8630
  alpha_channel_type = rb_const_get(Module_Magick, rb_intern("DeactivateAlphaChannel"));
8708
8631
  }
8709
8632
 
8633
+ rb_warning("Image#matte= is deprecated; use Image#alpha.");
8634
+
8710
8635
  return Image_alpha_eq(self, alpha_channel_type);
8711
- #else
8712
- Image *image = rm_check_frozen(self);
8713
- image->matte = RTEST(matte) ? MagickTrue : MagickFalse;
8714
- return matte;
8715
- #endif
8716
8636
  }
8717
8637
 
8718
8638
 
@@ -8729,7 +8649,7 @@ VALUE
8729
8649
  Image_matte_color(VALUE self)
8730
8650
  {
8731
8651
  Image *image = rm_check_destroyed(self);
8732
- return rm_pixelpacket_to_color_name(image, &image->matte_color);
8652
+ return rm_pixelcolor_to_color_name(image, &image->matte_color);
8733
8653
  }
8734
8654
 
8735
8655
  /**
@@ -8746,7 +8666,7 @@ VALUE
8746
8666
  Image_matte_color_eq(VALUE self, VALUE color)
8747
8667
  {
8748
8668
  Image *image = rm_check_frozen(self);
8749
- Color_to_PixelPacket(&image->matte_color, color);
8669
+ Color_to_PixelColor(&image->matte_color, color);
8750
8670
  return self;
8751
8671
  }
8752
8672
 
@@ -8769,13 +8689,16 @@ VALUE
8769
8689
  Image_matte_flood_fill(VALUE self, VALUE color, VALUE opacity, VALUE x_obj, VALUE y_obj, VALUE method_obj)
8770
8690
  {
8771
8691
  Image *image, *new_image;
8772
- PixelPacket target;
8692
+ PixelColor target;
8773
8693
  Quantum op;
8774
8694
  long x, y;
8775
8695
  PaintMethod method;
8696
+ DrawInfo *draw_info;
8697
+ MagickPixel target_mpp;
8698
+ MagickBooleanType invert;
8776
8699
 
8777
8700
  image = rm_check_destroyed(self);
8778
- Color_to_PixelPacket(&target, color);
8701
+ Color_to_PixelColor(&target, color);
8779
8702
 
8780
8703
  op = APP2QUANTUM(opacity);
8781
8704
 
@@ -8796,40 +8719,32 @@ Image_matte_flood_fill(VALUE self, VALUE color, VALUE opacity, VALUE x_obj, VALU
8796
8719
 
8797
8720
  new_image = rm_clone_image(image);
8798
8721
 
8799
- #if defined(HAVE_FLOODFILLPAINTIMAGE)
8722
+ // FloodfillPaintImage looks for the opacity in the DrawInfo.fill field.
8723
+ draw_info = CloneDrawInfo(NULL, NULL);
8724
+ if (!draw_info)
8800
8725
  {
8801
- DrawInfo *draw_info;
8802
- MagickPixelPacket target_mpp;
8803
- MagickBooleanType invert;
8726
+ rb_raise(rb_eNoMemError, "not enough memory to continue");
8727
+ }
8728
+ draw_info->fill.opacity = op;
8804
8729
 
8805
- // FloodfillPaintImage looks for the opacity in the DrawInfo.fill field.
8806
- draw_info = CloneDrawInfo(NULL, NULL);
8807
- if (!draw_info)
8808
- {
8809
- rb_raise(rb_eNoMemError, "not enough memory to continue");
8810
- }
8811
- draw_info->fill.opacity = op;
8730
+ if (method == FillToBorderMethod)
8731
+ {
8732
+ invert = MagickTrue;
8733
+ target_mpp.red = (MagickRealType) image->border_color.red;
8734
+ target_mpp.green = (MagickRealType) image->border_color.green;
8735
+ target_mpp.blue = (MagickRealType) image->border_color.blue;
8736
+ }
8737
+ else
8738
+ {
8739
+ invert = MagickFalse;
8740
+ target_mpp.red = (MagickRealType) target.red;
8741
+ target_mpp.green = (MagickRealType) target.green;
8742
+ target_mpp.blue = (MagickRealType) target.blue;
8743
+ }
8812
8744
 
8813
- if (method == FillToBorderMethod)
8814
- {
8815
- invert = MagickTrue;
8816
- target_mpp.red = (MagickRealType) image->border_color.red;
8817
- target_mpp.green = (MagickRealType) image->border_color.green;
8818
- target_mpp.blue = (MagickRealType) image->border_color.blue;
8819
- }
8820
- else
8821
- {
8822
- invert = MagickFalse;
8823
- target_mpp.red = (MagickRealType) target.red;
8824
- target_mpp.green = (MagickRealType) target.green;
8825
- target_mpp.blue = (MagickRealType) target.blue;
8826
- }
8745
+ (void) FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert);
8746
+ (void) DestroyDrawInfo(draw_info);
8827
8747
 
8828
- (void) FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert);
8829
- }
8830
- #else
8831
- (void) MatteFloodfillImage(new_image, target, op, x, y, method);
8832
- #endif
8833
8748
  rm_check_image_exception(new_image, DestroyOnError);
8834
8749
 
8835
8750
  return rm_image_new(new_image);
@@ -8873,11 +8788,7 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
8873
8788
  }
8874
8789
 
8875
8790
  exception = AcquireExceptionInfo();
8876
- #if defined(HAVE_STATISTICIMAGE)
8877
8791
  new_image = StatisticImage(image, MedianStatistic, (size_t)radius, (size_t)radius, exception);
8878
- #else
8879
- new_image = MedianFilterImage(image, radius, exception);
8880
- #endif
8881
8792
  rm_check_exception(exception, new_image, DestroyOnError);
8882
8793
 
8883
8794
  (void) DestroyExceptionInfo(exception);
@@ -9061,10 +8972,6 @@ Image_monitor_eq(VALUE self, VALUE monitor)
9061
8972
  (void) SetImageProgressMonitor(image, rm_progress_monitor, (void *)monitor);
9062
8973
  }
9063
8974
 
9064
- #if defined(_WIN32)
9065
- rb_warn("Image#monitor= does not work on Windows");
9066
- #endif
9067
-
9068
8975
  return self;
9069
8976
  }
9070
8977
 
@@ -9082,7 +8989,7 @@ Image_monitor_eq(VALUE self, VALUE monitor)
9082
8989
  VALUE
9083
8990
  Image_monochrome_q(VALUE self)
9084
8991
  {
9085
- return has_attribute(self, (MagickBooleanType (*)(const Image *, ExceptionInfo *))IsMonochromeImage);
8992
+ return has_attribute(self, IsMonochromeImage);
9086
8993
  }
9087
8994
 
9088
8995
 
@@ -9345,7 +9252,7 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9345
9252
  info_obj = rm_info_new();
9346
9253
  Data_Get_Struct(info_obj, Info, info);
9347
9254
 
9348
- image = AcquireImage(info);
9255
+ image = rm_acquire_image(info);
9349
9256
  if (!image)
9350
9257
  {
9351
9258
  rb_raise(rb_eNoMemError, "not enough memory to continue");
@@ -9589,22 +9496,19 @@ VALUE
9589
9496
  Image_opaque(VALUE self, VALUE target, VALUE fill)
9590
9497
  {
9591
9498
  Image *image, *new_image;
9592
- MagickPixelPacket target_pp;
9593
- MagickPixelPacket fill_pp;
9499
+ MagickPixel target_pp;
9500
+ MagickPixel fill_pp;
9594
9501
  MagickBooleanType okay;
9595
9502
 
9596
9503
  image = rm_check_destroyed(self);
9597
- new_image = rm_clone_image(image);
9598
9504
 
9599
9505
  // Allow color name or Pixel
9600
- Color_to_MagickPixelPacket(image, &target_pp, target);
9601
- Color_to_MagickPixelPacket(image, &fill_pp, fill);
9506
+ Color_to_MagickPixel(image, &target_pp, target);
9507
+ Color_to_MagickPixel(image, &fill_pp, fill);
9508
+
9509
+ new_image = rm_clone_image(image);
9602
9510
 
9603
- #if defined(HAVE_OPAQUEPAINTIMAGECHANNEL)
9604
9511
  okay = OpaquePaintImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse);
9605
- #else
9606
- okay = PaintOpaqueImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp);
9607
- #endif
9608
9512
  rm_check_image_exception(new_image, DestroyOnError);
9609
9513
 
9610
9514
  if (!okay)
@@ -9642,9 +9546,8 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
9642
9546
  VALUE
9643
9547
  Image_opaque_channel(int argc, VALUE *argv, VALUE self)
9644
9548
  {
9645
- #if defined(HAVE_OPAQUEPAINTIMAGECHANNEL)
9646
9549
  Image *image, *new_image;
9647
- MagickPixelPacket target_pp, fill_pp;
9550
+ MagickPixel target_pp, fill_pp;
9648
9551
  ChannelType channels;
9649
9552
  double keep, fuzz;
9650
9553
  MagickBooleanType okay, invert = MagickFalse;
@@ -9671,8 +9574,8 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
9671
9574
  invert = RTEST(argv[2]);
9672
9575
  case 2:
9673
9576
  // Allow color name or Pixel
9674
- Color_to_MagickPixelPacket(image, &fill_pp, argv[1]);
9675
- Color_to_MagickPixelPacket(image, &target_pp, argv[0]);
9577
+ Color_to_MagickPixel(image, &fill_pp, argv[1]);
9578
+ Color_to_MagickPixel(image, &target_pp, argv[0]);
9676
9579
  break;
9677
9580
  default:
9678
9581
  rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 2 or more)", argc);
@@ -9697,14 +9600,6 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
9697
9600
  }
9698
9601
 
9699
9602
  return rm_image_new(new_image);
9700
-
9701
- #else
9702
- argc = argc; // defeat "unused parameter" messages
9703
- argv = argv;
9704
- self = self;
9705
- rm_not_implemented();
9706
- return(VALUE)0;
9707
- #endif
9708
9603
  }
9709
9604
 
9710
9605
 
@@ -9892,9 +9787,8 @@ Image_page_eq(VALUE self, VALUE rect)
9892
9787
  VALUE
9893
9788
  Image_paint_transparent(int argc, VALUE *argv, VALUE self)
9894
9789
  {
9895
- #if defined(HAVE_TRANSPARENTPAINTIMAGE)
9896
9790
  Image *image, *new_image;
9897
- MagickPixelPacket color;
9791
+ MagickPixel color;
9898
9792
  Quantum opacity = TransparentOpacity;
9899
9793
  double keep, fuzz;
9900
9794
  MagickBooleanType okay, invert = MagickFalse;
@@ -9913,7 +9807,7 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
9913
9807
  case 2:
9914
9808
  opacity = APP2QUANTUM(argv[1]);
9915
9809
  case 1:
9916
- Color_to_MagickPixelPacket(image, &color, argv[0]);
9810
+ Color_to_MagickPixel(image, &color, argv[0]);
9917
9811
  break;
9918
9812
  default:
9919
9813
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc);
@@ -9926,7 +9820,7 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
9926
9820
  keep = new_image->fuzz;
9927
9821
  new_image->fuzz = fuzz;
9928
9822
 
9929
- okay = TransparentPaintImage(new_image, (const MagickPixelPacket *)&color, opacity, invert);
9823
+ okay = TransparentPaintImage(new_image, (const MagickPixel *)&color, opacity, invert);
9930
9824
  new_image->fuzz = keep;
9931
9825
 
9932
9826
  // Is it possible for TransparentPaintImage to silently fail?
@@ -9939,13 +9833,6 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
9939
9833
  }
9940
9834
 
9941
9835
  return rm_image_new(new_image);
9942
- #else
9943
- argc = argc; // defeat "unused parameter" messages
9944
- argv = argv;
9945
- self = self;
9946
- rm_not_implemented();
9947
- return(VALUE)0;
9948
- #endif
9949
9836
  }
9950
9837
 
9951
9838
 
@@ -10006,7 +9893,8 @@ VALUE
10006
9893
  Image_pixel_color(int argc, VALUE *argv, VALUE self)
10007
9894
  {
10008
9895
  Image *image;
10009
- PixelPacket old_color, new_color, *pixel;
9896
+ PixelColor new_color;
9897
+ PixelPacket old_color, *pixel;
10010
9898
  ExceptionInfo *exception;
10011
9899
  long x, y;
10012
9900
  unsigned int set = False;
@@ -10023,7 +9911,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10023
9911
  set = True;
10024
9912
  // Replace with new color? The arg can be either a color name or
10025
9913
  // a Magick::Pixel.
10026
- Color_to_PixelPacket(&new_color, argv[2]);
9914
+ Color_to_PixelColor(&new_color, argv[2]);
10027
9915
  case 2:
10028
9916
  break;
10029
9917
  default:
@@ -10038,11 +9926,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10038
9926
  if (!set)
10039
9927
  {
10040
9928
  exception = AcquireExceptionInfo();
10041
- #if defined(HAVE_GETVIRTUALPIXELS)
10042
9929
  old_color = *GetVirtualPixels(image, x, y, 1, 1, exception);
10043
- #else
10044
- old_color = *AcquireImagePixels(image, x, y, 1, 1, exception);
10045
- #endif
10046
9930
  CHECK_EXCEPTION()
10047
9931
 
10048
9932
  (void) DestroyExceptionInfo(exception);
@@ -10050,11 +9934,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10050
9934
  // PseudoClass
10051
9935
  if (image->storage_class == PseudoClass)
10052
9936
  {
10053
- #if defined(HAVE_GETAUTHENTICINDEXQUEUE)
10054
9937
  IndexPacket *indexes = GetAuthenticIndexQueue(image);
10055
- #else
10056
- IndexPacket *indexes = GetIndexes(image);
10057
- #endif
10058
9938
  old_color = image->colormap[(unsigned long)*indexes];
10059
9939
  }
10060
9940
  if (!image->matte)
@@ -10068,7 +9948,7 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10068
9948
  // Do what IM does and return the background color.
10069
9949
  if (x < 0 || y < 0 || (unsigned long)x >= image->columns || (unsigned long)y >= image->rows)
10070
9950
  {
10071
- return Pixel_from_PixelPacket(&image->background_color);
9951
+ return Pixel_from_PixelColor(&image->background_color);
10072
9952
  }
10073
9953
 
10074
9954
  // Set the color of a pixel. Return previous color.
@@ -10084,17 +9964,10 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10084
9964
  }
10085
9965
 
10086
9966
 
10087
- #if defined(HAVE_GETAUTHENTICPIXELS) || defined(HAVE_SYNCAUTHENTICPIXELS)
10088
9967
  exception = AcquireExceptionInfo();
10089
- #endif
10090
9968
 
10091
- #if defined(HAVE_GETAUTHENTICPIXELS)
10092
9969
  pixel = GetAuthenticPixels(image, x, y, 1, 1, exception);
10093
9970
  CHECK_EXCEPTION()
10094
- #else
10095
- pixel = GetImagePixels(image, x, y, 1, 1);
10096
- rm_check_image_exception(image, RetainOnError);
10097
- #endif
10098
9971
 
10099
9972
  if (pixel)
10100
9973
  {
@@ -10106,17 +9979,10 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10106
9979
  }
10107
9980
  *pixel = new_color;
10108
9981
 
10109
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
10110
9982
  SyncAuthenticPixels(image, exception);
10111
9983
  CHECK_EXCEPTION()
10112
- #else
10113
- SyncImagePixels(image);
10114
- rm_check_image_exception(image, RetainOnError);
10115
- #endif
10116
9984
 
10117
- #if defined(HAVE_GETAUTHENTICPIXELS) || defined(HAVE_SYNCAUTHENTICPIXELS)
10118
9985
  (void) DestroyExceptionInfo(exception);
10119
- #endif
10120
9986
 
10121
9987
  return Pixel_from_PixelPacket(&old_color);
10122
9988
  }
@@ -10286,10 +10152,10 @@ Image_preview(VALUE self, VALUE preview)
10286
10152
  PreviewType preview_type;
10287
10153
  ExceptionInfo *exception;
10288
10154
 
10289
- exception = AcquireExceptionInfo();
10290
10155
  image = rm_check_destroyed(self);
10291
10156
  VALUE_TO_ENUM(preview, preview_type, PreviewType);
10292
10157
 
10158
+ exception = AcquireExceptionInfo();
10293
10159
  new_image = PreviewImage(image, preview_type, exception);
10294
10160
  rm_check_exception(exception, new_image, DestroyOnError);
10295
10161
 
@@ -10463,75 +10329,67 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
10463
10329
  case XorQuantumOperator:
10464
10330
  qop = XorEvaluateOperator;
10465
10331
  break;
10466
- #if defined(HAVE_ENUM_POWEVALUATEOPERATOR)
10467
10332
  case PowQuantumOperator:
10468
10333
  qop = PowEvaluateOperator;
10469
10334
  break;
10470
- #endif
10471
- #if defined(HAVE_ENUM_LOGEVALUATEOPERATOR)
10472
10335
  case LogQuantumOperator:
10473
10336
  qop = LogEvaluateOperator;
10474
10337
  break;
10475
- #endif
10476
- #if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR)
10477
10338
  case ThresholdQuantumOperator:
10478
10339
  qop = ThresholdEvaluateOperator;
10479
10340
  break;
10480
- #endif
10481
- #if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR)
10482
10341
  case ThresholdBlackQuantumOperator:
10483
10342
  qop = ThresholdBlackEvaluateOperator;
10484
10343
  break;
10485
- #endif
10486
- #if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR)
10487
10344
  case ThresholdWhiteQuantumOperator:
10488
10345
  qop = ThresholdWhiteEvaluateOperator;
10489
10346
  break;
10490
- #endif
10491
- #if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR)
10492
10347
  case GaussianNoiseQuantumOperator:
10493
10348
  qop = GaussianNoiseEvaluateOperator;
10494
10349
  break;
10495
- #endif
10496
- #if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR)
10497
10350
  case ImpulseNoiseQuantumOperator:
10498
10351
  qop = ImpulseNoiseEvaluateOperator;
10499
10352
  break;
10500
- #endif
10501
- #if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR)
10502
10353
  case LaplacianNoiseQuantumOperator:
10503
10354
  qop = LaplacianNoiseEvaluateOperator;
10504
10355
  break;
10505
- #endif
10506
- #if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR)
10507
10356
  case MultiplicativeNoiseQuantumOperator:
10508
10357
  qop = MultiplicativeNoiseEvaluateOperator;
10509
10358
  break;
10510
- #endif
10511
- #if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR)
10512
10359
  case PoissonNoiseQuantumOperator:
10513
10360
  qop = PoissonNoiseEvaluateOperator;
10514
10361
  break;
10515
- #endif
10516
- #if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR)
10517
10362
  case UniformNoiseQuantumOperator:
10518
10363
  qop = UniformNoiseEvaluateOperator;
10519
10364
  break;
10520
- #endif
10521
- #if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR)
10522
10365
  case CosineQuantumOperator:
10523
10366
  qop = CosineEvaluateOperator;
10524
10367
  break;
10525
- #endif
10526
- #if defined(HAVE_ENUM_SINEEVALUATEOPERATOR)
10527
10368
  case SineQuantumOperator:
10528
10369
  qop = SineEvaluateOperator;
10529
10370
  break;
10530
- #endif
10531
- #if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR)
10532
10371
  case AddModulusQuantumOperator:
10533
10372
  qop = AddModulusEvaluateOperator;
10534
10373
  break;
10374
+ case MeanQuantumOperator:
10375
+ qop = MeanEvaluateOperator;
10376
+ break;
10377
+ case AbsQuantumOperator:
10378
+ qop = AbsEvaluateOperator;
10379
+ break;
10380
+ case ExponentialQuantumOperator:
10381
+ qop = ExponentialEvaluateOperator;
10382
+ break;
10383
+ case MedianQuantumOperator:
10384
+ qop = MedianEvaluateOperator;
10385
+ break;
10386
+ case SumQuantumOperator:
10387
+ qop = SumEvaluateOperator;
10388
+ break;
10389
+ #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10390
+ case RootMeanSquareQuantumOperator:
10391
+ qop = RootMeanSquareEvaluateOperator;
10392
+ break;
10535
10393
  #endif
10536
10394
  }
10537
10395
 
@@ -10584,15 +10442,15 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
10584
10442
  case 4:
10585
10443
  quantize_info.tree_depth = NUM2UINT(argv[3]);
10586
10444
  case 3:
10587
- #if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
10588
10445
  if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
10589
10446
  {
10590
10447
  VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
10591
10448
  quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
10592
10449
  }
10593
- #else
10594
- quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
10595
- #endif
10450
+ else
10451
+ {
10452
+ quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
10453
+ }
10596
10454
  case 2:
10597
10455
  VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
10598
10456
  case 1:
@@ -10624,18 +10482,19 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
10624
10482
  * @return a new image
10625
10483
  */
10626
10484
  VALUE
10627
- Image_radial_blur(VALUE self, VALUE angle)
10485
+ Image_radial_blur(VALUE self, VALUE angle_obj)
10628
10486
  {
10629
10487
  Image *image, *new_image;
10630
10488
  ExceptionInfo *exception;
10489
+ double angle = NUM2DBL(angle_obj);
10631
10490
 
10632
10491
  image = rm_check_destroyed(self);
10633
10492
  exception = AcquireExceptionInfo();
10634
10493
 
10635
- #if defined(HAVE_ROTATIONALBLURIMAGE)
10636
- new_image = RotationalBlurImage(image, NUM2DBL(angle), exception);
10494
+ #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10495
+ new_image = RotationalBlurImage(image, angle, exception);
10637
10496
  #else
10638
- new_image = RadialBlurImage(image, NUM2DBL(angle), exception);
10497
+ new_image = RadialBlurImage(image, angle, exception);
10639
10498
  #endif
10640
10499
  rm_check_exception(exception, new_image, DestroyOnError);
10641
10500
 
@@ -10670,6 +10529,7 @@ Image_radial_blur_channel(int argc, VALUE *argv, VALUE self)
10670
10529
  Image *image, *new_image;
10671
10530
  ExceptionInfo *exception;
10672
10531
  ChannelType channels;
10532
+ double angle;
10673
10533
 
10674
10534
  image = rm_check_destroyed(self);
10675
10535
  channels = extract_channels(&argc, argv);
@@ -10684,12 +10544,13 @@ Image_radial_blur_channel(int argc, VALUE *argv, VALUE self)
10684
10544
  raise_ChannelType_error(argv[argc-1]);
10685
10545
  }
10686
10546
 
10547
+ angle = NUM2DBL(argv[0]);
10687
10548
  exception = AcquireExceptionInfo();
10688
10549
 
10689
- #if defined(HAVE_ROTATIONALBLURIMAGECHANNEL)
10690
- new_image = RotationalBlurImageChannel(image, channels, NUM2DBL(argv[0]), exception);
10550
+ #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10551
+ new_image = RotationalBlurImageChannel(image, channels, angle, exception);
10691
10552
  #else
10692
- new_image = RadialBlurImageChannel(image, channels, NUM2DBL(argv[0]), exception);
10553
+ new_image = RadialBlurImageChannel(image, channels, angle, exception);
10693
10554
  #endif
10694
10555
  rm_check_exception(exception, new_image, DestroyOnError);
10695
10556
  (void) DestroyExceptionInfo(exception);
@@ -10885,12 +10746,12 @@ rd_image(VALUE class, VALUE file, reader_t reader)
10885
10746
 
10886
10747
  if (TYPE(file) == T_FILE)
10887
10748
  {
10888
- OpenFile *fptr;
10749
+ rb_io_t *fptr;
10889
10750
 
10890
10751
  // Ensure file is open - raise error if not
10891
10752
  GetOpenFile(file, fptr);
10892
10753
  rb_io_check_readable(fptr);
10893
- SetImageInfoFile(info, GetReadFile(fptr));
10754
+ SetImageInfoFile(info, rb_io_stdio_file(fptr));
10894
10755
  }
10895
10756
  else
10896
10757
  {
@@ -10940,13 +10801,10 @@ Image_recolor(VALUE self, VALUE color_matrix)
10940
10801
  long x, len;
10941
10802
  double *matrix;
10942
10803
  ExceptionInfo *exception;
10943
-
10944
- #if defined(HAVE_COLORMATRIXIMAGE)
10945
10804
  KernelInfo *kernel_info;
10946
- #endif
10947
10805
 
10948
10806
  image = rm_check_destroyed(self);
10949
- exception = AcquireExceptionInfo();
10807
+ color_matrix = rm_check_ary_type(color_matrix);
10950
10808
 
10951
10809
  // Allocate color matrix from Ruby's memory
10952
10810
  len = RARRAY_LEN(color_matrix);
@@ -10954,25 +10812,35 @@ Image_recolor(VALUE self, VALUE color_matrix)
10954
10812
 
10955
10813
  for (x = 0; x < len; x++)
10956
10814
  {
10957
- matrix[x] = NUM2DBL(rb_ary_entry(color_matrix, x));
10815
+ VALUE element = rb_ary_entry(color_matrix, x);
10816
+ if (rm_check_num2dbl(element))
10817
+ {
10818
+ matrix[x] = NUM2DBL(element);
10819
+ }
10820
+ else
10821
+ {
10822
+ xfree(matrix);
10823
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element)));
10824
+ }
10958
10825
  }
10959
10826
 
10960
10827
  order = (unsigned long)sqrt((double)(len + 1.0));
10961
10828
 
10962
10829
  // RecolorImage sets the ExceptionInfo and returns a NULL image if an error occurs.
10963
- #if defined(HAVE_COLORMATRIXIMAGE)
10964
- kernel_info = AcquireKernelInfo("1");
10830
+ kernel_info = AcquireKernelInfo(NULL);
10965
10831
  if (kernel_info == (KernelInfo *) NULL)
10966
- return((Image *) NULL);
10832
+ {
10833
+ xfree((void *)matrix);
10834
+ return Qnil;
10835
+ }
10967
10836
  kernel_info->width = order;
10968
10837
  kernel_info->height = order;
10969
10838
  kernel_info->values = (double *) matrix;
10839
+
10840
+ exception = AcquireExceptionInfo();
10970
10841
  new_image = ColorMatrixImage(image, kernel_info, exception);
10971
10842
  kernel_info->values = (double *) NULL;
10972
10843
  kernel_info = DestroyKernelInfo(kernel_info);
10973
- #else
10974
- new_image = RecolorImage(image, order, matrix, exception);
10975
- #endif
10976
10844
  xfree((void *)matrix);
10977
10845
 
10978
10846
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -11106,11 +10974,7 @@ Image_reduce_noise(VALUE self, VALUE radius)
11106
10974
  image = rm_check_destroyed(self);
11107
10975
 
11108
10976
  exception = AcquireExceptionInfo();
11109
- #if defined(HAVE_STATISTICIMAGE)
11110
10977
  new_image = StatisticImage(image, NonpeakStatistic, (size_t)radius, (size_t)radius, exception);
11111
- #else
11112
- new_image = ReduceNoiseImage(image, NUM2DBL(radius), exception);
11113
- #endif
11114
10978
  rm_check_exception(exception, new_image, DestroyOnError);
11115
10979
 
11116
10980
  (void) DestroyExceptionInfo(exception);
@@ -11137,7 +11001,6 @@ Image_reduce_noise(VALUE self, VALUE radius)
11137
11001
  VALUE
11138
11002
  Image_remap(int argc, VALUE *argv, VALUE self)
11139
11003
  {
11140
- #if defined(HAVE_REMAPIMAGE) || defined(HAVE_AFFINITYIMAGE)
11141
11004
  Image *image, *remap_image;
11142
11005
  QuantizeInfo quantize_info;
11143
11006
 
@@ -11164,21 +11027,10 @@ Image_remap(int argc, VALUE *argv, VALUE self)
11164
11027
  break;
11165
11028
  }
11166
11029
 
11167
- #if defined(HAVE_REMAPIMAGE)
11168
11030
  (void) RemapImage(&quantize_info, image, remap_image);
11169
- #else
11170
- (void) AffinityImage(&quantize_info, image, remap_image);
11171
- #endif
11172
11031
  rm_check_image_exception(image, RetainOnError);
11173
11032
 
11174
11033
  return self;
11175
- #else
11176
- self = self;
11177
- argc = argc;
11178
- argv = argv;
11179
- rm_not_implemented();
11180
- return(VALUE)0;
11181
- #endif
11182
11034
  }
11183
11035
 
11184
11036
 
@@ -11522,11 +11374,13 @@ Image_roll(VALUE self, VALUE x_offset, VALUE y_offset)
11522
11374
  {
11523
11375
  Image *image, *new_image;
11524
11376
  ExceptionInfo *exception;
11377
+ ssize_t x = NUM2LONG(x_offset);
11378
+ ssize_t y = NUM2LONG(y_offset);
11525
11379
 
11526
11380
  image = rm_check_destroyed(self);
11527
11381
 
11528
11382
  exception = AcquireExceptionInfo();
11529
- new_image = RollImage(image, NUM2LONG(x_offset), NUM2LONG(y_offset), exception);
11383
+ new_image = RollImage(image, x, y, exception);
11530
11384
  rm_check_exception(exception, new_image, DestroyOnError);
11531
11385
 
11532
11386
  (void) DestroyExceptionInfo(exception);
@@ -11870,7 +11724,6 @@ DEF_ATTR_READER(Image, scene, ulong)
11870
11724
  VALUE
11871
11725
  Image_selective_blur_channel(int argc, VALUE *argv, VALUE self)
11872
11726
  {
11873
- #if defined(HAVE_SELECTIVEBLURIMAGECHANNEL)
11874
11727
  Image *image, *new_image;
11875
11728
  double radius, sigma, threshold;
11876
11729
  ExceptionInfo *exception;
@@ -11900,14 +11753,6 @@ Image_selective_blur_channel(int argc, VALUE *argv, VALUE self)
11900
11753
  rm_ensure_result(new_image);
11901
11754
 
11902
11755
  return rm_image_new(new_image);
11903
-
11904
- #else
11905
- rm_not_implemented();
11906
- argc = argc;
11907
- argv = argv;
11908
- self = self;
11909
- return (VALUE)0;
11910
- #endif
11911
11756
  }
11912
11757
 
11913
11758
 
@@ -12380,10 +12225,8 @@ Image_sharpen_channel(int argc, VALUE *argv, VALUE self)
12380
12225
  raise_ChannelType_error(argv[argc-1]);
12381
12226
  }
12382
12227
 
12383
- new_image = rm_clone_image(image);
12384
-
12385
12228
  exception = AcquireExceptionInfo();
12386
- (void) SharpenImageChannel(new_image, channels, radius, sigma, exception);
12229
+ new_image = SharpenImageChannel(image, channels, radius, sigma, exception);
12387
12230
 
12388
12231
  rm_check_exception(exception, new_image, DestroyOnError);
12389
12232
  (void) DestroyExceptionInfo(exception);
@@ -12452,11 +12295,13 @@ Image_shear(VALUE self, VALUE x_shear, VALUE y_shear)
12452
12295
  {
12453
12296
  Image *image, *new_image;
12454
12297
  ExceptionInfo *exception;
12298
+ double x = NUM2DBL(x_shear);
12299
+ double y = NUM2DBL(y_shear);
12455
12300
 
12456
12301
  image = rm_check_destroyed(self);
12457
12302
 
12458
12303
  exception = AcquireExceptionInfo();
12459
- new_image = ShearImage(image, NUM2DBL(x_shear), NUM2DBL(y_shear), exception);
12304
+ new_image = ShearImage(image, x, y, exception);
12460
12305
  rm_check_exception(exception, new_image, DestroyOnError);
12461
12306
 
12462
12307
  (void) DestroyExceptionInfo(exception);
@@ -12673,7 +12518,6 @@ Image_spaceship(VALUE self, VALUE other)
12673
12518
  }
12674
12519
 
12675
12520
 
12676
- #if defined(HAVE_SPARSECOLORIMAGE)
12677
12521
  /**
12678
12522
  * Count the number of channels from the specified list are in an image. Note
12679
12523
  * that this method also removes invalid channels based on the image.
@@ -12721,7 +12565,6 @@ count_channels(Image *image, ChannelType *channels)
12721
12565
 
12722
12566
  return ncolors;
12723
12567
  }
12724
- #endif
12725
12568
 
12726
12569
 
12727
12570
  /**
@@ -12750,14 +12593,13 @@ count_channels(Image *image, ChannelType *channels)
12750
12593
  VALUE
12751
12594
  Image_sparse_color(int argc, VALUE *argv, VALUE self)
12752
12595
  {
12753
- #if defined(HAVE_SPARSECOLORIMAGE)
12754
12596
  Image *image, *new_image;
12755
12597
  unsigned long x, nargs, ncolors;
12756
12598
  SparseColorMethod method;
12757
12599
  int n, exp;
12758
12600
  double * volatile args;
12759
12601
  ChannelType channels;
12760
- MagickPixelPacket pp;
12602
+ MagickPixel pp;
12761
12603
  ExceptionInfo *exception;
12762
12604
 
12763
12605
  image = rm_check_destroyed(self);
@@ -12794,9 +12636,19 @@ Image_sparse_color(int argc, VALUE *argv, VALUE self)
12794
12636
  n = 0;
12795
12637
  while (n < argc)
12796
12638
  {
12797
- args[x++] = NUM2DBL(argv[n++]);
12798
- args[x++] = NUM2DBL(argv[n++]);
12799
- Color_to_MagickPixelPacket(NULL, &pp, argv[n++]);
12639
+ VALUE elem1 = argv[n++];
12640
+ VALUE elem2 = argv[n++];
12641
+ if (rm_check_num2dbl(elem1) && rm_check_num2dbl(elem2))
12642
+ {
12643
+ args[x++] = NUM2DBL(elem1);
12644
+ args[x++] = NUM2DBL(elem2);
12645
+ }
12646
+ else
12647
+ {
12648
+ xfree((void *)args);
12649
+ rb_raise(rb_eTypeError, "type mismatch: %s and %s given", rb_class2name(CLASS_OF(elem1)), rb_class2name(CLASS_OF(elem2)));
12650
+ }
12651
+ Color_to_MagickPixel(NULL, &pp, argv[n++]);
12800
12652
  if (channels & RedChannel)
12801
12653
  {
12802
12654
  args[x++] = pp.red / QuantumRange;
@@ -12826,17 +12678,7 @@ Image_sparse_color(int argc, VALUE *argv, VALUE self)
12826
12678
  (void) DestroyExceptionInfo(exception);
12827
12679
  rm_ensure_result(new_image);
12828
12680
 
12829
- RB_GC_GUARD(args);
12830
-
12831
12681
  return rm_image_new(new_image);
12832
-
12833
- #else
12834
- self = self;
12835
- argc = argc;
12836
- argv = argv;
12837
- rm_not_implemented();
12838
- return(VALUE)0;
12839
- #endif
12840
12682
  }
12841
12683
 
12842
12684
 
@@ -12863,7 +12705,7 @@ VALUE
12863
12705
  Image_splice(int argc, VALUE *argv, VALUE self)
12864
12706
  {
12865
12707
  Image *image, *new_image;
12866
- PixelPacket color, old_color;
12708
+ PixelColor color, old_color;
12867
12709
  RectangleInfo rectangle;
12868
12710
  ExceptionInfo *exception;
12869
12711
 
@@ -12876,8 +12718,8 @@ Image_splice(int argc, VALUE *argv, VALUE self)
12876
12718
  color = image->background_color;
12877
12719
  break;
12878
12720
  case 5:
12879
- // Convert color argument to PixelPacket
12880
- Color_to_PixelPacket(&color, argv[4]);
12721
+ // Convert color argument to PixelColor
12722
+ Color_to_PixelColor(&color, argv[4]);
12881
12723
  break;
12882
12724
  default:
12883
12725
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 4 or 5)", argc);
@@ -13127,9 +12969,7 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg
13127
12969
  long x, y;
13128
12970
  unsigned long cols, rows;
13129
12971
  unsigned int okay;
13130
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_GETAUTHENTICPIXELS)
13131
12972
  ExceptionInfo *exception;
13132
- #endif
13133
12973
 
13134
12974
  image = rm_check_destroyed(self);
13135
12975
 
@@ -13156,16 +12996,11 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg
13156
12996
  // Get a pointer to the pixels. Replace the values with the PixelPackets
13157
12997
  // from the pixels argument.
13158
12998
  {
13159
- #if defined(HAVE_GETAUTHENTICPIXELS)
13160
12999
  exception = AcquireExceptionInfo();
13161
13000
 
13162
13001
  pixels = GetAuthenticPixels(image, x, y, cols, rows, exception);
13163
13002
  CHECK_EXCEPTION()
13164
13003
  DestroyExceptionInfo(exception);
13165
- #else
13166
- pixels = GetImagePixels(image, x, y, cols, rows);
13167
- rm_check_image_exception(image, RetainOnError);
13168
- #endif
13169
13004
 
13170
13005
  if (pixels)
13171
13006
  {
@@ -13175,16 +13010,11 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg
13175
13010
  Data_Get_Struct(new_pixel, Pixel, pixel);
13176
13011
  pixels[n] = *pixel;
13177
13012
  }
13178
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
13179
13013
  exception = AcquireExceptionInfo();
13180
13014
 
13181
13015
  SyncAuthenticPixels(image, exception);
13182
13016
  CHECK_EXCEPTION()
13183
13017
  DestroyExceptionInfo(exception);
13184
- #else
13185
- SyncImagePixels(image);
13186
- rm_check_image_exception(image, RetainOnError);
13187
- #endif
13188
13018
  }
13189
13019
  }
13190
13020
 
@@ -13226,15 +13056,16 @@ Image_strip_bang(VALUE self)
13226
13056
  * @return a new image
13227
13057
  */
13228
13058
  VALUE
13229
- Image_swirl(VALUE self, VALUE degrees)
13059
+ Image_swirl(VALUE self, VALUE degrees_obj)
13230
13060
  {
13231
13061
  Image *image, *new_image;
13232
13062
  ExceptionInfo *exception;
13063
+ double degrees = NUM2DBL(degrees_obj);
13233
13064
 
13234
13065
  image = rm_check_destroyed(self);
13235
13066
 
13236
13067
  exception = AcquireExceptionInfo();
13237
- new_image = SwirlImage(image, NUM2DBL(degrees), exception);
13068
+ new_image = SwirlImage(image, degrees, exception);
13238
13069
  rm_check_exception(exception, new_image, DestroyOnError);
13239
13070
 
13240
13071
  (void) DestroyExceptionInfo(exception);
@@ -13294,15 +13125,17 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj
13294
13125
  {
13295
13126
  Image *image, *new_image;
13296
13127
  Image *texture_image;
13297
- PixelPacket color;
13128
+ PixelColor color;
13298
13129
  VALUE texture;
13299
13130
  DrawInfo *draw_info;
13300
13131
  long x, y;
13301
13132
  PaintMethod method;
13133
+ MagickPixel color_mpp;
13134
+ MagickBooleanType invert;
13302
13135
 
13303
13136
  image = rm_check_destroyed(self);
13304
13137
 
13305
- Color_to_PixelPacket(&color, color_obj);
13138
+ Color_to_PixelColor(&color, color_obj);
13306
13139
  texture = rm_cur_image(texture_obj);
13307
13140
  texture_image = rm_check_destroyed(texture);
13308
13141
 
@@ -13332,33 +13165,23 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj
13332
13165
  new_image = rm_clone_image(image);
13333
13166
 
13334
13167
 
13335
- #if defined(HAVE_FLOODFILLPAINTIMAGE)
13168
+ rm_init_magickpixel(new_image, &color_mpp);
13169
+ if (method == FillToBorderMethod)
13336
13170
  {
13337
- MagickPixelPacket color_mpp;
13338
- MagickBooleanType invert;
13339
-
13340
- GetMagickPixelPacket(new_image, &color_mpp);
13341
- if (method == FillToBorderMethod)
13342
- {
13343
- invert = MagickTrue;
13344
- color_mpp.red = (MagickRealType) image->border_color.red;
13345
- color_mpp.green = (MagickRealType) image->border_color.green;
13346
- color_mpp.blue = (MagickRealType) image->border_color.blue;
13347
- }
13348
- else
13349
- {
13350
- invert = MagickFalse;
13351
- color_mpp.red = (MagickRealType) color.red;
13352
- color_mpp.green = (MagickRealType) color.green;
13353
- color_mpp.blue = (MagickRealType) color.blue;
13354
- }
13355
-
13356
- (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert);
13171
+ invert = MagickTrue;
13172
+ color_mpp.red = (MagickRealType) image->border_color.red;
13173
+ color_mpp.green = (MagickRealType) image->border_color.green;
13174
+ color_mpp.blue = (MagickRealType) image->border_color.blue;
13175
+ }
13176
+ else
13177
+ {
13178
+ invert = MagickFalse;
13179
+ color_mpp.red = (MagickRealType) color.red;
13180
+ color_mpp.green = (MagickRealType) color.green;
13181
+ color_mpp.blue = (MagickRealType) color.blue;
13357
13182
  }
13358
13183
 
13359
- #else
13360
- (void) ColorFloodfillImage(new_image, draw_info, color, x, y, method);
13361
- #endif
13184
+ (void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert);
13362
13185
 
13363
13186
  (void) DestroyDrawInfo(draw_info);
13364
13187
  rm_check_image_exception(new_image, DestroyOnError);
@@ -13381,14 +13204,15 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj
13381
13204
  * @return a new image
13382
13205
  */
13383
13206
  VALUE
13384
- Image_threshold(VALUE self, VALUE threshold)
13207
+ Image_threshold(VALUE self, VALUE threshold_obj)
13385
13208
  {
13386
13209
  Image *image, *new_image;
13210
+ double threshold = NUM2DBL(threshold_obj);
13387
13211
 
13388
13212
  image = rm_check_destroyed(self);
13389
13213
  new_image = rm_clone_image(image);
13390
13214
 
13391
- (void) BilevelImageChannel(new_image, DefaultChannels, NUM2DBL(threshold));
13215
+ (void) BilevelImageChannel(new_image, DefaultChannels, threshold);
13392
13216
  rm_check_image_exception(new_image, DestroyOnError);
13393
13217
 
13394
13218
  return rm_image_new(new_image);
@@ -13631,7 +13455,7 @@ VALUE
13631
13455
  Image_tint(int argc, VALUE *argv, VALUE self)
13632
13456
  {
13633
13457
  Image *image, *new_image;
13634
- Pixel *tint;
13458
+ PixelColor tint;
13635
13459
  double red_pct_opaque, green_pct_opaque, blue_pct_opaque;
13636
13460
  double alpha_pct_opaque = 1.0;
13637
13461
  char opacity[50];
@@ -13680,10 +13504,10 @@ Image_tint(int argc, VALUE *argv, VALUE self)
13680
13504
  "%g,%g,%g,%g", red_pct_opaque*100.0, green_pct_opaque*100.0
13681
13505
  , blue_pct_opaque*100.0, alpha_pct_opaque*100.0);
13682
13506
 
13683
- Data_Get_Struct(argv[0], Pixel, tint);
13507
+ Color_to_PixelColor(&tint, argv[0]);
13684
13508
  exception = AcquireExceptionInfo();
13685
13509
 
13686
- new_image = TintImage(image, opacity, *tint, exception);
13510
+ new_image = TintImage(image, opacity, tint, exception);
13687
13511
  rm_check_exception(exception, new_image, DestroyOnError);
13688
13512
 
13689
13513
  (void) DestroyExceptionInfo(exception);
@@ -13803,12 +13627,12 @@ VALUE
13803
13627
  Image_to_color(VALUE self, VALUE pixel_arg)
13804
13628
  {
13805
13629
  Image *image;
13806
- Pixel *pixel;
13630
+ PixelColor pixel;
13807
13631
  ExceptionInfo *exception;
13808
13632
  char name[MaxTextExtent];
13809
13633
 
13810
13634
  image = rm_check_destroyed(self);
13811
- Data_Get_Struct(pixel_arg, Pixel, pixel);
13635
+ Color_to_PixelColor(&pixel, pixel_arg);
13812
13636
  exception = AcquireExceptionInfo();
13813
13637
 
13814
13638
  // QueryColorname returns False if the color represented by the PixelPacket
@@ -13816,7 +13640,7 @@ Image_to_color(VALUE self, VALUE pixel_arg)
13816
13640
  // about that.
13817
13641
 
13818
13642
  name[0] = '\0';
13819
- (void) QueryColorname(image, pixel, AllCompliance, name, exception);
13643
+ (void) QueryColorname(image, &pixel, AllCompliance, name, exception);
13820
13644
  CHECK_EXCEPTION()
13821
13645
 
13822
13646
  (void) DestroyExceptionInfo(exception);
@@ -13896,7 +13720,7 @@ VALUE
13896
13720
  Image_transparent(int argc, VALUE *argv, VALUE self)
13897
13721
  {
13898
13722
  Image *image, *new_image;
13899
- MagickPixelPacket color;
13723
+ MagickPixel color;
13900
13724
  Quantum opacity = TransparentOpacity;
13901
13725
  MagickBooleanType okay;
13902
13726
 
@@ -13907,7 +13731,7 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
13907
13731
  case 2:
13908
13732
  opacity = APP2QUANTUM(argv[1]);
13909
13733
  case 1:
13910
- Color_to_MagickPixelPacket(image, &color, argv[0]);
13734
+ Color_to_MagickPixel(image, &color, argv[0]);
13911
13735
  break;
13912
13736
  default:
13913
13737
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
@@ -13916,17 +13740,13 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
13916
13740
 
13917
13741
  new_image = rm_clone_image(image);
13918
13742
 
13919
- #if defined(HAVE_TRANSPARENTPAINTIMAGE)
13920
13743
  okay = TransparentPaintImage(new_image, &color, opacity, MagickFalse);
13921
- #else
13922
- okay = PaintTransparentImage(new_image, &color, opacity);
13923
- #endif
13924
13744
  rm_check_image_exception(new_image, DestroyOnError);
13925
13745
  if (!okay)
13926
13746
  {
13927
13747
  // Force exception
13928
13748
  DestroyImage(new_image);
13929
- rm_magick_error("TransparentPaintImage failed with no explanation", NULL);
13749
+ rm_magick_error("TransparentPaintImage failed with no explanation");
13930
13750
  }
13931
13751
 
13932
13752
  return rm_image_new(new_image);
@@ -13954,10 +13774,9 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
13954
13774
  VALUE
13955
13775
  Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
13956
13776
  {
13957
- #if defined(HAVE_TRANSPARENTPAINTIMAGECHROMA)
13958
13777
  Image *image, *new_image;
13959
13778
  Quantum opacity = TransparentOpacity;
13960
- MagickPixelPacket low, high;
13779
+ MagickPixel low, high;
13961
13780
  MagickBooleanType invert = MagickFalse;
13962
13781
  MagickBooleanType okay;
13963
13782
 
@@ -13970,8 +13789,8 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
13970
13789
  case 3:
13971
13790
  opacity = APP2QUANTUM(argv[2]);
13972
13791
  case 2:
13973
- Color_to_MagickPixelPacket(image, &high, argv[1]);
13974
- Color_to_MagickPixelPacket(image, &low, argv[0]);
13792
+ Color_to_MagickPixel(image, &high, argv[1]);
13793
+ Color_to_MagickPixel(image, &low, argv[0]);
13975
13794
  break;
13976
13795
  default:
13977
13796
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2, 3 or 4)", argc);
@@ -13986,17 +13805,10 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
13986
13805
  {
13987
13806
  // Force exception
13988
13807
  DestroyImage(new_image);
13989
- rm_magick_error("TransparentPaintImageChroma failed with no explanation", NULL);
13808
+ rm_magick_error("TransparentPaintImageChroma failed with no explanation");
13990
13809
  }
13991
13810
 
13992
13811
  return rm_image_new(new_image);
13993
- #else
13994
- rm_not_implemented();
13995
- return (VALUE)0;
13996
- argc = argc;
13997
- argv = argv;
13998
- self = self;
13999
- #endif
14000
13812
  }
14001
13813
 
14002
13814
 
@@ -14013,7 +13825,7 @@ VALUE
14013
13825
  Image_transparent_color(VALUE self)
14014
13826
  {
14015
13827
  Image *image = rm_check_destroyed(self);
14016
- return rm_pixelpacket_to_color_name(image, &image->transparent_color);
13828
+ return rm_pixelcolor_to_color_name(image, &image->transparent_color);
14017
13829
  }
14018
13830
 
14019
13831
 
@@ -14031,7 +13843,7 @@ VALUE
14031
13843
  Image_transparent_color_eq(VALUE self, VALUE color)
14032
13844
  {
14033
13845
  Image *image = rm_check_frozen(self);
14034
- Color_to_PixelPacket(&image->transparent_color, color);
13846
+ Color_to_PixelColor(&image->transparent_color, color);
14035
13847
  return self;
14036
13848
  }
14037
13849
 
@@ -14322,21 +14134,14 @@ VALUE Image_image_type_eq(VALUE self, VALUE image_type)
14322
14134
  VALUE
14323
14135
  Image_undefine(VALUE self, VALUE artifact)
14324
14136
  {
14325
- #if defined(HAVE_REMOVEIMAGEARTIFACT)
14326
14137
  Image *image;
14327
14138
  char *key;
14328
14139
  long key_l;
14329
14140
 
14330
14141
  image = rm_check_frozen(self);
14331
14142
  key = rm_str2cstr(artifact, &key_l);
14332
- (void) RemoveImageArtifact(image, key);
14143
+ (void) DeleteImageArtifact(image, key);
14333
14144
  return self;
14334
- #else
14335
- rm_not_implemented();
14336
- artifact = artifact;
14337
- self = self;
14338
- return(VALUE)0;
14339
- #endif
14340
14145
  }
14341
14146
 
14342
14147
 
@@ -14769,9 +14574,7 @@ Image_watermark(int argc, VALUE *argv, VALUE self)
14769
14574
 
14770
14575
  blend_geometry(geometry, sizeof(geometry), src_percent, dst_percent);
14771
14576
  (void) CloneString(&overlay->geometry, geometry);
14772
- #if defined(HAVE_SETIMAGEARTIFACT)
14773
14577
  (void) SetImageArtifact(overlay,"compose:args", geometry);
14774
- #endif
14775
14578
 
14776
14579
  new_image = rm_clone_image(image);
14777
14580
  (void) CompositeImage(new_image, ModulateCompositeOp, overlay, x_offset, y_offset);
@@ -14946,12 +14749,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
14946
14749
  opacity = TransparentOpacity;
14947
14750
  }
14948
14751
 
14949
-
14950
- #if defined(HAVE_GETVIRTUALPIXELS)
14951
14752
  p = GetVirtualPixels(reflection, 0, y, image->columns, 1, exception);
14952
- #else
14953
- p = AcquireImagePixels(reflection, 0, y, image->columns, 1, exception);
14954
- #endif
14955
14753
  rm_check_exception(exception, reflection, DestroyOnError);
14956
14754
  if (!p)
14957
14755
  {
@@ -14959,11 +14757,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
14959
14757
  goto error;
14960
14758
  }
14961
14759
 
14962
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
14963
14760
  q = QueueAuthenticPixels(reflection, 0, y, image->columns, 1, exception);
14964
- #else
14965
- q = SetImagePixels(reflection, 0, y, image->columns, 1);
14966
- #endif
14761
+
14967
14762
  rm_check_exception(exception, reflection, DestroyOnError);
14968
14763
  if (!q)
14969
14764
  {
@@ -14979,13 +14774,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
14979
14774
  }
14980
14775
 
14981
14776
 
14982
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
14983
14777
  SyncAuthenticPixels(reflection, exception);
14984
14778
  rm_check_exception(exception, reflection, DestroyOnError);
14985
- #else
14986
- SyncImagePixels(reflection);
14987
- rm_check_image_exception(reflection, DestroyOnError);
14988
- #endif
14989
14779
 
14990
14780
  opacity += step;
14991
14781
  }
@@ -15139,7 +14929,7 @@ Image_write(VALUE self, VALUE file)
15139
14929
 
15140
14930
  if (TYPE(file) == T_FILE)
15141
14931
  {
15142
- OpenFile *fptr;
14932
+ rb_io_t *fptr;
15143
14933
 
15144
14934
  // Ensure file is open - raise error if not
15145
14935
  GetOpenFile(file, fptr);
@@ -15149,7 +14939,7 @@ Image_write(VALUE self, VALUE file)
15149
14939
  strcpy(image->filename, info->filename);
15150
14940
  SetImageInfoFile(info, NULL);
15151
14941
  #else
15152
- SetImageInfoFile(info, GetWriteFile(fptr));
14942
+ SetImageInfoFile(info, rb_io_stdio_file(fptr));
15153
14943
  memset(image->filename, 0, sizeof(image->filename));
15154
14944
  #endif
15155
14945
  }
@@ -15516,7 +15306,7 @@ static void call_trace_proc(Image *image, const char *which)
15516
15306
  n = sprintf(buffer, "%p", (void *)image);
15517
15307
  buffer[n] = '\0';
15518
15308
  trace_args[2] = rb_str_new2(buffer+2); // don't use leading 0x
15519
- trace_args[3] = ID2SYM(THIS_FUNC());
15309
+ trace_args[3] = ID2SYM(rb_frame_this_func());
15520
15310
  (void) rb_funcall2(trace, rm_ID_call, 4, (VALUE *)trace_args);
15521
15311
  }
15522
15312
  }