rmagick 5.3.0 → 5.4.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.
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rmimage.c
9
- * @version $Id: rmimage.c,v 1.361 2010/05/03 03:34:48 baror Exp $
8
+ * @file rmimage.cpp
9
+ * @version $Id: rmimage.cpp,v 1.361 2010/05/03 03:34:48 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
12
12
 
@@ -126,6 +126,7 @@ DEFINE_GVL_STUB4(ColorizeImage, const Image *, const char *, const PixelInfo *,
126
126
  DEFINE_GVL_STUB5(CompareImages, Image *, const Image *, const MetricType, double *, ExceptionInfo *);
127
127
  DEFINE_GVL_STUB7(CompositeImage, Image *, const Image *, const CompositeOperator, const MagickBooleanType, const ssize_t, const ssize_t, ExceptionInfo *);
128
128
  DEFINE_GVL_STUB2(CompressImageColormap, Image *, ExceptionInfo *);
129
+ DEFINE_GVL_STUB3(ContrastImage, Image *, const MagickBooleanType, ExceptionInfo *);
129
130
  DEFINE_GVL_STUB4(ContrastStretchImage, Image *, const double, const double, ExceptionInfo *);
130
131
  DEFINE_GVL_STUB3(ConvolveImage, const Image *, const KernelInfo *, ExceptionInfo *);
131
132
  DEFINE_GVL_STUB3(CycleColormapImage, Image *, const ssize_t, ExceptionInfo *);
@@ -206,6 +207,7 @@ DEFINE_GVL_STUB6(CompareImageChannels, Image *, const Image *, const ChannelType
206
207
  DEFINE_GVL_STUB5(CompositeImage, Image *, const CompositeOperator, const Image *, const ssize_t, const ssize_t);
207
208
  DEFINE_GVL_STUB6(CompositeImageChannel, Image *, const ChannelType, const CompositeOperator, const Image *, const ssize_t, const ssize_t);
208
209
  DEFINE_GVL_STUB1(CompressImageColormap, Image *);
210
+ DEFINE_GVL_STUB2(ContrastImage, Image *, const MagickBooleanType);
209
211
  DEFINE_GVL_STUB4(ContrastStretchImageChannel, Image *, const ChannelType, const double, const double);
210
212
  DEFINE_GVL_STUB4(ConvolveImage, const Image *, const size_t, const double *, ExceptionInfo *);
211
213
  DEFINE_GVL_STUB5(ConvolveImageChannel, const Image *, const ChannelType, const size_t, const double *, ExceptionInfo *);
@@ -597,10 +599,10 @@ Image_adaptive_sharpen_channel(int argc, VALUE *argv, VALUE self)
597
599
  * local neighborhood. This allows for thresholding of an image whose global intensity histogram
598
600
  * doesn't contain distinctive peaks.
599
601
  *
600
- * @overload adaptive_threshold(width = 3, height = 3, offset = 0)
602
+ * @overload adaptive_threshold(width = 3, height = 3, bias = 0)
601
603
  * @param width [Numeric] the width of the local neighborhood.
602
604
  * @param height [Numeric] the height of the local neighborhood.
603
- * @param offset [Numeric] the mean offset
605
+ * @param bias [Numeric] the mean offset
604
606
  * @return [Magick::Image] a new image
605
607
  */
606
608
  VALUE
@@ -608,7 +610,7 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
608
610
  {
609
611
  Image *image, *new_image;
610
612
  unsigned long width = 3, height = 3;
611
- long offset = 0;
613
+ double bias = 0;
612
614
  ExceptionInfo *exception;
613
615
 
614
616
  image = rm_check_destroyed(self);
@@ -616,7 +618,7 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
616
618
  switch (argc)
617
619
  {
618
620
  case 3:
619
- offset = NUM2LONG(argv[2]);
621
+ bias = NUM2DBL(argv[2]);
620
622
  case 2:
621
623
  height = NUM2ULONG(argv[1]);
622
624
  case 1:
@@ -628,7 +630,7 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
628
630
  }
629
631
 
630
632
  exception = AcquireExceptionInfo();
631
- GVL_STRUCT_TYPE(AdaptiveThresholdImage) args = { image, width, height, offset, exception };
633
+ GVL_STRUCT_TYPE(AdaptiveThresholdImage) args = { image, width, height, bias, exception };
632
634
  new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AdaptiveThresholdImage), &args);
633
635
  rm_check_exception(exception, new_image, DestroyOnError);
634
636
  DestroyExceptionInfo(exception);
@@ -757,7 +759,7 @@ Image_add_noise_channel(int argc, VALUE *argv, VALUE self)
757
759
  }
758
760
 
759
761
  VALUE_TO_ENUM(argv[0], noise_type, NoiseType);
760
- channels &= ~OpacityChannel;
762
+ channels = (ChannelType)(channels & ~OpacityChannel);
761
763
 
762
764
  exception = AcquireExceptionInfo();
763
765
  #if defined(IMAGEMAGICK_7)
@@ -953,7 +955,8 @@ Image_affine_transform(VALUE self, VALUE affine)
953
955
 
954
956
  exception = AcquireExceptionInfo();
955
957
  GVL_STRUCT_TYPE(AffineTransformImage) args = { image, &matrix, exception };
956
- new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AffineTransformImage), &args);
958
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AffineTransformImage), &args);
959
+ new_image = reinterpret_cast<decltype(new_image)>(ret);
957
960
  rm_check_exception(exception, new_image, DestroyOnError);
958
961
  DestroyExceptionInfo(exception);
959
962
 
@@ -1098,7 +1101,8 @@ crisscross(int bang, VALUE self, gvl_function_t fp)
1098
1101
  exception = AcquireExceptionInfo();
1099
1102
 
1100
1103
  GVL_STRUCT_TYPE(crisscross) args = { image, exception };
1101
- new_image = CALL_FUNC_WITHOUT_GVL(fp, &args);
1104
+ void *ret = CALL_FUNC_WITHOUT_GVL(fp, &args);
1105
+ new_image = reinterpret_cast<decltype(new_image)>(ret);
1102
1106
  rm_check_exception(exception, new_image, DestroyOnError);
1103
1107
  DestroyExceptionInfo(exception);
1104
1108
 
@@ -2801,13 +2805,15 @@ Image_clut_channel(int argc, VALUE *argv, VALUE self)
2801
2805
  exception = AcquireExceptionInfo();
2802
2806
  BEGIN_CHANNEL_MASK(image, channels);
2803
2807
  GVL_STRUCT_TYPE(ClutImage) args = { image, clut, image->interpolate, exception };
2804
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImage), &args);
2808
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImage), &args);
2809
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
2805
2810
  END_CHANNEL_MASK(image);
2806
2811
  CHECK_EXCEPTION();
2807
2812
  DestroyExceptionInfo(exception);
2808
2813
  #else
2809
2814
  GVL_STRUCT_TYPE(ClutImageChannel) args = { image, channels, clut };
2810
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImageChannel), &args);
2815
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImageChannel), &args);
2816
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
2811
2817
  rm_check_image_exception(image, RetainOnError);
2812
2818
  rm_check_image_exception(clut, RetainOnError);
2813
2819
  #endif
@@ -2857,7 +2863,8 @@ Image_color_histogram(VALUE self)
2857
2863
  }
2858
2864
 
2859
2865
  GVL_STRUCT_TYPE(GetImageHistogram) args = { image, &colors, exception };
2860
- histogram = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageHistogram), &args);
2866
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageHistogram), &args);
2867
+ histogram = reinterpret_cast<decltype(histogram)>(ret);
2861
2868
 
2862
2869
  if (histogram == NULL)
2863
2870
  {
@@ -2927,7 +2934,7 @@ set_profile(VALUE self, const char *name, VALUE profile)
2927
2934
  ExceptionInfo *exception;
2928
2935
  char *profile_name;
2929
2936
  char *profile_blob;
2930
- long profile_length;
2937
+ size_t profile_length;
2931
2938
  const StringInfo *profile_data;
2932
2939
 
2933
2940
  image = rm_check_frozen(self);
@@ -2951,7 +2958,7 @@ set_profile(VALUE self, const char *name, VALUE profile)
2951
2958
 
2952
2959
  strlcpy(info->magick, m->name, sizeof(info->magick));
2953
2960
 
2954
- GVL_STRUCT_TYPE(BlobToImage) args = { info, profile_blob, (size_t)profile_length, exception };
2961
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, profile_blob, profile_length, exception };
2955
2962
  profile_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
2956
2963
  DestroyImageInfo(info);
2957
2964
  CHECK_EXCEPTION();
@@ -3098,7 +3105,7 @@ Image_color_flood_fill(VALUE self, VALUE target_color, VALUE fill_color,
3098
3105
  y = NUM2LONG(yv);
3099
3106
  if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
3100
3107
  {
3101
- rb_raise(rb_eArgError, "target out of range. %lux%lu given, image is %"RMIuSIZE"x%"RMIuSIZE"",
3108
+ rb_raise(rb_eArgError, "target out of range. %lux%lu given, image is %" RMIuSIZE "x%" RMIuSIZE "",
3102
3109
  x, y, image->columns, image->rows);
3103
3110
  }
3104
3111
 
@@ -3541,7 +3548,7 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3541
3548
  {
3542
3549
  Image *image, *new_image;
3543
3550
  Image *comp_image;
3544
- CompositeOperator operator = UndefinedCompositeOp;
3551
+ CompositeOperator composite_op = UndefinedCompositeOp;
3545
3552
  GravityType gravity;
3546
3553
  VALUE comp;
3547
3554
  signed long x_offset = 0;
@@ -3570,7 +3577,7 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3570
3577
  {
3571
3578
  case 3: // argv[1] is gravity, argv[2] is composite_op
3572
3579
  VALUE_TO_ENUM(argv[1], gravity, GravityType);
3573
- VALUE_TO_ENUM(argv[2], operator, CompositeOperator);
3580
+ VALUE_TO_ENUM(argv[2], composite_op, CompositeOperator);
3574
3581
 
3575
3582
  // convert gravity to x, y offsets
3576
3583
  switch (gravity)
@@ -3620,14 +3627,14 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3620
3627
  // argv[3] is composite_op
3621
3628
  x_offset = NUM2LONG(argv[1]);
3622
3629
  y_offset = NUM2LONG(argv[2]);
3623
- VALUE_TO_ENUM(argv[3], operator, CompositeOperator);
3630
+ VALUE_TO_ENUM(argv[3], composite_op, CompositeOperator);
3624
3631
  break;
3625
3632
 
3626
3633
  case 5:
3627
3634
  VALUE_TO_ENUM(argv[1], gravity, GravityType);
3628
3635
  x_offset = NUM2LONG(argv[2]);
3629
3636
  y_offset = NUM2LONG(argv[3]);
3630
- VALUE_TO_ENUM(argv[4], operator, CompositeOperator);
3637
+ VALUE_TO_ENUM(argv[4], composite_op, CompositeOperator);
3631
3638
 
3632
3639
  switch (gravity)
3633
3640
  {
@@ -3670,13 +3677,13 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3670
3677
  #if defined(IMAGEMAGICK_7)
3671
3678
  exception = AcquireExceptionInfo();
3672
3679
  BEGIN_CHANNEL_MASK(image, channels);
3673
- GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, operator, MagickTrue, x_offset, y_offset, exception };
3680
+ GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, composite_op, MagickTrue, x_offset, y_offset, exception };
3674
3681
  CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
3675
3682
  END_CHANNEL_MASK(image);
3676
3683
  CHECK_EXCEPTION();
3677
3684
  DestroyExceptionInfo(exception);
3678
3685
  #else
3679
- GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, operator, comp_image, x_offset, y_offset };
3686
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, composite_op, comp_image, x_offset, y_offset };
3680
3687
  CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
3681
3688
  rm_check_image_exception(image, RetainOnError);
3682
3689
  #endif
@@ -3690,13 +3697,13 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3690
3697
  #if defined(IMAGEMAGICK_7)
3691
3698
  exception = AcquireExceptionInfo();
3692
3699
  BEGIN_CHANNEL_MASK(new_image, channels);
3693
- GVL_STRUCT_TYPE(CompositeImage) args = { new_image, comp_image, operator, MagickTrue, x_offset, y_offset, exception };
3700
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, comp_image, composite_op, MagickTrue, x_offset, y_offset, exception };
3694
3701
  CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
3695
3702
  END_CHANNEL_MASK(new_image);
3696
3703
  rm_check_exception(exception, new_image, DestroyOnError);
3697
3704
  DestroyExceptionInfo(exception);
3698
3705
  #else
3699
- GVL_STRUCT_TYPE(CompositeImageChannel) args = { new_image, channels, operator, comp_image, x_offset, y_offset };
3706
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { new_image, channels, composite_op, comp_image, x_offset, y_offset };
3700
3707
  CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
3701
3708
  rm_check_image_exception(new_image, DestroyOnError);
3702
3709
  #endif
@@ -4123,7 +4130,7 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self)
4123
4130
  {
4124
4131
  Image *image;
4125
4132
  Image *comp_image;
4126
- CompositeOperator operator = OverCompositeOp;
4133
+ CompositeOperator composite_op = OverCompositeOp;
4127
4134
  long x, y;
4128
4135
  unsigned long columns;
4129
4136
  ChannelType channels;
@@ -4147,7 +4154,7 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self)
4147
4154
  switch (argc)
4148
4155
  {
4149
4156
  case 2:
4150
- VALUE_TO_ENUM(argv[1], operator, CompositeOperator);
4157
+ VALUE_TO_ENUM(argv[1], composite_op, CompositeOperator);
4151
4158
  case 1:
4152
4159
  break;
4153
4160
  case 0:
@@ -4181,13 +4188,15 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self)
4181
4188
  {
4182
4189
  #if defined(IMAGEMAGICK_7)
4183
4190
  BEGIN_CHANNEL_MASK(image, channels);
4184
- GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, operator, MagickTrue, x, y, exception };
4185
- status = (MagickStatusType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
4191
+ GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, composite_op, MagickTrue, x, y, exception };
4192
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
4193
+ status = reinterpret_cast<MagickStatusType &>(ret);
4186
4194
  END_CHANNEL_MASK(image);
4187
4195
  rm_check_exception(exception, image, bang ? RetainOnError: DestroyOnError);
4188
4196
  #else
4189
- GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, operator, comp_image, x, y };
4190
- status = (MagickStatusType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
4197
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, composite_op, comp_image, x, y };
4198
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
4199
+ status = reinterpret_cast<MagickStatusType &>(ret);
4191
4200
  rm_check_image_exception(image, bang ? RetainOnError: DestroyOnError);
4192
4201
  #endif
4193
4202
  }
@@ -4301,12 +4310,14 @@ Image_compress_colormap_bang(VALUE self)
4301
4310
  #if defined(IMAGEMAGICK_7)
4302
4311
  exception = AcquireExceptionInfo();
4303
4312
  GVL_STRUCT_TYPE(CompressImageColormap) args = { image, exception };
4304
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4313
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4314
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
4305
4315
  CHECK_EXCEPTION();
4306
4316
  DestroyExceptionInfo(exception);
4307
4317
  #else
4308
4318
  GVL_STRUCT_TYPE(CompressImageColormap) args = { image };
4309
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4319
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4320
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
4310
4321
  rm_check_image_exception(image, RetainOnError);
4311
4322
  #endif
4312
4323
  if (!okay)
@@ -4339,12 +4350,13 @@ Image_compress_colormap_bang(VALUE self)
4339
4350
  * @return [Magick::Image] a new image
4340
4351
  */
4341
4352
  VALUE
4342
- Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg,
4353
+ Image_constitute(VALUE klass ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg,
4343
4354
  VALUE map_arg, VALUE pixels_arg)
4344
4355
  {
4345
4356
  Image *new_image;
4346
4357
  VALUE pixel, pixel0;
4347
- long width, height, x, npixels, map_l;
4358
+ long x, npixels;
4359
+ size_t width, height, map_l;
4348
4360
  char *map;
4349
4361
  volatile union
4350
4362
  {
@@ -4360,14 +4372,13 @@ Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg
4360
4372
  // and raises TypeError if it can't.
4361
4373
  pixels_arg = rb_Array(pixels_arg);
4362
4374
 
4363
- width = NUM2LONG(width_arg);
4364
- height = NUM2LONG(height_arg);
4365
-
4366
- if (width <= 0 || height <= 0)
4375
+ if (NUM2LONG(width_arg) <= 0 || NUM2LONG(height_arg) <= 0)
4367
4376
  {
4368
4377
  rb_raise(rb_eArgError, "width and height must be greater than zero");
4369
4378
  }
4370
4379
 
4380
+ width = NUM2LONG(width_arg);
4381
+ height = NUM2LONG(height_arg);
4371
4382
  map = rm_str2cstr(map_arg, &map_l);
4372
4383
 
4373
4384
  npixels = width * height * map_l;
@@ -4507,7 +4518,7 @@ VALUE
4507
4518
  Image_contrast(int argc, VALUE *argv, VALUE self)
4508
4519
  {
4509
4520
  Image *image, *new_image;
4510
- unsigned int sharpen = 0;
4521
+ MagickBooleanType sharpen = MagickFalse;
4511
4522
  #if defined(IMAGEMAGICK_7)
4512
4523
  ExceptionInfo *exception;
4513
4524
  #endif
@@ -4519,18 +4530,20 @@ Image_contrast(int argc, VALUE *argv, VALUE self)
4519
4530
  }
4520
4531
  else if (argc == 1)
4521
4532
  {
4522
- sharpen = RTEST(argv[0]);
4533
+ sharpen = (MagickBooleanType)RTEST(argv[0]);
4523
4534
  }
4524
4535
 
4525
4536
  new_image = rm_clone_image(image);
4526
4537
 
4527
4538
  #if defined(IMAGEMAGICK_7)
4528
4539
  exception = AcquireExceptionInfo();
4529
- ContrastImage(new_image, sharpen, exception);
4540
+ GVL_STRUCT_TYPE(ContrastImage) args = { new_image, sharpen, exception };
4541
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ContrastImage), &args);
4530
4542
  rm_check_exception(exception, new_image, DestroyOnError);
4531
4543
  DestroyExceptionInfo(exception);
4532
4544
  #else
4533
- ContrastImage(new_image, sharpen);
4545
+ GVL_STRUCT_TYPE(ContrastImage) args = { new_image, sharpen };
4546
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ContrastImage), &args);
4534
4547
  rm_check_image_exception(new_image, DestroyOnError);
4535
4548
  #endif
4536
4549
 
@@ -4805,7 +4818,7 @@ VALUE
4805
4818
  Image_convolve(VALUE self, VALUE order_arg, VALUE kernel_arg)
4806
4819
  {
4807
4820
  Image *image, *new_image;
4808
- int order;
4821
+ size_t order;
4809
4822
  ExceptionInfo *exception;
4810
4823
  #if defined(IMAGEMAGICK_7)
4811
4824
  KernelInfo *kernel;
@@ -4816,13 +4829,12 @@ Image_convolve(VALUE self, VALUE order_arg, VALUE kernel_arg)
4816
4829
 
4817
4830
  image = rm_check_destroyed(self);
4818
4831
 
4819
- order = NUM2INT(order_arg);
4820
-
4821
- if (order <= 0)
4832
+ if (NUM2INT(order_arg) <= 0)
4822
4833
  {
4823
4834
  rb_raise(rb_eArgError, "order must be non-zero and positive");
4824
4835
  }
4825
4836
 
4837
+ order = NUM2INT(order_arg);
4826
4838
  kernel_arg = rb_Array(kernel_arg);
4827
4839
  rm_check_ary_len(kernel_arg, (long)(order*order));
4828
4840
 
@@ -4886,7 +4898,7 @@ Image_convolve_channel(int argc, VALUE *argv, VALUE self)
4886
4898
  {
4887
4899
  Image *image, *new_image;
4888
4900
  VALUE ary;
4889
- int order;
4901
+ size_t order;
4890
4902
  ChannelType channels;
4891
4903
  ExceptionInfo *exception;
4892
4904
  #if defined(IMAGEMAGICK_7)
@@ -4910,12 +4922,12 @@ Image_convolve_channel(int argc, VALUE *argv, VALUE self)
4910
4922
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc);
4911
4923
  }
4912
4924
 
4913
- order = NUM2INT(argv[0]);
4914
- if (order <= 0)
4925
+ if (NUM2INT(argv[0]) <= 0)
4915
4926
  {
4916
4927
  rb_raise(rb_eArgError, "order must be non-zero and positive");
4917
4928
  }
4918
4929
 
4930
+ order = NUM2INT(argv[0]);
4919
4931
  ary = rb_Array(argv[1]);
4920
4932
  rm_check_ary_len(ary, (long)(order*order));
4921
4933
 
@@ -5236,7 +5248,8 @@ Image_decipher(VALUE self, VALUE passphrase)
5236
5248
  new_image = rm_clone_image(image);
5237
5249
 
5238
5250
  GVL_STRUCT_TYPE(DecipherImage) args = { new_image, pf, exception };
5239
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DecipherImage), &args);
5251
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DecipherImage), &args);
5252
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
5240
5253
  rm_check_exception(exception, new_image, DestroyOnError);
5241
5254
  if (!okay)
5242
5255
  {
@@ -5665,7 +5678,7 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
5665
5678
  VALUE pixels_ary;
5666
5679
  StorageType stg_type = QuantumPixel;
5667
5680
  char *map;
5668
- long mapL;
5681
+ size_t mapL;
5669
5682
  MagickBooleanType okay;
5670
5683
  ExceptionInfo *exception;
5671
5684
  volatile union
@@ -5704,7 +5717,8 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
5704
5717
 
5705
5718
  exception = AcquireExceptionInfo();
5706
5719
  GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception };
5707
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
5720
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
5721
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
5708
5722
 
5709
5723
  if (!okay)
5710
5724
  {
@@ -5759,7 +5773,7 @@ Image_display(VALUE self)
5759
5773
 
5760
5774
  if (image->rows == 0 || image->columns == 0)
5761
5775
  {
5762
- rb_raise(rb_eArgError, "invalid image geometry (%"RMIuSIZE"x%"RMIuSIZE")", image->rows, image->columns);
5776
+ rb_raise(rb_eArgError, "invalid image geometry (%" RMIuSIZE "x%" RMIuSIZE ")", image->rows, image->columns);
5763
5777
  }
5764
5778
 
5765
5779
  info_obj = rm_info_new();
@@ -5937,7 +5951,7 @@ Image_distort(int argc, VALUE *argv, VALUE self)
5937
5951
  switch (argc)
5938
5952
  {
5939
5953
  case 3:
5940
- bestfit = RTEST(argv[2]);
5954
+ bestfit = (MagickBooleanType)RTEST(argv[2]);
5941
5955
  case 2:
5942
5956
  // Ensure pts is an array
5943
5957
  pts = rb_Array(argv[1]);
@@ -6299,7 +6313,8 @@ Image_encipher(VALUE self, VALUE passphrase)
6299
6313
  new_image = rm_clone_image(image);
6300
6314
 
6301
6315
  GVL_STRUCT_TYPE(EncipherImage) args = { new_image, pf, exception };
6302
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EncipherImage), &args);
6316
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EncipherImage), &args);
6317
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
6303
6318
  rm_check_exception(exception, new_image, DestroyOnError);
6304
6319
  if (!okay)
6305
6320
  {
@@ -6649,7 +6664,8 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6649
6664
  exception = AcquireExceptionInfo();
6650
6665
 
6651
6666
  GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, exception };
6652
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6667
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6668
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
6653
6669
  if (!okay)
6654
6670
  {
6655
6671
  xfree((void *)pixels);
@@ -6725,7 +6741,7 @@ Image_extent(int argc, VALUE *argv, VALUE self)
6725
6741
  }
6726
6742
  else
6727
6743
  {
6728
- rb_raise(rb_eArgError, "invalid extent geometry %ldx%ld+%"RMIdSIZE"+%"RMIdSIZE"",
6744
+ rb_raise(rb_eArgError, "invalid extent geometry %ldx%ld+%" RMIdSIZE "+%" RMIdSIZE "",
6729
6745
  width, height, geometry.x, geometry.y);
6730
6746
  }
6731
6747
  }
@@ -6841,7 +6857,8 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6841
6857
  exception = AcquireExceptionInfo();
6842
6858
 
6843
6859
  GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, type, (void *)RSTRING_PTR(string), exception };
6844
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6860
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6861
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
6845
6862
  if (!okay)
6846
6863
  {
6847
6864
  // Let GC have the string buffer.
@@ -6985,11 +7002,12 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6985
7002
  exception = AcquireExceptionInfo();
6986
7003
  #if defined(IMAGEMAGICK_7)
6987
7004
  GVL_STRUCT_TYPE(IsEquivalentImage) args = { image, target, &x, &y, exception };
6988
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsEquivalentImage), &args);
7005
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsEquivalentImage), &args);
6989
7006
  #else
6990
7007
  GVL_STRUCT_TYPE(IsImageSimilar) args = { image, target, &x, &y, exception };
6991
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImageSimilar), &args);
7008
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImageSimilar), &args);
6992
7009
  #endif
7010
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
6993
7011
  CHECK_EXCEPTION();
6994
7012
  DestroyExceptionInfo(exception);
6995
7013
 
@@ -7261,14 +7279,14 @@ Image_frame(int argc, VALUE *argv, VALUE self)
7261
7279
  * @see Image#to_blob
7262
7280
  */
7263
7281
  VALUE
7264
- Image_from_blob(VALUE class ATTRIBUTE_UNUSED, VALUE blob_arg)
7282
+ Image_from_blob(VALUE klass ATTRIBUTE_UNUSED, VALUE blob_arg)
7265
7283
  {
7266
7284
  Image *images;
7267
7285
  Info *info;
7268
7286
  VALUE info_obj;
7269
7287
  ExceptionInfo *exception;
7270
7288
  void *blob;
7271
- long length;
7289
+ size_t length;
7272
7290
 
7273
7291
  blob = (void *) rm_str2cstr(blob_arg, &length);
7274
7292
 
@@ -7827,7 +7845,8 @@ Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE row
7827
7845
  // to change the pixels but I don't want to make "pixels" const.
7828
7846
  exception = AcquireExceptionInfo();
7829
7847
  GVL_STRUCT_TYPE(GetVirtualPixels) args = { image, x, y, columns, rows, exception };
7830
- pixels = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
7848
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
7849
+ pixels = reinterpret_cast<decltype(pixels)>(ret);
7831
7850
  CHECK_EXCEPTION();
7832
7851
 
7833
7852
  DestroyExceptionInfo(exception);
@@ -8040,7 +8059,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
8040
8059
  long x_off, y_off;
8041
8060
  unsigned long cols, rows;
8042
8061
  unsigned long n, npixels;
8043
- long buffer_l;
8062
+ size_t buffer_l;
8044
8063
  char *map;
8045
8064
  VALUE pixel_arg, pixel_ary;
8046
8065
  StorageType stg_type = CharPixel;
@@ -8120,7 +8139,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
8120
8139
  }
8121
8140
  if ((unsigned long)(buffer_l / type_sz) < npixels)
8122
8141
  {
8123
- rb_raise(rb_eArgError, "pixel buffer too small (need %lu channel values, got %"RMIuSIZE")",
8142
+ rb_raise(rb_eArgError, "pixel buffer too small (need %lu channel values, got %" RMIuSIZE ")",
8124
8143
  npixels, buffer_l/type_sz);
8125
8144
  }
8126
8145
  }
@@ -8189,7 +8208,8 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
8189
8208
  #else
8190
8209
  GVL_STRUCT_TYPE(ImportImagePixels) args = { image, x_off, y_off, cols, rows, map, stg_type, buffer };
8191
8210
  #endif
8192
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args);
8211
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args);
8212
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
8193
8213
 
8194
8214
  // Free pixel array before checking for errors.
8195
8215
  if (pixels)
@@ -8253,7 +8273,7 @@ build_inspect_string(Image *image, char *buffer, size_t len)
8253
8273
  // Print scene number.
8254
8274
  if ((GetPreviousImageInList(image) != NULL) && (GetNextImageInList(image) != NULL) && image->scene > 0)
8255
8275
  {
8256
- x += snprintf(buffer+x, len-x, "[%"RMIuSIZE"]", image->scene);
8276
+ x += snprintf(buffer+x, len-x, "[%" RMIuSIZE "]", image->scene);
8257
8277
  }
8258
8278
  // Print format
8259
8279
  x += snprintf(buffer+x, len-x, " %s ", image->magick);
@@ -8263,17 +8283,17 @@ build_inspect_string(Image *image, char *buffer, size_t len)
8263
8283
  {
8264
8284
  if (image->magick_columns != image->columns || image->magick_rows != image->rows)
8265
8285
  {
8266
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"x%"RMIuSIZE"=>", image->magick_columns, image->magick_rows);
8286
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "x%" RMIuSIZE "=>", image->magick_columns, image->magick_rows);
8267
8287
  }
8268
8288
  }
8269
8289
 
8270
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"x%"RMIuSIZE" ", image->columns, image->rows);
8290
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "x%" RMIuSIZE " ", image->columns, image->rows);
8271
8291
 
8272
8292
  // Print current columnsXrows
8273
8293
  if ( image->page.width != 0 || image->page.height != 0
8274
8294
  || image->page.x != 0 || image->page.y != 0)
8275
8295
  {
8276
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"x%"RMIuSIZE"+%"RMIdSIZE"+%"RMIdSIZE" ",
8296
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "x%" RMIuSIZE "+%" RMIdSIZE "+%" RMIdSIZE " ",
8277
8297
  image->page.width, image->page.height,
8278
8298
  image->page.x, image->page.y);
8279
8299
  }
@@ -8285,17 +8305,17 @@ build_inspect_string(Image *image, char *buffer, size_t len)
8285
8305
  {
8286
8306
  if (image->total_colors >= (unsigned long)(1 << 24))
8287
8307
  {
8288
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"mc ", image->total_colors/1024/1024);
8308
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "mc ", image->total_colors/1024/1024);
8289
8309
  }
8290
8310
  else
8291
8311
  {
8292
8312
  if (image->total_colors >= (unsigned long)(1 << 16))
8293
8313
  {
8294
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"kc ", image->total_colors/1024);
8314
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "kc ", image->total_colors/1024);
8295
8315
  }
8296
8316
  else
8297
8317
  {
8298
- x += snprintf(buffer+x, len-x, "%"RMIuSIZE"c ", image->total_colors);
8318
+ x += snprintf(buffer+x, len-x, "%" RMIuSIZE "c ", image->total_colors);
8299
8319
  }
8300
8320
  }
8301
8321
  }
@@ -8310,7 +8330,7 @@ build_inspect_string(Image *image, char *buffer, size_t len)
8310
8330
  }
8311
8331
  else
8312
8332
  {
8313
- x += snprintf(buffer+x, len-x, "PseudoClass %"RMIuSIZE"=>%"RMIuSIZE"c ", image->total_colors, image->colors);
8333
+ x += snprintf(buffer+x, len-x, "PseudoClass %" RMIuSIZE "=>%" RMIuSIZE "c ", image->total_colors, image->colors);
8314
8334
  if (image->error.mean_error_per_pixel != 0.0)
8315
8335
  {
8316
8336
  x += snprintf(buffer+x, len-x, "%ld/%.6f/%.6fdb ",
@@ -8632,7 +8652,7 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8632
8652
  MagickPixel black_color, white_color;
8633
8653
  ChannelType channels;
8634
8654
  MagickBooleanType invert = MagickTrue;
8635
- MagickBooleanType status;
8655
+ MagickBooleanType okay;
8636
8656
  #if defined(IMAGEMAGICK_7)
8637
8657
  ExceptionInfo *exception;
8638
8658
  #endif
@@ -8647,7 +8667,7 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8647
8667
  switch (argc)
8648
8668
  {
8649
8669
  case 3:
8650
- invert = RTEST(argv[2]);
8670
+ invert = (MagickBooleanType)RTEST(argv[2]);
8651
8671
 
8652
8672
  case 2:
8653
8673
  Color_to_MagickPixel(image, &white_color, argv[1]);
@@ -8675,16 +8695,18 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8675
8695
  exception = AcquireExceptionInfo();
8676
8696
  BEGIN_CHANNEL_MASK(new_image, channels);
8677
8697
  GVL_STRUCT_TYPE(LevelImageColors) args = { new_image, &black_color, &white_color, invert, exception };
8678
- status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImageColors), &args);
8698
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImageColors), &args);
8699
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
8679
8700
  END_CHANNEL_MASK(new_image);
8680
8701
  rm_check_exception(exception, new_image, DestroyOnError);
8681
8702
  DestroyExceptionInfo(exception);
8682
8703
  #else
8683
8704
  GVL_STRUCT_TYPE(LevelColorsImageChannel) args = { new_image, channels, &black_color, &white_color, invert };
8684
- status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelColorsImageChannel), &args);
8705
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelColorsImageChannel), &args);
8706
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
8685
8707
  rm_check_image_exception(new_image, DestroyOnError);
8686
8708
  #endif
8687
- if (!status)
8709
+ if (!okay)
8688
8710
  {
8689
8711
  rb_raise(rb_eRuntimeError, "LevelImageColors failed for unknown reason.");
8690
8712
  }
@@ -8717,7 +8739,7 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8717
8739
  ChannelType channels;
8718
8740
  double black_point, white_point;
8719
8741
  double gamma = 1.0;
8720
- MagickBooleanType status;
8742
+ MagickBooleanType okay;
8721
8743
  #if defined(IMAGEMAGICK_7)
8722
8744
  ExceptionInfo *exception;
8723
8745
  #endif
@@ -8752,17 +8774,19 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8752
8774
  exception = AcquireExceptionInfo();
8753
8775
  BEGIN_CHANNEL_MASK(new_image, channels);
8754
8776
  GVL_STRUCT_TYPE(LevelizeImage) args = { new_image, black_point, white_point, gamma, exception };
8755
- status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImage), &args);
8777
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImage), &args);
8778
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
8756
8779
  END_CHANNEL_MASK(new_image);
8757
8780
  rm_check_exception(exception, new_image, DestroyOnError);
8758
8781
  DestroyExceptionInfo(exception);
8759
8782
  #else
8760
8783
  GVL_STRUCT_TYPE(LevelizeImageChannel) args = { new_image, channels, black_point, white_point, gamma };
8761
- status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImageChannel), &args);
8784
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImageChannel), &args);
8785
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
8762
8786
  rm_check_image_exception(new_image, DestroyOnError);
8763
8787
  #endif
8764
8788
 
8765
- if (!status)
8789
+ if (!okay)
8766
8790
  {
8767
8791
  rb_raise(rb_eRuntimeError, "LevelizeImageChannel failed for unknown reason.");
8768
8792
  }
@@ -8868,14 +8892,14 @@ Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
8868
8892
  * @see Image#_dump
8869
8893
  */
8870
8894
  VALUE
8871
- Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8895
+ Image__load(VALUE klass ATTRIBUTE_UNUSED, VALUE str)
8872
8896
  {
8873
8897
  Image *image;
8874
8898
  ImageInfo *info;
8875
8899
  DumpedImage mi;
8876
8900
  ExceptionInfo *exception;
8877
8901
  char *blob;
8878
- long length;
8902
+ size_t length;
8879
8903
 
8880
8904
  blob = rm_str2cstr(str, &length);
8881
8905
 
@@ -8906,7 +8930,7 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8906
8930
  mi.len = ((DumpedImage *)blob)->len;
8907
8931
 
8908
8932
  // Must be bigger than the header
8909
- if (length <= (long)(mi.len+sizeof(DumpedImage)-MaxTextExtent))
8933
+ if (length <= (mi.len + sizeof(DumpedImage) - MaxTextExtent))
8910
8934
  {
8911
8935
  rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)");
8912
8936
  }
@@ -9075,7 +9099,7 @@ Image_marshal_load(VALUE self, VALUE ary)
9075
9099
  {
9076
9100
  strlcpy(info->filename, RSTRING_PTR(filename), sizeof(info->filename));
9077
9101
  }
9078
- GVL_STRUCT_TYPE(BlobToImage) args = { info, RSTRING_PTR(blob), RSTRING_LEN(blob), exception };
9102
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, RSTRING_PTR(blob), (size_t)RSTRING_LEN(blob), exception };
9079
9103
  image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
9080
9104
 
9081
9105
  // Destroy info before raising an exception
@@ -9377,7 +9401,7 @@ Image_matte_flood_fill(int argc, VALUE *argv, VALUE self)
9377
9401
  y = NUM2LONG(argv[2]);
9378
9402
  if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
9379
9403
  {
9380
- rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %"RMIuSIZE"x%"RMIuSIZE"",
9404
+ rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %" RMIuSIZE "x%" RMIuSIZE "",
9381
9405
  x, y, image->columns, image->rows);
9382
9406
  }
9383
9407
 
@@ -9728,7 +9752,7 @@ VALUE
9728
9752
  Image_negate(int argc, VALUE *argv, VALUE self)
9729
9753
  {
9730
9754
  Image *image, *new_image;
9731
- unsigned int grayscale = MagickFalse;
9755
+ MagickBooleanType grayscale = MagickFalse;
9732
9756
  #if defined(IMAGEMAGICK_7)
9733
9757
  ExceptionInfo *exception;
9734
9758
  #endif
@@ -9736,7 +9760,7 @@ Image_negate(int argc, VALUE *argv, VALUE self)
9736
9760
  image = rm_check_destroyed(self);
9737
9761
  if (argc == 1)
9738
9762
  {
9739
- grayscale = RTEST(argv[0]);
9763
+ grayscale = (MagickBooleanType)RTEST(argv[0]);
9740
9764
  }
9741
9765
  else if (argc > 1)
9742
9766
  {
@@ -9783,7 +9807,7 @@ Image_negate_channel(int argc, VALUE *argv, VALUE self)
9783
9807
  {
9784
9808
  Image *image, *new_image;
9785
9809
  ChannelType channels;
9786
- unsigned int grayscale = MagickFalse;
9810
+ MagickBooleanType grayscale = MagickFalse;
9787
9811
  #if defined(IMAGEMAGICK_7)
9788
9812
  ExceptionInfo *exception;
9789
9813
  #endif
@@ -9798,7 +9822,7 @@ Image_negate_channel(int argc, VALUE *argv, VALUE self)
9798
9822
  }
9799
9823
  else if (argc == 1)
9800
9824
  {
9801
- grayscale = RTEST(argv[0]);
9825
+ grayscale = (MagickBooleanType)RTEST(argv[0]);
9802
9826
  }
9803
9827
 
9804
9828
  new_image = rm_clone_image(image);
@@ -9827,11 +9851,11 @@ Image_negate_channel(int argc, VALUE *argv, VALUE self)
9827
9851
  * @return [Magick::Image] a newly allocated image
9828
9852
  */
9829
9853
  VALUE
9830
- Image_alloc(VALUE class)
9854
+ Image_alloc(VALUE klass)
9831
9855
  {
9832
9856
  VALUE image_obj;
9833
9857
 
9834
- image_obj = TypedData_Wrap_Struct(class, &rm_image_data_type, NULL);
9858
+ image_obj = TypedData_Wrap_Struct(klass, &rm_image_data_type, NULL);
9835
9859
 
9836
9860
  RB_GC_GUARD(image_obj);
9837
9861
 
@@ -10177,12 +10201,14 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
10177
10201
  #if defined(IMAGEMAGICK_7)
10178
10202
  exception = AcquireExceptionInfo();
10179
10203
  GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, MagickFalse, exception };
10180
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
10204
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
10205
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10181
10206
  rm_check_exception(exception, new_image, DestroyOnError);
10182
10207
  DestroyExceptionInfo(exception);
10183
10208
  #else
10184
10209
  GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse };
10185
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
10210
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
10211
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10186
10212
  rm_check_image_exception(new_image, DestroyOnError);
10187
10213
  #endif
10188
10214
 
@@ -10250,7 +10276,7 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
10250
10276
  rb_raise(rb_eArgError, "fuzz must be >= 0.0 (%g given)", fuzz);
10251
10277
  }
10252
10278
  case 3:
10253
- invert = RTEST(argv[2]);
10279
+ invert = (MagickBooleanType)RTEST(argv[2]);
10254
10280
  case 2:
10255
10281
  // Allow color name or Pixel
10256
10282
  Color_to_MagickPixel(image, &fill_pp, argv[1]);
@@ -10269,14 +10295,16 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
10269
10295
  exception = AcquireExceptionInfo();
10270
10296
  BEGIN_CHANNEL_MASK(new_image, channels);
10271
10297
  GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, invert, exception };
10272
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
10298
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
10299
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10273
10300
  END_CHANNEL_MASK(new_image);
10274
10301
  new_image->fuzz = keep;
10275
10302
  rm_check_exception(exception, new_image, DestroyOnError);
10276
10303
  DestroyExceptionInfo(exception);
10277
10304
  #else
10278
10305
  GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, channels, &target_pp, &fill_pp, invert };
10279
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
10306
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
10307
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10280
10308
 
10281
10309
  new_image->fuzz = keep;
10282
10310
  rm_check_image_exception(new_image, DestroyOnError);
@@ -10478,11 +10506,11 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
10478
10506
  case 3:
10479
10507
  if (TYPE(argv[argc - 1]) == T_HASH)
10480
10508
  {
10481
- invert = RTEST(argv[1]);
10509
+ invert = (MagickBooleanType)RTEST(argv[1]);
10482
10510
  }
10483
10511
  else
10484
10512
  {
10485
- invert = RTEST(argv[2]);
10513
+ invert = (MagickBooleanType)RTEST(argv[2]);
10486
10514
  }
10487
10515
  case 2:
10488
10516
  alpha = get_named_alpha_value(argv[argc - 1]);
@@ -10503,13 +10531,15 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
10503
10531
  #if defined(IMAGEMAGICK_7)
10504
10532
  exception = AcquireExceptionInfo();
10505
10533
  GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, alpha, invert, exception };
10506
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10534
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10535
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10507
10536
  new_image->fuzz = keep;
10508
10537
  rm_check_exception(exception, new_image, DestroyOnError);
10509
10538
  DestroyExceptionInfo(exception);
10510
10539
  #else
10511
- GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, QuantumRange - alpha, invert };
10512
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10540
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, (Quantum)(QuantumRange - alpha), invert };
10541
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10542
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10513
10543
  new_image->fuzz = keep;
10514
10544
 
10515
10545
  // Is it possible for TransparentPaintImage to silently fail?
@@ -10550,9 +10580,9 @@ Image_palette_q(VALUE self)
10550
10580
  * @see Image#read
10551
10581
  */
10552
10582
  VALUE
10553
- Image_ping(VALUE class, VALUE file_arg)
10583
+ Image_ping(VALUE klass, VALUE file_arg)
10554
10584
  {
10555
- return rd_image(class, file_arg, GVL_FUNC(PingImage));
10585
+ return rd_image(klass, file_arg, GVL_FUNC(PingImage));
10556
10586
  }
10557
10587
 
10558
10588
 
@@ -10619,7 +10649,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10619
10649
  {
10620
10650
  exception = AcquireExceptionInfo();
10621
10651
  GVL_STRUCT_TYPE(GetVirtualPixels) args = { image, x, y, 1, 1, exception };
10622
- old_pixel = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
10652
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
10653
+ old_pixel = reinterpret_cast<decltype(old_pixel)>(ret);
10623
10654
  CHECK_EXCEPTION();
10624
10655
 
10625
10656
  DestroyExceptionInfo(exception);
@@ -10672,7 +10703,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10672
10703
  {
10673
10704
  #if defined(IMAGEMAGICK_7)
10674
10705
  GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
10675
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10706
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10707
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10676
10708
  CHECK_EXCEPTION();
10677
10709
  if (!okay)
10678
10710
  {
@@ -10681,7 +10713,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10681
10713
  }
10682
10714
  #else
10683
10715
  GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
10684
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10716
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10717
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
10685
10718
  rm_check_image_exception(image, RetainOnError);
10686
10719
  if (!okay)
10687
10720
  {
@@ -10695,7 +10728,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10695
10728
  #endif
10696
10729
 
10697
10730
  GVL_STRUCT_TYPE(GetAuthenticPixels) args = { image, x, y, 1, 1, exception };
10698
- pixel = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
10731
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
10732
+ pixel = reinterpret_cast<decltype(pixel)>(ret);
10699
10733
  CHECK_EXCEPTION();
10700
10734
 
10701
10735
  if (pixel)
@@ -10989,13 +11023,13 @@ Image_quantum_depth(VALUE self)
10989
11023
  * quantum_operator will be faster, especially for large numbers of pixels, since it does not need
10990
11024
  * to convert the pixels from C to Ruby.
10991
11025
  *
10992
- * @overload quantum_operator(operator, rvalue, channel = Magick::AllChannels)
10993
- * @param operator [Magick::QuantumExpressionOperator] the operator
11026
+ * @overload quantum_operator(quantum_expression_op, rvalue, channel = Magick::AllChannels)
11027
+ * @param quantum_expression_op [Magick::QuantumExpressionOperator] the operator
10994
11028
  * @param rvalue [Float] the operation rvalue.
10995
11029
  * @param channel [Magick::ChannelType] a ChannelType arguments.
10996
11030
  *
10997
- * @overload quantum_operator(operator, rvalue, *channels)
10998
- * @param operator [Magick::QuantumExpressionOperator] the operator
11031
+ * @overload quantum_operator(quantum_expression_op, rvalue, *channels)
11032
+ * @param quantum_expression_op [Magick::QuantumExpressionOperator] the operator
10999
11033
  * @param rvalue [Float] the operation rvalue.
11000
11034
  * @param *channels [Magick::ChannelType] one or more ChannelType arguments.
11001
11035
  *
@@ -11005,7 +11039,7 @@ VALUE
11005
11039
  Image_quantum_operator(int argc, VALUE *argv, VALUE self)
11006
11040
  {
11007
11041
  Image *image;
11008
- QuantumExpressionOperator operator;
11042
+ QuantumExpressionOperator quantum_expression_op;
11009
11043
  MagickEvaluateOperator qop;
11010
11044
  double rvalue;
11011
11045
  ChannelType channel;
@@ -11028,7 +11062,7 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
11028
11062
  /* Fall through */
11029
11063
  case 2:
11030
11064
  rvalue = NUM2DBL(argv[1]);
11031
- VALUE_TO_ENUM(argv[0], operator, QuantumExpressionOperator);
11065
+ VALUE_TO_ENUM(argv[0], quantum_expression_op, QuantumExpressionOperator);
11032
11066
  break;
11033
11067
  default:
11034
11068
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
@@ -11036,7 +11070,7 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
11036
11070
  }
11037
11071
 
11038
11072
  // Map QuantumExpressionOperator to MagickEvaluateOperator
11039
- switch (operator)
11073
+ switch (quantum_expression_op)
11040
11074
  {
11041
11075
  default:
11042
11076
  case UndefinedQuantumOperator:
@@ -11201,7 +11235,7 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
11201
11235
  {
11202
11236
  VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
11203
11237
  #if defined(IMAGEMAGICK_6)
11204
- quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
11238
+ quantize_info.dither = (MagickBooleanType)(quantize_info.dither_method != NoDitherMethod);
11205
11239
  #endif
11206
11240
  }
11207
11241
  else
@@ -11259,10 +11293,12 @@ Image_radial_blur(VALUE self, VALUE angle_obj)
11259
11293
 
11260
11294
  #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
11261
11295
  GVL_STRUCT_TYPE(RotationalBlurImage) args = { image, angle, exception };
11262
- new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotationalBlurImage), &args);
11296
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotationalBlurImage), &args);
11297
+ new_image = reinterpret_cast<decltype(new_image)>(ret);
11263
11298
  #else
11264
11299
  GVL_STRUCT_TYPE(RadialBlurImage) args = { image, angle, exception };
11265
- new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RadialBlurImage), &args);
11300
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RadialBlurImage), &args);
11301
+ new_image = reinterpret_cast<decltype(new_image)>(ret);
11266
11302
  #endif
11267
11303
  rm_check_exception(exception, new_image, DestroyOnError);
11268
11304
  DestroyExceptionInfo(exception);
@@ -11414,7 +11450,7 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11414
11450
  {
11415
11451
  Image *image, *new_image;
11416
11452
  RectangleInfo rect;
11417
- int raised = MagickTrue; // default
11453
+ MagickBooleanType raised = MagickTrue; // default
11418
11454
  #if defined(IMAGEMAGICK_7)
11419
11455
  ExceptionInfo *exception;
11420
11456
  #endif
@@ -11427,7 +11463,7 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11427
11463
  switch (argc)
11428
11464
  {
11429
11465
  case 3:
11430
- raised = RTEST(argv[2]);
11466
+ raised = (MagickBooleanType)RTEST(argv[2]);
11431
11467
  case 2:
11432
11468
  rect.height = NUM2ULONG(argv[1]);
11433
11469
  case 1:
@@ -11464,9 +11500,9 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11464
11500
  * @return [Array<Magick::Image>] an array of 1 or more new image objects
11465
11501
  */
11466
11502
  VALUE
11467
- Image_read(VALUE class, VALUE file_arg)
11503
+ Image_read(VALUE klass, VALUE file_arg)
11468
11504
  {
11469
- return rd_image(class, file_arg, GVL_FUNC(ReadImage));
11505
+ return rd_image(klass, file_arg, GVL_FUNC(ReadImage));
11470
11506
  }
11471
11507
 
11472
11508
 
@@ -11498,7 +11534,7 @@ typedef GVL_STRUCT_TYPE(PingImage) GVL_STRUCT_TYPE(rd_image);
11498
11534
  * - Yields to a block to get Image::Info attributes before calling
11499
11535
  * Read/PingImage
11500
11536
  *
11501
- * @param class the Ruby class for an Image
11537
+ * @param klass the Ruby class for an Image
11502
11538
  * @param file the file containing image data
11503
11539
  * @param reader which image reader to use (ReadImage or PingImage)
11504
11540
  * @return an array of 1 or more new image objects
@@ -11514,10 +11550,10 @@ void sig_handler(int sig ATTRIBUTE_UNUSED)
11514
11550
  #endif
11515
11551
 
11516
11552
  static VALUE
11517
- rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, gvl_function_t fp)
11553
+ rd_image(VALUE klass ATTRIBUTE_UNUSED, VALUE file, gvl_function_t fp)
11518
11554
  {
11519
11555
  char *filename;
11520
- long filename_l;
11556
+ size_t filename_l;
11521
11557
  Info *info;
11522
11558
  VALUE info_obj;
11523
11559
  Image *images;
@@ -11539,7 +11575,7 @@ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, gvl_function_t fp)
11539
11575
  else
11540
11576
  {
11541
11577
  // Convert arg to string. If an exception occurs raise an error condition.
11542
- file = rb_rescue(rb_String, file, file_arg_rescue, file);
11578
+ file = rb_rescue(RESCUE_FUNC(rb_String), file, RESCUE_EXCEPTION_HANDLER_FUNC(file_arg_rescue), file);
11543
11579
 
11544
11580
  filename = rm_str2cstr(file, &filename_l);
11545
11581
  filename_l = min(filename_l, MaxTextExtent-1);
@@ -11677,7 +11713,7 @@ Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content)
11677
11713
  Image *images;
11678
11714
  ImageInfo *info;
11679
11715
  char *image_data;
11680
- long x, image_data_l;
11716
+ size_t x, image_data_l;
11681
11717
  unsigned char *blob;
11682
11718
  size_t blob_l;
11683
11719
  ExceptionInfo *exception;
@@ -12252,7 +12288,7 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
12252
12288
  Image *image, *new_image;
12253
12289
  double degrees;
12254
12290
  char *arrow;
12255
- long arrow_l;
12291
+ size_t arrow_l;
12256
12292
  ExceptionInfo *exception;
12257
12293
 
12258
12294
  TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
@@ -12668,7 +12704,7 @@ VALUE
12668
12704
  Image_separate(int argc, VALUE *argv, VALUE self)
12669
12705
  {
12670
12706
  Image *image, *new_images;
12671
- ChannelType channels = 0;
12707
+ ChannelType channels = UndefinedChannel;
12672
12708
  ExceptionInfo *exception;
12673
12709
 
12674
12710
  image = rm_check_destroyed(self);
@@ -12757,8 +12793,8 @@ VALUE
12757
12793
  Image_segment(int argc, VALUE *argv, VALUE self)
12758
12794
  {
12759
12795
  Image *image, *new_image;
12760
- int colorspace = RGBColorspace; // These are the Magick++ defaults
12761
- unsigned int verbose = MagickFalse;
12796
+ ColorspaceType colorspace = RGBColorspace; // These are the Magick++ defaults
12797
+ MagickBooleanType verbose = MagickFalse;
12762
12798
  double cluster_threshold = 1.0;
12763
12799
  double smoothing_threshold = 1.5;
12764
12800
  #if defined(IMAGEMAGICK_7)
@@ -12769,7 +12805,7 @@ Image_segment(int argc, VALUE *argv, VALUE self)
12769
12805
  switch (argc)
12770
12806
  {
12771
12807
  case 4:
12772
- verbose = RTEST(argv[3]);
12808
+ verbose = (MagickBooleanType)RTEST(argv[3]);
12773
12809
  case 3:
12774
12810
  smoothing_threshold = NUM2DBL(argv[2]);
12775
12811
  case 2:
@@ -12909,7 +12945,7 @@ Image_shade(int argc, VALUE *argv, VALUE self)
12909
12945
  {
12910
12946
  Image *image, *new_image;
12911
12947
  double azimuth = 30.0, elevation = 30.0;
12912
- unsigned int shading = MagickFalse;
12948
+ MagickBooleanType shading = MagickFalse;
12913
12949
  ExceptionInfo *exception;
12914
12950
 
12915
12951
  image = rm_check_destroyed(self);
@@ -12920,7 +12956,7 @@ Image_shade(int argc, VALUE *argv, VALUE self)
12920
12956
  case 2:
12921
12957
  azimuth = NUM2DBL(argv[1]);
12922
12958
  case 1:
12923
- shading = RTEST(argv[0]);
12959
+ shading = (MagickBooleanType)RTEST(argv[0]);
12924
12960
  case 0:
12925
12961
  break;
12926
12962
  default:
@@ -13888,7 +13924,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13888
13924
  #if defined(IMAGEMAGICK_7)
13889
13925
  exception = AcquireExceptionInfo();
13890
13926
  GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
13891
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13927
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13928
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
13892
13929
  CHECK_EXCEPTION();
13893
13930
  if (!okay)
13894
13931
  {
@@ -13897,7 +13934,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13897
13934
  }
13898
13935
  #else
13899
13936
  GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
13900
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13937
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13938
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
13901
13939
  rm_check_image_exception(image, RetainOnError);
13902
13940
  if (!okay)
13903
13941
  {
@@ -13910,7 +13948,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13910
13948
  // from the pixels argument.
13911
13949
  {
13912
13950
  GVL_STRUCT_TYPE(GetAuthenticPixels) args = { image, x, y, cols, rows, exception };
13913
- pixels = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
13951
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
13952
+ pixels = reinterpret_cast<decltype(pixels)>(ret);
13914
13953
  CHECK_EXCEPTION();
13915
13954
 
13916
13955
  if (pixels)
@@ -14063,7 +14102,7 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj,
14063
14102
 
14064
14103
  if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
14065
14104
  {
14066
- rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %"RMIuSIZE"x%"RMIuSIZE"",
14105
+ rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %" RMIuSIZE "x%" RMIuSIZE "",
14067
14106
  x, y, image->columns, image->rows);
14068
14107
  }
14069
14108
 
@@ -14530,7 +14569,7 @@ Image_to_blob(VALUE self)
14530
14569
  || !rm_strcasecmp(magick_info->name, "JPG"))
14531
14570
  && (image->rows == 0 || image->columns == 0))
14532
14571
  {
14533
- rb_raise(rb_eRuntimeError, "Can't convert %"RMIuSIZE"x%"RMIuSIZE" %.4s image to a blob",
14572
+ rb_raise(rb_eRuntimeError, "Can't convert %" RMIuSIZE "x%" RMIuSIZE " %.4s image to a blob",
14534
14573
  image->columns, image->rows, magick_info->name);
14535
14574
  }
14536
14575
  }
@@ -14548,7 +14587,7 @@ Image_to_blob(VALUE self)
14548
14587
  return Qnil;
14549
14588
  }
14550
14589
 
14551
- blob_str = rb_str_new(blob, length);
14590
+ blob_str = rb_str_new((const char *)blob, length);
14552
14591
 
14553
14592
  magick_free((void*)blob);
14554
14593
 
@@ -14685,12 +14724,14 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
14685
14724
  #if defined(IMAGEMAGICK_7)
14686
14725
  exception = AcquireExceptionInfo();
14687
14726
  GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, alpha, MagickFalse, exception };
14688
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14727
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14728
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
14689
14729
  rm_check_exception(exception, new_image, DestroyOnError);
14690
14730
  DestroyExceptionInfo(exception);
14691
14731
  #else
14692
- GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, QuantumRange - alpha, MagickFalse };
14693
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14732
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, (Quantum)(QuantumRange - alpha), MagickFalse };
14733
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14734
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
14694
14735
  rm_check_image_exception(new_image, DestroyOnError);
14695
14736
  #endif
14696
14737
  if (!okay)
@@ -14739,11 +14780,11 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
14739
14780
  case 4:
14740
14781
  if (TYPE(argv[argc - 1]) == T_HASH)
14741
14782
  {
14742
- invert = RTEST(argv[3]);
14783
+ invert = (MagickBooleanType)RTEST(argv[3]);
14743
14784
  }
14744
14785
  else
14745
14786
  {
14746
- invert = RTEST(argv[2]);
14787
+ invert = (MagickBooleanType)RTEST(argv[2]);
14747
14788
  }
14748
14789
  case 3:
14749
14790
  alpha = get_named_alpha_value(argv[argc - 1]);
@@ -14761,12 +14802,14 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
14761
14802
  #if defined(IMAGEMAGICK_7)
14762
14803
  exception = AcquireExceptionInfo();
14763
14804
  GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, alpha, invert, exception };
14764
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14805
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14806
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
14765
14807
  rm_check_exception(exception, new_image, DestroyOnError);
14766
14808
  DestroyExceptionInfo(exception);
14767
14809
  #else
14768
- GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, QuantumRange - alpha, invert };
14769
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14810
+ GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, (Quantum)(QuantumRange - alpha), invert };
14811
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14812
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
14770
14813
  rm_check_image_exception(new_image, DestroyOnError);
14771
14814
  #endif
14772
14815
  if (!okay)
@@ -15711,7 +15754,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15711
15754
  #endif
15712
15755
 
15713
15756
  GVL_STRUCT_TYPE(GetVirtualPixels) args_GetVirtualPixels = { reflection, 0, y, image->columns, 1, exception };
15714
- p = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args_GetVirtualPixels);
15757
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args_GetVirtualPixels);
15758
+ p = reinterpret_cast<decltype(p)>(ret);
15715
15759
  rm_check_exception(exception, reflection, DestroyOnError);
15716
15760
  if (!p)
15717
15761
  {
@@ -15795,7 +15839,7 @@ Image_white_threshold(int argc, VALUE *argv, VALUE self)
15795
15839
  void add_format_prefix(Info *info, VALUE file)
15796
15840
  {
15797
15841
  char *filename;
15798
- long filename_l;
15842
+ size_t filename_l;
15799
15843
  const MagickInfo *magick_info, *magick_info2;
15800
15844
  ExceptionInfo *exception;
15801
15845
  char magic[MaxTextExtent];
@@ -15808,7 +15852,7 @@ void add_format_prefix(Info *info, VALUE file)
15808
15852
  {
15809
15853
  FilePathStringValue(file);
15810
15854
  }
15811
- file = rb_rescue(rb_String, file, file_arg_rescue, file);
15855
+ file = rb_rescue(RESCUE_FUNC(rb_String), file, RESCUE_EXCEPTION_HANDLER_FUNC(file_arg_rescue), file);
15812
15856
 
15813
15857
  filename = rm_str2cstr(file, &filename_l);
15814
15858
 
@@ -15822,7 +15866,7 @@ void add_format_prefix(Info *info, VALUE file)
15822
15866
  // If the filename starts with a prefix, and it's a valid image format
15823
15867
  // prefix, then check for a conflict. If it's not a valid format prefix,
15824
15868
  // ignore it.
15825
- p = memchr(filename, ':', (size_t)filename_l);
15869
+ p = (char *)memchr(filename, ':', (size_t)filename_l);
15826
15870
  if (p)
15827
15871
  {
15828
15872
  memset(magic, '\0', sizeof(magic));
@@ -15903,7 +15947,8 @@ Image_write(VALUE self, VALUE file)
15903
15947
  // Ensure file is open - raise error if not
15904
15948
  GetOpenFile(file, fptr);
15905
15949
  rb_io_check_writable(fptr);
15906
- add_format_prefix(info, fptr->pathv);
15950
+
15951
+ add_format_prefix(info, rm_io_path(file));
15907
15952
  #if defined(_WIN32)
15908
15953
  SetImageInfoFile(info, NULL);
15909
15954
  #else
@@ -16310,7 +16355,7 @@ ChannelType extract_channels(int *argc, VALUE *argv)
16310
16355
  VALUE arg;
16311
16356
  ChannelType channels, ch_arg;
16312
16357
 
16313
- channels = 0;
16358
+ channels = UndefinedChannel;
16314
16359
  while (*argc > 0)
16315
16360
  {
16316
16361
  arg = argv[(*argc)-1];
@@ -16321,7 +16366,7 @@ ChannelType extract_channels(int *argc, VALUE *argv)
16321
16366
  break;
16322
16367
  }
16323
16368
  VALUE_TO_ENUM(arg, ch_arg, ChannelType);
16324
- channels |= ch_arg;
16369
+ channels = (ChannelType)(channels | ch_arg);
16325
16370
  *argc -= 1;
16326
16371
  }
16327
16372