rmagick 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (66) hide show
  1. data/ChangeLog +22 -0
  2. data/README.html +11 -63
  3. data/README.txt +8 -56
  4. data/configure +214 -787
  5. data/configure.ac +22 -24
  6. data/doc/comtasks.html +2 -2
  7. data/doc/constants.html +5 -6
  8. data/doc/draw.html +33 -14
  9. data/doc/ex/clip_path.rb +3 -0
  10. data/doc/ex/path.rb +1 -1
  11. data/doc/ex/polaroid.rb +23 -0
  12. data/doc/ex/tspan01.rb +2 -2
  13. data/doc/ex/tspan02.rb +2 -2
  14. data/doc/ex/tspan03.rb +3 -3
  15. data/doc/ex/wet_floor.rb +54 -0
  16. data/doc/ilist.html +83 -4
  17. data/doc/image1.html +4 -5
  18. data/doc/image2.html +395 -266
  19. data/doc/image3.html +104 -8
  20. data/doc/imageattrs.html +2 -2
  21. data/doc/imusage.html +2 -2
  22. data/doc/index.html +22 -18
  23. data/doc/info.html +28 -6
  24. data/doc/magick.html +125 -4
  25. data/doc/optequiv.html +196 -21
  26. data/doc/rvg.html +2 -2
  27. data/doc/rvgclip.html +2 -2
  28. data/doc/rvggroup.html +2 -2
  29. data/doc/rvgimage.html +2 -2
  30. data/doc/rvgpattern.html +2 -2
  31. data/doc/rvgshape.html +2 -2
  32. data/doc/rvgstyle.html +2 -2
  33. data/doc/rvgtext.html +2 -2
  34. data/doc/rvgtspan.html +2 -2
  35. data/doc/rvgtut.html +3 -3
  36. data/doc/rvguse.html +2 -2
  37. data/doc/rvgxform.html +2 -2
  38. data/doc/struct.html +2 -2
  39. data/doc/usage.html +26 -5
  40. data/ext/RMagick/MANIFEST +3 -1
  41. data/ext/RMagick/rmagick.h +46 -12
  42. data/ext/RMagick/rmagick_config.h.in +12 -2
  43. data/ext/RMagick/rmdraw.c +202 -62
  44. data/ext/RMagick/rmfill.c +36 -36
  45. data/ext/RMagick/rmilist.c +75 -31
  46. data/ext/RMagick/rmimage.c +640 -323
  47. data/ext/RMagick/rminfo.c +76 -15
  48. data/ext/RMagick/rmmain.c +107 -30
  49. data/ext/RMagick/rmutil.c +97 -68
  50. data/lib/RMagick.rb +11 -11
  51. data/lib/rvg/clippath.rb +38 -36
  52. data/lib/rvg/container.rb +120 -118
  53. data/lib/rvg/deep_equal.rb +44 -42
  54. data/lib/rvg/describable.rb +49 -47
  55. data/lib/rvg/embellishable.rb +399 -397
  56. data/lib/rvg/misc.rb +613 -603
  57. data/lib/rvg/paint.rb +38 -36
  58. data/lib/rvg/pathdata.rb +124 -122
  59. data/lib/rvg/rvg.rb +202 -198
  60. data/lib/rvg/stretchable.rb +132 -130
  61. data/lib/rvg/stylable.rb +101 -99
  62. data/lib/rvg/text.rb +173 -171
  63. data/lib/rvg/transformable.rb +120 -118
  64. data/lib/rvg/units.rb +60 -58
  65. data/rmagick.gemspec +1 -1
  66. metadata +5 -3
@@ -1,6 +1,6 @@
1
- /* $Id: rmilist.c,v 1.43 2006/08/29 22:33:25 rmagick Exp $ */
1
+ /* $Id: rmilist.c,v 1.46 2007/01/12 00:11:16 rmagick Exp $ */
2
2
  /*============================================================================\
3
- | Copyright (C) 2006 by Timothy P. Hunter
3
+ | Copyright (C) 2007 by Timothy P. Hunter
4
4
  | Name: rmilist.c
5
5
  | Author: Tim Hunter
6
6
  | Purpose: ImageList class method definitions for RMagick
@@ -78,7 +78,7 @@ ImageList_append(VALUE self, VALUE stack_arg)
78
78
  new_image = AppendImages(images, stack, &exception);
79
79
  rm_split(images);
80
80
  rm_check_exception(&exception, new_image, DestroyOnError);
81
- DestroyExceptionInfo(&exception);
81
+ (void) DestroyExceptionInfo(&exception);
82
82
 
83
83
  rm_ensure_result(new_image);
84
84
 
@@ -103,7 +103,7 @@ ImageList_average(VALUE self)
103
103
  new_image = AverageImages(images, &exception);
104
104
  rm_split(images);
105
105
  rm_check_exception(&exception, new_image, DestroyOnError);
106
- DestroyExceptionInfo(&exception);
106
+ (void) DestroyExceptionInfo(&exception);
107
107
 
108
108
  rm_ensure_result(new_image);
109
109
 
@@ -131,7 +131,7 @@ ImageList_coalesce(VALUE self)
131
131
  new_images = CoalesceImages(images, &exception);
132
132
  rm_split(images);
133
133
  rm_check_exception(&exception, new_images, DestroyOnError);
134
- DestroyExceptionInfo(&exception);
134
+ (void) DestroyExceptionInfo(&exception);
135
135
 
136
136
  rm_ensure_result(new_images);
137
137
 
@@ -157,7 +157,7 @@ ImageList_deconstruct(VALUE self)
157
157
  new_images = DeconstructImages(images, &exception);
158
158
  rm_split(images);
159
159
  rm_check_exception(&exception, new_images, DestroyOnError);
160
- DestroyExceptionInfo(&exception);
160
+ (void) DestroyExceptionInfo(&exception);
161
161
 
162
162
  rm_ensure_result(new_images);
163
163
 
@@ -206,7 +206,7 @@ ImageList_flatten_images(VALUE self)
206
206
  new_image = FlattenImages(images, &exception);
207
207
  rm_split(images);
208
208
  rm_check_exception(&exception, new_image, DestroyOnError);
209
- DestroyExceptionInfo(&exception);
209
+ (void) DestroyExceptionInfo(&exception);
210
210
 
211
211
  rm_ensure_result(new_image);
212
212
 
@@ -214,6 +214,50 @@ ImageList_flatten_images(VALUE self)
214
214
  }
215
215
 
216
216
 
217
+ /*
218
+ Method: ImageList#fx(expression[, channel...])
219
+ */
220
+ VALUE
221
+ ImageList_fx(int argc, VALUE *argv, VALUE self)
222
+ {
223
+ #if defined(HAVE_FXIMAGECHANNEL)
224
+ Image *images, *new_image;
225
+ char *expression;
226
+ ChannelType channels;
227
+ ExceptionInfo exception;
228
+
229
+
230
+ channels = extract_channels(&argc, argv);
231
+
232
+ // There must be exactly 1 remaining argument.
233
+ if (argc == 0)
234
+ {
235
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)");
236
+ }
237
+ else if (argc > 1)
238
+ {
239
+ raise_ChannelType_error(argv[argc-1]);
240
+ }
241
+
242
+ expression = STRING_PTR(argv[0]);
243
+
244
+ images = rm_images_from_imagelist(self);
245
+ GetExceptionInfo(&exception);
246
+ new_image = FxImageChannel(images, channels, expression, &exception);
247
+ rm_split(images);
248
+ rm_check_exception(&exception, new_image, DestroyOnError);
249
+ (void) DestroyExceptionInfo(&exception);
250
+
251
+ rm_ensure_result(new_image);
252
+
253
+ return rm_image_new(new_image);
254
+ #else
255
+ rm_not_implemented();
256
+ return (VALUE)0;
257
+ #endif
258
+ }
259
+
260
+
217
261
 
218
262
  /*
219
263
  Method: ImageList#map(reference, dither=false)
@@ -254,7 +298,7 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
254
298
  new_images = CloneImageList(images, &exception);
255
299
  rm_split(images);
256
300
  rm_check_exception(&exception, new_images, DestroyOnError);
257
- DestroyExceptionInfo(&exception);
301
+ (void) DestroyExceptionInfo(&exception);
258
302
 
259
303
  rm_ensure_result(new_images);
260
304
 
@@ -290,7 +334,7 @@ ImageList_montage(VALUE self)
290
334
  {
291
335
  // Run the block in the instance's context, allowing the app to modify the
292
336
  // object's attributes.
293
- rb_obj_instance_eval(0, NULL, montage_obj);
337
+ (void) rb_obj_instance_eval(0, NULL, montage_obj);
294
338
  }
295
339
 
296
340
  Data_Get_Struct(montage_obj, Montage, montage);
@@ -313,7 +357,7 @@ ImageList_montage(VALUE self)
313
357
  new_images = MontageImages(images, montage->info, &exception);
314
358
  rm_split(images);
315
359
  rm_check_exception(&exception, new_images, DestroyOnError);
316
- DestroyExceptionInfo(&exception);
360
+ (void) DestroyExceptionInfo(&exception);
317
361
 
318
362
  rm_ensure_result(new_images);
319
363
 
@@ -352,7 +396,7 @@ ImageList_morph(VALUE self, VALUE nimages)
352
396
  new_images = MorphImages(images, (unsigned long)number_images, &exception);
353
397
  rm_split(images);
354
398
  rm_check_exception(&exception, new_images, DestroyOnError);
355
- DestroyExceptionInfo(&exception);
399
+ (void) DestroyExceptionInfo(&exception);
356
400
 
357
401
  rm_ensure_result(new_images);
358
402
 
@@ -375,7 +419,7 @@ ImageList_mosaic(VALUE self)
375
419
  new_image = MosaicImages(images, &exception);
376
420
  rm_split(images);
377
421
  rm_check_exception(&exception, new_image, DestroyOnError);
378
- DestroyExceptionInfo(&exception);
422
+ (void) DestroyExceptionInfo(&exception);
379
423
 
380
424
  rm_ensure_result(new_image);
381
425
 
@@ -428,7 +472,7 @@ ImageList_optimize_layers(VALUE self, VALUE method)
428
472
 
429
473
  rm_split(images);
430
474
  rm_check_exception(&exception, new_images, DestroyOnError);
431
- DestroyExceptionInfo(&exception);
475
+ (void) DestroyExceptionInfo(&exception);
432
476
 
433
477
  rm_ensure_result(new_images);
434
478
 
@@ -478,7 +522,7 @@ rm_imagelist_from_images(Image *images)
478
522
  rm_imagelist_push(new_imagelist, rm_image_new(image));
479
523
  }
480
524
 
481
- rb_iv_set(new_imagelist, "@scene", INT2FIX(0));
525
+ (void) rb_iv_set(new_imagelist, "@scene", INT2FIX(0));
482
526
  return new_imagelist;
483
527
  }
484
528
 
@@ -522,7 +566,7 @@ VALUE
522
566
  rm_imagelist_scene_eq(VALUE imagelist, VALUE scene)
523
567
  {
524
568
  rm_check_frozen(imagelist);
525
- rb_iv_set(imagelist, "@scene", scene);
569
+ (void) rb_iv_set(imagelist, "@scene", scene);
526
570
  return scene;
527
571
  }
528
572
 
@@ -571,15 +615,15 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
571
615
  switch (argc)
572
616
  {
573
617
  case 5:
574
- quantize_info.measure_error = RTEST(argv[4]);
618
+ quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
575
619
  case 4:
576
- quantize_info.tree_depth = NUM2INT(argv[3]);
620
+ quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]);
577
621
  case 3:
578
- quantize_info.dither = RTEST(argv[2]);
622
+ quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
579
623
  case 2:
580
624
  VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
581
625
  case 1:
582
- quantize_info.number_colors = NUM2INT(argv[0]);
626
+ quantize_info.number_colors = NUM2ULONG(argv[0]);
583
627
  case 0:
584
628
  break;
585
629
  default:
@@ -598,12 +642,12 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
598
642
  new_images = CloneImageList(images, &exception);
599
643
  rm_split(images);
600
644
  rm_check_exception(&exception, new_images, DestroyOnError);
601
- DestroyExceptionInfo(&exception);
645
+ (void) DestroyExceptionInfo(&exception);
602
646
 
603
647
  rm_ensure_result(new_images);
604
648
 
605
649
 
606
- QuantizeImages(&quantize_info, new_images);
650
+ (void) QuantizeImages(&quantize_info, new_images);
607
651
  rm_check_exception(&exception, new_images, DestroyOnError);
608
652
 
609
653
  // Create new ImageList object, convert mapped image sequence to images,
@@ -616,7 +660,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
616
660
 
617
661
  // Set @scene in new ImageList object to same value as in self.
618
662
  scene = rb_iv_get(self, "@scene");
619
- rb_iv_set(new_imagelist, "@scene", scene);
663
+ (void) rb_iv_set(new_imagelist, "@scene", scene);
620
664
 
621
665
  return new_imagelist;
622
666
  }
@@ -645,7 +689,7 @@ ImageList_to_blob(VALUE self)
645
689
  images = rm_images_from_imagelist(self);
646
690
 
647
691
  GetExceptionInfo(&exception);
648
- (void) SetImageInfo(info, True, &exception);
692
+ (void) SetImageInfo(info, MagickTrue, &exception);
649
693
  rm_check_exception(&exception, images, RetainOnError);
650
694
 
651
695
  if (*info->magick != '\0')
@@ -660,7 +704,7 @@ ImageList_to_blob(VALUE self)
660
704
  // Unconditionally request multi-images support. The worst that
661
705
  // can happen is that there's only one image or the format
662
706
  // doesn't support multi-image files.
663
- info->adjoin = True;
707
+ info->adjoin = MagickTrue;
664
708
  #if defined(HAVE_IMAGESTOBLOB)
665
709
  blob = ImagesToBlob(info, images, &length, &exception);
666
710
  #else
@@ -672,7 +716,7 @@ ImageList_to_blob(VALUE self)
672
716
  }
673
717
  rm_split(images);
674
718
  CHECK_EXCEPTION()
675
- DestroyExceptionInfo(&exception);
719
+ (void) DestroyExceptionInfo(&exception);
676
720
 
677
721
 
678
722
  if (length == 0 || !blob)
@@ -680,7 +724,7 @@ ImageList_to_blob(VALUE self)
680
724
  return Qnil;
681
725
  }
682
726
 
683
- blob_str = rb_str_new(blob, length);
727
+ blob_str = rb_str_new(blob, (long)length);
684
728
  magick_free((void*)blob);
685
729
 
686
730
  return blob_str;
@@ -715,7 +759,7 @@ ImageList_write(VALUE self, VALUE file)
715
759
  volatile VALUE info_obj;
716
760
  char *filename;
717
761
  long filenameL;
718
- int scene;
762
+ unsigned long scene;
719
763
  ExceptionInfo exception;
720
764
 
721
765
  info_obj = rm_info_new();
@@ -755,20 +799,20 @@ ImageList_write(VALUE self, VALUE file)
755
799
  }
756
800
 
757
801
  GetExceptionInfo(&exception);
758
- (void) SetImageInfo(info, True, &exception);
802
+ (void) SetImageInfo(info, MagickTrue, &exception);
759
803
  rm_check_exception(&exception, images, RetainOnError);
760
- DestroyExceptionInfo(&exception);
804
+ (void) DestroyExceptionInfo(&exception);
761
805
 
762
806
  // Find out if the format supports multi-images files.
763
807
  GetExceptionInfo(&exception);
764
808
  m = GetMagickInfo(info->magick, &exception);
765
809
  rm_check_exception(&exception, images, RetainOnError);
766
- DestroyExceptionInfo(&exception);
810
+ (void) DestroyExceptionInfo(&exception);
767
811
 
768
812
  // Tell WriteImage if we want a multi-images file.
769
813
  if (rm_imagelist_length(self) > 1 && m->adjoin)
770
814
  {
771
- info->adjoin = True;
815
+ info->adjoin = MagickTrue;
772
816
  }
773
817
 
774
818
  for (img = images; img; img = GetNextImageInList(img))
@@ -1,6 +1,6 @@
1
- /* $Id: rmimage.c,v 1.183 2006/09/27 21:26:35 rmagick Exp $ */
1
+ /* $Id: rmimage.c,v 1.192 2007/01/20 17:43:10 rmagick Exp $ */
2
2
  /*============================================================================\
3
- | Copyright (C) 2006 by Timothy P. Hunter
3
+ | Copyright (C) 2007 by Timothy P. Hunter
4
4
  | Name: rmimage.c
5
5
  | Author: Tim Hunter
6
6
  | Purpose: Image class method definitions for RMagick
@@ -25,11 +25,11 @@ typedef unsigned int (thresholder_t)(Image *, const char *);
25
25
  typedef Image *(xformer_t)(const Image *, const RectangleInfo *, ExceptionInfo *);
26
26
 
27
27
  static VALUE cropper(int, int, VALUE *, VALUE);
28
- static VALUE effect_image(VALUE, int, VALUE *, effector_t *);
28
+ static VALUE effect_image(VALUE, int, VALUE *, effector_t);
29
29
  static VALUE flipflop(int, VALUE, flipper_t);
30
30
  static VALUE rd_image(VALUE, VALUE, reader_t);
31
31
  static VALUE rotate(int, int, VALUE *, VALUE);
32
- static VALUE scale(int, int, VALUE *, VALUE, scaler_t *);
32
+ static VALUE scale(int, int, VALUE *, VALUE, scaler_t);
33
33
  static VALUE threshold_image(int, VALUE *, VALUE, thresholder_t);
34
34
  static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, xformer_t);
35
35
  static VALUE array_from_images(Image *);
@@ -77,7 +77,7 @@ static VALUE adaptive_method(
77
77
  new_image = (fp)(image, radius, sigma, &exception);
78
78
  rm_check_exception(&exception, new_image, DestroyOnError);
79
79
 
80
- DestroyExceptionInfo(&exception);
80
+ (void) DestroyExceptionInfo(&exception);
81
81
 
82
82
  rm_ensure_result(new_image);
83
83
 
@@ -124,7 +124,7 @@ static VALUE adaptive_channel_method(
124
124
  new_image = (fp)(image, channels, radius, sigma, &exception);
125
125
  rm_check_exception(&exception, new_image, DestroyOnError);
126
126
 
127
- DestroyExceptionInfo(&exception);
127
+ (void) DestroyExceptionInfo(&exception);
128
128
 
129
129
  rm_ensure_result(new_image);
130
130
 
@@ -197,7 +197,7 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
197
197
  }
198
198
  drows = scale * image->rows + 0.5;
199
199
  dcols = scale * image->columns + 0.5;
200
- if (drows > ULONG_MAX || dcols > ULONG_MAX)
200
+ if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
201
201
  {
202
202
  rb_raise(rb_eRangeError, "resized image too big");
203
203
  }
@@ -213,7 +213,7 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
213
213
  new_image = AdaptiveResizeImage(image, columns, rows, &exception);
214
214
  rm_check_exception(&exception, new_image, DestroyOnError);
215
215
 
216
- DestroyExceptionInfo(&exception);
216
+ (void) DestroyExceptionInfo(&exception);
217
217
  rm_ensure_result(new_image);
218
218
 
219
219
  return rm_image_new(new_image);
@@ -274,13 +274,14 @@ VALUE
274
274
  Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
275
275
  {
276
276
  Image *image, *new_image;
277
- unsigned long width = 3, height = 3, offset = 0;
277
+ unsigned long width = 3, height = 3;
278
+ long offset = 0;
278
279
  ExceptionInfo exception;
279
280
 
280
281
  switch (argc)
281
282
  {
282
283
  case 3:
283
- offset = NUM2ULONG(argv[2]);
284
+ offset = NUM2LONG(argv[2]);
284
285
  case 2:
285
286
  height = NUM2ULONG(argv[1]);
286
287
  case 1:
@@ -297,7 +298,7 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
297
298
  new_image = AdaptiveThresholdImage(image, width, height, offset, &exception);
298
299
  rm_check_exception(&exception, new_image, DestroyOnError);
299
300
 
300
- DestroyExceptionInfo(&exception);
301
+ (void) DestroyExceptionInfo(&exception);
301
302
 
302
303
  rm_ensure_result(new_image);
303
304
 
@@ -324,7 +325,7 @@ Image_add_noise(VALUE self, VALUE noise)
324
325
  new_image = AddNoiseImage(image, noise_type, &exception);
325
326
  rm_check_exception(&exception, new_image, DestroyOnError);
326
327
 
327
- DestroyExceptionInfo(&exception);
328
+ (void) DestroyExceptionInfo(&exception);
328
329
 
329
330
  rm_ensure_result(new_image);
330
331
 
@@ -366,7 +367,7 @@ Image_add_noise_channel(int argc, VALUE *argv, VALUE self)
366
367
  new_image = AddNoiseImageChannel(image, channels, noise_type, &exception);
367
368
  rm_check_exception(&exception, new_image, DestroyOnError);
368
369
 
369
- DestroyExceptionInfo(&exception);
370
+ (void) DestroyExceptionInfo(&exception);
370
371
 
371
372
  rm_ensure_result(new_image);
372
373
 
@@ -406,14 +407,14 @@ Image_add_profile(VALUE self, VALUE name)
406
407
  info = CloneImageInfo(NULL);
407
408
  info->client_data= (void *)GetImageProfile(image,"8bim");
408
409
 
409
- strncpy(info->filename, profile_filename, min(profile_filename_l, sizeof(info->filename)));
410
+ strncpy(info->filename, profile_filename, min((size_t)profile_filename_l, sizeof(info->filename)));
410
411
  info->filename[MaxTextExtent-1] = '\0';
411
412
 
412
413
  GetExceptionInfo(&exception);
413
414
  profile_image = ReadImage(info, &exception);
414
- DestroyImageInfo(info);
415
+ (void) DestroyImageInfo(info);
415
416
  rm_check_exception(&exception, profile_image, DestroyOnError);
416
- DestroyExceptionInfo(&exception);
417
+ (void) DestroyExceptionInfo(&exception);
417
418
  rm_ensure_result(profile_image);
418
419
 
419
420
  ResetImageProfileIterator(profile_image);
@@ -423,7 +424,7 @@ Image_add_profile(VALUE self, VALUE name)
423
424
  profile = GetImageProfile(profile_image, profile_name);
424
425
  if (profile)
425
426
  {
426
- (void)ProfileImage(image, profile_name, profile->datum, (unsigned long)profile->length, False);
427
+ (void)ProfileImage(image, profile_name, profile->datum, (unsigned long)profile->length, MagickFalse);
427
428
  if (image->exception.severity >= ErrorException)
428
429
  {
429
430
  break;
@@ -432,7 +433,7 @@ Image_add_profile(VALUE self, VALUE name)
432
433
  profile_name = GetNextImageProfile(profile_image);
433
434
  }
434
435
 
435
- DestroyImage(profile_image);
436
+ (void) DestroyImage(profile_image);
436
437
  rm_check_image_exception(image, RetainOnError);
437
438
 
438
439
  #else
@@ -461,9 +462,9 @@ Image_add_profile(VALUE self, VALUE name)
461
462
 
462
463
  GetExceptionInfo(&exception);
463
464
  profile_image = ReadImage(info, &exception);
464
- DestroyImageInfo(info);
465
+ (void) DestroyImageInfo(info);
465
466
  rm_check_exception(&exception, profile_image, DestroyOnError);
466
- DestroyExceptionInfo(&exception);
467
+ (void) DestroyExceptionInfo(&exception);
467
468
  rm_ensure_result(profile_image);
468
469
 
469
470
  /* IPTC NewsPhoto Profile */
@@ -500,7 +501,7 @@ Image_add_profile(VALUE self, VALUE name)
500
501
  }
501
502
 
502
503
  done:
503
- DestroyImage(profile_image);
504
+ (void) DestroyImage(profile_image);
504
505
  rm_check_image_exception(image, RetainOnError);
505
506
 
506
507
  #endif
@@ -530,7 +531,7 @@ Image_affine_transform(VALUE self, VALUE affine)
530
531
  new_image = AffineTransformImage(image, &matrix, &exception);
531
532
  rm_check_exception(&exception, new_image, DestroyOnError);
532
533
 
533
- DestroyExceptionInfo(&exception);
534
+ (void) DestroyExceptionInfo(&exception);
534
535
 
535
536
  rm_ensure_result(new_image);
536
537
 
@@ -558,7 +559,7 @@ Image_aref(VALUE self, VALUE key_arg)
558
559
  return Qnil;
559
560
 
560
561
  case T_SYMBOL:
561
- key = rb_id2name(SYM2ID(key_arg));
562
+ key = rb_id2name((ID)SYM2ID(key_arg));
562
563
  break;
563
564
 
564
565
  default:
@@ -609,7 +610,7 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
609
610
  return self;
610
611
 
611
612
  case T_SYMBOL:
612
- key = rb_id2name(SYM2ID(key_arg));
613
+ key = rb_id2name((ID)SYM2ID(key_arg));
613
614
  break;
614
615
 
615
616
  default:
@@ -675,14 +676,14 @@ crisscross(
675
676
  new_image = (fp)(image, &exception);
676
677
  rm_check_exception(&exception, new_image, DestroyOnError);
677
678
 
678
- DestroyExceptionInfo(&exception);
679
+ (void) DestroyExceptionInfo(&exception);
679
680
 
680
681
  rm_ensure_result(new_image);
681
682
 
682
683
  if (bang)
683
684
  {
684
685
  DATA_PTR(self) = new_image;
685
- DestroyImage(image);
686
+ (void) DestroyImage(image);
686
687
  return self;
687
688
  }
688
689
 
@@ -1142,10 +1143,11 @@ static void get_composite_offsets(
1142
1143
  // NorthWest corner. The arguments must be numbers.
1143
1144
  else
1144
1145
  {
1145
- *x_offset = rb_protect(check_for_long_value, argv[0], &exc);
1146
+ (void)rb_protect(check_for_long_value, argv[0], &exc);
1146
1147
  if (exc)
1147
1148
  {
1148
- rb_raise(rb_eArgError, "expected GravityType, got %s", rb_obj_classname(argv[0]));
1149
+ rb_raise(rb_eArgError, "expected GravityType, got %s"
1150
+ , rb_class2name(CLASS_OF(argv[0])));
1149
1151
  }
1150
1152
  *x_offset = NUM2LONG(argv[0]);
1151
1153
  if (argc > 1)
@@ -1173,7 +1175,7 @@ blend_geometry(
1173
1175
  double src_percent,
1174
1176
  double dst_percent)
1175
1177
  {
1176
- int sz = 0;
1178
+ size_t sz = 0;
1177
1179
  int fw, prec;
1178
1180
 
1179
1181
  if (fabs(src_percent) >= 1000.0 || fabs(dst_percent) >= 1000.0)
@@ -1190,13 +1192,13 @@ blend_geometry(
1190
1192
 
1191
1193
  fw = 4;
1192
1194
  prec = 0;
1193
- if (src_percent != (int)(src_percent))
1195
+ if (src_percent != floor(src_percent))
1194
1196
  {
1195
1197
  prec = 2;
1196
1198
  fw += 3;
1197
1199
  }
1198
1200
 
1199
- sz = sprintf(geometry, "%*.*f", -fw, prec, src_percent);
1201
+ sz = (size_t)sprintf(geometry, "%*.*f", -fw, prec, src_percent);
1200
1202
  assert(sz < geometry_l);
1201
1203
 
1202
1204
  sz = strcspn(geometry, " ");
@@ -1206,14 +1208,14 @@ blend_geometry(
1206
1208
  {
1207
1209
  fw = 4;
1208
1210
  prec = 0;
1209
- if (dst_percent != (int)(dst_percent))
1211
+ if (dst_percent != floor(dst_percent))
1210
1212
  {
1211
1213
  prec = 2;
1212
1214
  fw += 3;
1213
1215
  }
1214
1216
 
1215
1217
 
1216
- sz += sprintf(geometry+sz, "x%*.*f", -fw, prec, dst_percent);
1218
+ sz += (size_t)sprintf(geometry+sz, "x%*.*f", -fw, prec, dst_percent);
1217
1219
  assert(sz < geometry_l);
1218
1220
  sz = strcspn(geometry, " ");
1219
1221
  }
@@ -1240,7 +1242,7 @@ special_composite(
1240
1242
  char geometry[20];
1241
1243
 
1242
1244
  blend_geometry(geometry, sizeof(geometry), image_pct, overlay_pct);
1243
- CloneString(&overlay->geometry, geometry);
1245
+ (void) CloneString(&overlay->geometry, geometry);
1244
1246
 
1245
1247
  new_image = rm_clone_image(image);
1246
1248
  (void) CompositeImage(new_image, op, overlay, x_off, y_off);
@@ -1345,7 +1347,7 @@ Image_blur_channel(int argc, VALUE *argv, VALUE self)
1345
1347
  new_image = BlurImageChannel(image, channels, radius, sigma, &exception);
1346
1348
  rm_check_exception(&exception, new_image, DestroyOnError);
1347
1349
 
1348
- DestroyExceptionInfo(&exception);
1350
+ (void) DestroyExceptionInfo(&exception);
1349
1351
 
1350
1352
  rm_ensure_result(new_image);
1351
1353
 
@@ -1400,7 +1402,7 @@ static VALUE border(
1400
1402
  new_image = BorderImage(image, &rect, &exception);
1401
1403
  rm_check_exception(&exception, new_image, DestroyOnError);
1402
1404
 
1403
- DestroyExceptionInfo(&exception);
1405
+ (void) DestroyExceptionInfo(&exception);
1404
1406
 
1405
1407
  rm_ensure_result(new_image);
1406
1408
 
@@ -1408,7 +1410,7 @@ static VALUE border(
1408
1410
  {
1409
1411
  new_image->border_color = old_border;
1410
1412
  DATA_PTR(self) = new_image;
1411
- DestroyImage(image);
1413
+ (void) DestroyImage(image);
1412
1414
  return self;
1413
1415
  }
1414
1416
 
@@ -1483,7 +1485,7 @@ VALUE Image_bounding_box(VALUE self)
1483
1485
  box = GetImageBoundingBox(image, &exception);
1484
1486
  CHECK_EXCEPTION()
1485
1487
 
1486
- DestroyExceptionInfo(&exception);
1488
+ (void) DestroyExceptionInfo(&exception);
1487
1489
 
1488
1490
  return Rectangle_from_RectangleInfo(&box);
1489
1491
  }
@@ -1515,15 +1517,15 @@ Image_capture(
1515
1517
  switch (argc)
1516
1518
  {
1517
1519
  case 5:
1518
- ximage_info.borders = RTEST(argv[4]);
1520
+ ximage_info.borders = (MagickBooleanType)RTEST(argv[4]);
1519
1521
  case 4:
1520
- ximage_info.screen = RTEST(argv[3]);
1522
+ ximage_info.screen = (MagickBooleanType)RTEST(argv[3]);
1521
1523
  case 3:
1522
- ximage_info.descend = RTEST(argv[2]);
1524
+ ximage_info.descend = (MagickBooleanType)RTEST(argv[2]);
1523
1525
  case 2:
1524
- ximage_info.frame = RTEST(argv[1]);
1526
+ ximage_info.frame = (MagickBooleanType)RTEST(argv[1]);
1525
1527
  case 1:
1526
- ximage_info.silent = RTEST(argv[0]);
1528
+ ximage_info.silent = (MagickBooleanType)RTEST(argv[0]);
1527
1529
  case 0:
1528
1530
  break;
1529
1531
  default:
@@ -1688,7 +1690,7 @@ Image_channel_depth(int argc, VALUE *argv, VALUE self)
1688
1690
  channel_depth = GetImageChannelDepth(image, channels, &exception);
1689
1691
  CHECK_EXCEPTION()
1690
1692
 
1691
- DestroyExceptionInfo(&exception);
1693
+ (void) DestroyExceptionInfo(&exception);
1692
1694
 
1693
1695
  return ULONG2NUM(channel_depth);
1694
1696
  #else
@@ -1732,7 +1734,7 @@ Image_channel_extrema(int argc, VALUE *argv, VALUE self)
1732
1734
  (void) GetImageChannelExtrema(image, channels, &min, &max, &exception);
1733
1735
  CHECK_EXCEPTION()
1734
1736
 
1735
- DestroyExceptionInfo(&exception);
1737
+ (void) DestroyExceptionInfo(&exception);
1736
1738
 
1737
1739
  ary = rb_ary_new2(2);
1738
1740
  rb_ary_store(ary, 0, ULONG2NUM(min));
@@ -1771,7 +1773,7 @@ Image_channel_extrema(int argc, VALUE *argv, VALUE self)
1771
1773
  (void) GetImageStatistics(image, &stats, &exception);
1772
1774
  CHECK_EXCEPTION()
1773
1775
 
1774
- DestroyExceptionInfo(&exception);
1776
+ (void) DestroyExceptionInfo(&exception);
1775
1777
 
1776
1778
  ary = rb_ary_new2(2);
1777
1779
  switch(channel)
@@ -1840,7 +1842,7 @@ Image_channel_mean(int argc, VALUE *argv, VALUE self)
1840
1842
  (void) GetImageChannelMean(image, channels, &mean, &stddev, &exception);
1841
1843
  CHECK_EXCEPTION()
1842
1844
 
1843
- DestroyExceptionInfo(&exception);
1845
+ (void) DestroyExceptionInfo(&exception);
1844
1846
 
1845
1847
  ary = rb_ary_new2(2);
1846
1848
  rb_ary_store(ary, 0, rb_float_new(mean));
@@ -1879,7 +1881,7 @@ Image_channel_mean(int argc, VALUE *argv, VALUE self)
1879
1881
  (void) GetImageStatistics(image, &stats, &exception);
1880
1882
  CHECK_EXCEPTION()
1881
1883
 
1882
- DestroyExceptionInfo(&exception);
1884
+ (void) DestroyExceptionInfo(&exception);
1883
1885
 
1884
1886
  ary = rb_ary_new2(2);
1885
1887
  switch(channel)
@@ -2013,7 +2015,7 @@ Image_clone(VALUE self)
2013
2015
  clone = Image_dup(self);
2014
2016
  if (OBJ_FROZEN(self))
2015
2017
  {
2016
- rb_obj_freeze(clone);
2018
+ (void) rb_obj_freeze(clone);
2017
2019
  }
2018
2020
 
2019
2021
  return clone;
@@ -2041,7 +2043,7 @@ Image_color_histogram(VALUE self)
2041
2043
  histogram = GetColorHistogram(image, &colors, &exception);
2042
2044
  CHECK_EXCEPTION()
2043
2045
 
2044
- DestroyExceptionInfo(&exception);
2046
+ (void) DestroyExceptionInfo(&exception);
2045
2047
 
2046
2048
  hash = rb_hash_new();
2047
2049
  for (x = 0; x < colors; x++)
@@ -2072,7 +2074,7 @@ Image_color_histogram(VALUE self)
2072
2074
  if (image->storage_class != DirectClass)
2073
2075
  {
2074
2076
  dc_copy = rm_clone_image(image);
2075
- SyncImage(dc_copy);
2077
+ (void) SyncImage(dc_copy);
2076
2078
  magick_free(dc_copy->colormap);
2077
2079
  dc_copy->colormap = NULL;
2078
2080
  dc_copy->storage_class = DirectClass;
@@ -2086,33 +2088,33 @@ Image_color_histogram(VALUE self)
2086
2088
  {
2087
2089
  if (dc_copy)
2088
2090
  {
2089
- DestroyImage(dc_copy);
2091
+ (void) DestroyImage(dc_copy);
2090
2092
  }
2091
2093
  rb_raise(rb_eNoMemError, "not enough memory to continue");
2092
2094
  }
2093
2095
  if (exception.severity != UndefinedException)
2094
2096
  {
2095
- RelinquishMagickMemory(histogram);
2097
+ (void) RelinquishMagickMemory(histogram);
2096
2098
  rm_check_exception(&exception, dc_copy, DestroyOnError);
2097
2099
  }
2098
2100
 
2099
- DestroyExceptionInfo(&exception);
2101
+ (void) DestroyExceptionInfo(&exception);
2100
2102
 
2101
2103
  hash = rb_hash_new();
2102
2104
  for (x = 0; x < colors; x++)
2103
2105
  {
2104
2106
  pixel = Pixel_from_PixelPacket(&histogram[x].pixel);
2105
- rb_hash_aset(hash, pixel, ULONG2NUM((unsigned long)histogram[x].count));
2107
+ (void) rb_hash_aset(hash, pixel, ULONG2NUM((unsigned long)histogram[x].count));
2106
2108
  }
2107
2109
 
2108
2110
  /*
2109
2111
  Christy evidently didn't agree with Bob's memory management.
2110
2112
  */
2111
- RelinquishMagickMemory(histogram);
2113
+ (void) RelinquishMagickMemory(histogram);
2112
2114
 
2113
2115
  if (dc_copy)
2114
2116
  {
2115
- DestroyImage(dc_copy);
2117
+ (void) DestroyImage(dc_copy);
2116
2118
  }
2117
2119
 
2118
2120
  return hash;
@@ -2160,10 +2162,10 @@ static VALUE set_profile(VALUE self, const char *name, VALUE profile)
2160
2162
  strncpy(info->magick, m->name, MaxTextExtent);
2161
2163
  info->magick[MaxTextExtent-1] = '\0';
2162
2164
 
2163
- profile_image = BlobToImage(info, profile_blob, profile_length, &exception);
2164
- DestroyImageInfo(info);
2165
+ profile_image = BlobToImage(info, profile_blob, (size_t)profile_length, &exception);
2166
+ (void) DestroyImageInfo(info);
2165
2167
  CHECK_EXCEPTION()
2166
- DestroyExceptionInfo(&exception);
2168
+ (void) DestroyExceptionInfo(&exception);
2167
2169
 
2168
2170
  ResetImageProfileIterator(profile_image);
2169
2171
  profile_name = GetNextImageProfile(profile_image);
@@ -2175,7 +2177,8 @@ static VALUE set_profile(VALUE self, const char *name, VALUE profile)
2175
2177
  if (profile)
2176
2178
  {
2177
2179
  (void)ProfileImage(image, profile_name, profile_data->datum
2178
- , (unsigned long)profile_data->length, False);
2180
+ , (unsigned long)profile_data->length
2181
+ , (MagickBooleanType)False);
2179
2182
  if (image->exception.severity >= ErrorException)
2180
2183
  {
2181
2184
  break;
@@ -2185,7 +2188,7 @@ static VALUE set_profile(VALUE self, const char *name, VALUE profile)
2185
2188
  profile_name = GetNextImageProfile(profile_image);
2186
2189
  }
2187
2190
 
2188
- DestroyImage(profile_image);
2191
+ (void) DestroyImage(profile_image);
2189
2192
  rm_check_image_exception(image, RetainOnError);
2190
2193
 
2191
2194
  #else
@@ -2218,9 +2221,9 @@ static VALUE set_profile(VALUE self, const char *name, VALUE profile)
2218
2221
  info->magick[MaxTextExtent-1] = '\0';
2219
2222
 
2220
2223
  profile_image = BlobToImage(info, profile_blob, profile_length, &exception);
2221
- DestroyImageInfo(info);
2224
+ (void) DestroyImageInfo(info);
2222
2225
  CHECK_EXCEPTION()
2223
- DestroyExceptionInfo(&exception);
2226
+ (void) DestroyExceptionInfo(&exception);
2224
2227
 
2225
2228
  // GraphicsMagick uses "ICM" to refer to the ICC profile.
2226
2229
  if (rm_strcasecmp(name, "ICC") == 0)
@@ -2236,7 +2239,7 @@ static VALUE set_profile(VALUE self, const char *name, VALUE profile)
2236
2239
  (void)SetImageProfile(image, name, profile_data, profile_data_l);
2237
2240
  }
2238
2241
 
2239
- DestroyImage(profile_image);
2242
+ (void) DestroyImage(profile_image);
2240
2243
  rm_check_image_exception(image, RetainOnError);
2241
2244
 
2242
2245
  #endif
@@ -2337,9 +2340,9 @@ Image_color_flood_fill(
2337
2340
 
2338
2341
  x = NUM2LONG(xv);
2339
2342
  y = NUM2LONG(yv);
2340
- if (x > image->columns || y > image->rows)
2343
+ if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
2341
2344
  {
2342
- rb_raise(rb_eArgError, "target out of range. %dx%d given, image is %dx%d"
2345
+ rb_raise(rb_eArgError, "target out of range. %lux%lu given, image is %lux%lu"
2343
2346
  , x, y, image->columns, image->rows);
2344
2347
  }
2345
2348
 
@@ -2362,7 +2365,7 @@ Image_color_flood_fill(
2362
2365
  (void) ColorFloodfillImage(new_image, draw_info, target, x, y, (PaintMethod)fill_method);
2363
2366
  // No need to check for error
2364
2367
 
2365
- DestroyDrawInfo(draw_info);
2368
+ (void) DestroyDrawInfo(draw_info);
2366
2369
  return rm_image_new(new_image);
2367
2370
  }
2368
2371
 
@@ -2412,7 +2415,7 @@ Image_colorize(
2412
2415
  new_image = ColorizeImage(image, opacity, target, &exception);
2413
2416
  rm_check_exception(&exception, new_image, DestroyOnError);
2414
2417
 
2415
- DestroyExceptionInfo(&exception);
2418
+ (void) DestroyExceptionInfo(&exception);
2416
2419
 
2417
2420
  rm_ensure_result(new_image);
2418
2421
 
@@ -2433,7 +2436,7 @@ VALUE
2433
2436
  Image_colormap(int argc, VALUE *argv, VALUE self)
2434
2437
  {
2435
2438
  Image *image;
2436
- unsigned int index;
2439
+ unsigned long index;
2437
2440
  PixelPacket color, new_color;
2438
2441
 
2439
2442
  Data_Get_Struct(self, Image, image);
@@ -2444,7 +2447,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
2444
2447
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
2445
2448
  }
2446
2449
 
2447
- index = NUM2UINT(argv[0]);
2450
+ index = NUM2ULONG(argv[0]);
2448
2451
  if (index > MaxRGB)
2449
2452
  {
2450
2453
  rb_raise(rb_eIndexError, "index out of range");
@@ -2478,7 +2481,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
2478
2481
  if (!image->colormap || index > image->colors-1)
2479
2482
  {
2480
2483
  PixelPacket black = {0};
2481
- unsigned int i;
2484
+ unsigned long i;
2482
2485
 
2483
2486
  if (!image->colormap)
2484
2487
  {
@@ -2629,7 +2632,7 @@ VALUE Image_compare_channel(
2629
2632
  , &exception);
2630
2633
  rm_check_exception(&exception, difference_image, DestroyOnError);
2631
2634
 
2632
- DestroyExceptionInfo(&exception);
2635
+ (void) DestroyExceptionInfo(&exception);
2633
2636
 
2634
2637
  rm_ensure_result(difference_image);
2635
2638
 
@@ -3007,8 +3010,8 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3007
3010
  // and raises TypeError if it can't.
3008
3011
  pixels_arg = rb_Array(pixels_arg);
3009
3012
 
3010
- width = NUM2INT(width_arg);
3011
- height = NUM2INT(height_arg);
3013
+ width = NUM2ULONG(width_arg);
3014
+ height = NUM2ULONG(height_arg);
3012
3015
 
3013
3016
  if (width == 0 || height == 0)
3014
3017
  {
@@ -3017,7 +3020,7 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3017
3020
 
3018
3021
  map = STRING_PTR_LEN(map_arg, map_l);
3019
3022
 
3020
- npixels = width * height * map_l;
3023
+ npixels = (long)(width * height * map_l);
3021
3024
  if (RARRAY(pixels_arg)->len != npixels)
3022
3025
  {
3023
3026
  rb_raise(rb_eArgError, "wrong number of array elements (%d for %d)"
@@ -3081,7 +3084,7 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3081
3084
  rb_raise(rb_eNoMemError, "not enough memory to continue.");
3082
3085
  }
3083
3086
  SetImageExtent(image, width, height);
3084
- SetImageBackgroundColor(image);
3087
+ (void) SetImageBackgroundColor(image);
3085
3088
 
3086
3089
  (void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, (void *)pixels.v);
3087
3090
  rm_check_image_exception(image, DestroyOnError);
@@ -3090,7 +3093,7 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
3090
3093
  rm_check_exception(&exception, image, DestroyOnError);
3091
3094
  #endif
3092
3095
 
3093
- DestroyExceptionInfo(&exception);
3096
+ (void) DestroyExceptionInfo(&exception);
3094
3097
  DestroyConstitute();
3095
3098
 
3096
3099
  xfree((void *)pixels.v);
@@ -3130,63 +3133,54 @@ Image_contrast(int argc, VALUE *argv, VALUE self)
3130
3133
  return rm_image_new(new_image);
3131
3134
  }
3132
3135
 
3136
+
3133
3137
  /*
3134
- Method: Image#contrast_stretch_channel(black_point <, white_point> <, channel...>)
3135
- Purpose: Call ContrastStretchImageChannel
3136
- Notes: If white_point is not specified then it is #pixels-black_point.
3137
- Both black_point and white_point can be specified as Floats
3138
- or as percentages, i.e. "10%"
3138
+ Static: get_black_white_point
3139
+ Purpose: Convert percentages to #pixels. If the white-point (2nd)
3140
+ argument is not supplied set it to #pixels - black-point.
3139
3141
  */
3140
- VALUE
3141
- Image_contrast_stretch_channel(int argc, VALUE *argv, VALUE self)
3142
+ static void get_black_white_point(
3143
+ Image *image,
3144
+ int argc,
3145
+ VALUE *argv,
3146
+ double *black_point,
3147
+ double *white_point)
3142
3148
  {
3143
- #if defined(HAVE_CONTRASTSTRETCHIMAGECHANNEL)
3144
- Image *image, *new_image;
3145
- ChannelType channels;
3146
- double black_point, white_point;
3147
- unsigned long pixels;
3149
+ double pixels;
3148
3150
 
3149
- channels = extract_channels(&argc, argv);
3150
- if (argc > 2)
3151
- {
3152
- raise_ChannelType_error(argv[argc-1]);
3153
- }
3154
-
3155
- Data_Get_Struct(self, Image, image);
3156
-
3157
- pixels = image->columns * image->rows;
3151
+ pixels = (double) (image->columns * image->rows);
3158
3152
 
3159
3153
  switch (argc)
3160
3154
  {
3161
3155
  case 2:
3162
3156
  if (rm_check_num2dbl(argv[0]))
3163
3157
  {
3164
- black_point = NUM2DBL(argv[0]);
3158
+ *black_point = NUM2DBL(argv[0]);
3165
3159
  }
3166
3160
  else
3167
3161
  {
3168
- black_point = pixels * rm_str_to_pct(argv[0]);
3162
+ *black_point = pixels * rm_str_to_pct(argv[0]);
3169
3163
  }
3170
3164
  if (rm_check_num2dbl(argv[1]))
3171
3165
  {
3172
- white_point = NUM2DBL(argv[1]);
3166
+ *white_point = NUM2DBL(argv[1]);
3173
3167
  }
3174
3168
  else
3175
3169
  {
3176
- white_point = pixels * rm_str_to_pct(argv[1]);
3170
+ *white_point = pixels * rm_str_to_pct(argv[1]);
3177
3171
  }
3178
3172
  break;
3179
3173
 
3180
3174
  case 1:
3181
3175
  if (rm_check_num2dbl(argv[0]))
3182
3176
  {
3183
- black_point = NUM2DBL(argv[0]);
3177
+ *black_point = NUM2DBL(argv[0]);
3184
3178
  }
3185
3179
  else
3186
3180
  {
3187
- black_point = pixels * rm_str_to_pct(argv[0]);
3181
+ *black_point = pixels * rm_str_to_pct(argv[0]);
3188
3182
  }
3189
- white_point = (double) pixels - black_point;
3183
+ *white_point = pixels - *black_point;
3190
3184
  break;
3191
3185
 
3192
3186
  default:
@@ -3194,6 +3188,35 @@ Image_contrast_stretch_channel(int argc, VALUE *argv, VALUE self)
3194
3188
  break;
3195
3189
  }
3196
3190
 
3191
+ return;
3192
+ }
3193
+
3194
+
3195
+ /*
3196
+ Method: Image#contrast_stretch_channel(black_point <, white_point> <, channel...>)
3197
+ Purpose: Call ContrastStretchImageChannel
3198
+ Notes: If white_point is not specified then it is #pixels-black_point.
3199
+ Both black_point and white_point can be specified as Floats
3200
+ or as percentages, i.e. "10%"
3201
+ */
3202
+ VALUE
3203
+ Image_contrast_stretch_channel(int argc, VALUE *argv, VALUE self)
3204
+ {
3205
+ #if defined(HAVE_CONTRASTSTRETCHIMAGECHANNEL)
3206
+ Image *image, *new_image;
3207
+ ChannelType channels;
3208
+ double black_point, white_point;
3209
+
3210
+ channels = extract_channels(&argc, argv);
3211
+ if (argc > 2)
3212
+ {
3213
+ raise_ChannelType_error(argv[argc-1]);
3214
+ }
3215
+
3216
+ Data_Get_Struct(self, Image, image);
3217
+
3218
+ get_black_white_point(image, argc, argv, &black_point, &white_point);
3219
+
3197
3220
  new_image = rm_clone_image(image);
3198
3221
 
3199
3222
  (void) ContrastStretchImageChannel(new_image, channels, black_point, white_point);
@@ -3228,14 +3251,14 @@ Image_convolve(
3228
3251
 
3229
3252
  order = NUM2UINT(order_arg);
3230
3253
 
3231
- rm_check_ary_len(kernel_arg, order*order);
3254
+ rm_check_ary_len(kernel_arg, (long)(order*order));
3232
3255
 
3233
3256
  // Convert the kernel array argument to an array of doubles
3234
3257
 
3235
3258
  kernel = (volatile double *)ALLOC_N(double, order*order);
3236
3259
  for (x = 0; x < order*order; x++)
3237
3260
  {
3238
- kernel[x] = NUM2DBL(rb_ary_entry(kernel_arg, x));
3261
+ kernel[x] = NUM2DBL(rb_ary_entry(kernel_arg, (long)x));
3239
3262
  }
3240
3263
 
3241
3264
  GetExceptionInfo(&exception);
@@ -3244,7 +3267,7 @@ Image_convolve(
3244
3267
  xfree((double *)kernel);
3245
3268
  rm_check_exception(&exception, new_image, DestroyOnError);
3246
3269
 
3247
- DestroyExceptionInfo(&exception);
3270
+ (void) DestroyExceptionInfo(&exception);
3248
3271
 
3249
3272
  rm_ensure_result(new_image);
3250
3273
 
@@ -3284,17 +3307,17 @@ Image_convolve_channel(
3284
3307
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc);
3285
3308
  }
3286
3309
 
3287
- order = NUM2INT(argv[0]);
3310
+ order = NUM2UINT(argv[0]);
3288
3311
  ary = argv[1];
3289
3312
 
3290
- rm_check_ary_len(ary, order*order);
3313
+ rm_check_ary_len(ary, (long)(order*order));
3291
3314
 
3292
- kernel = ALLOC_N(double, order*order);
3315
+ kernel = ALLOC_N(double, (long)(order*order));
3293
3316
 
3294
3317
  // Convert the kernel array argument to an array of doubles
3295
3318
  for (x = 0; x < order*order; x++)
3296
3319
  {
3297
- kernel[x] = NUM2DBL(rb_ary_entry(ary, x));
3320
+ kernel[x] = NUM2DBL(rb_ary_entry(ary, (long)x));
3298
3321
  }
3299
3322
 
3300
3323
  GetExceptionInfo(&exception);
@@ -3303,7 +3326,7 @@ Image_convolve_channel(
3303
3326
  xfree((double *)kernel);
3304
3327
  rm_check_exception(&exception, new_image, DestroyOnError);
3305
3328
 
3306
- DestroyExceptionInfo(&exception);
3329
+ (void) DestroyExceptionInfo(&exception);
3307
3330
 
3308
3331
  rm_ensure_result(new_image);
3309
3332
 
@@ -3487,7 +3510,7 @@ Image_depth(VALUE self)
3487
3510
  depth = GetImageDepth(image, &exception);
3488
3511
  CHECK_EXCEPTION()
3489
3512
 
3490
- DestroyExceptionInfo(&exception);
3513
+ (void) DestroyExceptionInfo(&exception);
3491
3514
 
3492
3515
  return INT2FIX(depth);
3493
3516
  }
@@ -3509,7 +3532,7 @@ Image_delete_profile(VALUE self, VALUE name)
3509
3532
  rm_check_frozen(self);
3510
3533
  Data_Get_Struct(self, Image, image);
3511
3534
 
3512
- (void) ProfileImage(image, STRING_PTR(name), NULL, 0, True);
3535
+ (void) ProfileImage(image, STRING_PTR(name), NULL, 0, MagickTrue);
3513
3536
  rm_check_image_exception(image, RetainOnError);
3514
3537
 
3515
3538
  return self;
@@ -3534,7 +3557,7 @@ Image_despeckle(VALUE self)
3534
3557
  new_image = DespeckleImage(image, &exception);
3535
3558
  rm_check_exception(&exception, new_image, DestroyOnError);
3536
3559
 
3537
- DestroyExceptionInfo(&exception);
3560
+ (void) DestroyExceptionInfo(&exception);
3538
3561
 
3539
3562
  rm_ensure_result(new_image);
3540
3563
 
@@ -3583,7 +3606,7 @@ Image_displace(int argc, VALUE *argv, VALUE self)
3583
3606
  {
3584
3607
 
3585
3608
  Image *image, *displacement_map;
3586
- double x_amplitude, y_amplitude;
3609
+ double x_amplitude = 0.0, y_amplitude = 0.0;
3587
3610
  long x_offset = 0L, y_offset = 0L;
3588
3611
 
3589
3612
  Data_Get_Struct(self, Image, image);
@@ -3638,8 +3661,8 @@ VALUE
3638
3661
  Image_dispatch(int argc, VALUE *argv, VALUE self)
3639
3662
  {
3640
3663
  Image *image;
3641
- unsigned long x, y, columns, rows;
3642
- unsigned long n, npixels;
3664
+ long x, y;
3665
+ unsigned long columns, rows, n, npixels;
3643
3666
  volatile VALUE pixels_ary;
3644
3667
  StorageType stg_type = FIX_STG_TYPE;
3645
3668
  char *map;
@@ -3658,8 +3681,8 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
3658
3681
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 5 or 6)", argc);
3659
3682
  }
3660
3683
 
3661
- x = NUM2ULONG(argv[0]);
3662
- y = NUM2ULONG(argv[1]);
3684
+ x = NUM2LONG(argv[0]);
3685
+ y = NUM2LONG(argv[1]);
3663
3686
  columns = NUM2ULONG(argv[2]);
3664
3687
  rows = NUM2ULONG(argv[3]);
3665
3688
  map = STRING_PTR_LEN(argv[4], mapL);
@@ -3694,21 +3717,21 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
3694
3717
 
3695
3718
  CHECK_EXCEPTION()
3696
3719
 
3697
- DestroyExceptionInfo(&exception);
3720
+ (void) DestroyExceptionInfo(&exception);
3698
3721
 
3699
3722
  // Convert the pixel data to the appropriate Ruby type
3700
3723
  if (stg_type == FIX_STG_TYPE)
3701
3724
  {
3702
3725
  for (n = 0; n < npixels; n++)
3703
3726
  {
3704
- rb_ary_push(pixels_ary, UINT2NUM((unsigned int) pixels.i[n]));
3727
+ (void) rb_ary_push(pixels_ary, UINT2NUM((unsigned int) pixels.i[n]));
3705
3728
  }
3706
3729
  }
3707
3730
  else
3708
3731
  {
3709
3732
  for (n = 0; n < npixels; n++)
3710
3733
  {
3711
- rb_ary_push(pixels_ary, rb_float_new((double)pixels.f[n]));
3734
+ (void) rb_ary_push(pixels_ary, rb_float_new((double)pixels.f[n]));
3712
3735
  }
3713
3736
  }
3714
3737
 
@@ -3868,7 +3891,7 @@ Image_dissolve(int argc, VALUE *argv, VALUE self)
3868
3891
  , x_offset, y_offset, DissolveCompositeOp);
3869
3892
 
3870
3893
  #if defined(GRAPHICSMAGICK)
3871
- DestroyImage(overlay);
3894
+ (void) DestroyImage(overlay);
3872
3895
  #endif
3873
3896
 
3874
3897
  return composite;
@@ -3908,7 +3931,7 @@ Image_distortion_channel(int argc, VALUE *argv, VALUE self)
3908
3931
  , metric, &distortion, &exception);
3909
3932
  CHECK_EXCEPTION()
3910
3933
 
3911
- DestroyExceptionInfo(&exception);
3934
+ (void) DestroyExceptionInfo(&exception);
3912
3935
 
3913
3936
  return rb_float_new(distortion);
3914
3937
  #else
@@ -3950,11 +3973,11 @@ Image__dump(VALUE self, VALUE depth)
3950
3973
  blob = ImageToBlob(info, image, &length, &exception);
3951
3974
 
3952
3975
  // Free ImageInfo first - error handling may raise an exception
3953
- DestroyImageInfo(info);
3976
+ (void) DestroyImageInfo(info);
3954
3977
 
3955
3978
  CHECK_EXCEPTION()
3956
3979
 
3957
- DestroyExceptionInfo(&exception);
3980
+ (void) DestroyExceptionInfo(&exception);
3958
3981
 
3959
3982
  if (!blob)
3960
3983
  {
@@ -3969,11 +3992,11 @@ Image__dump(VALUE self, VALUE depth)
3969
3992
  mi.mj = DUMPED_IMAGE_MAJOR_VERS;
3970
3993
  mi.mi = DUMPED_IMAGE_MINOR_VERS;
3971
3994
  strcpy(mi.magick, image->magick);
3972
- mi.len = strlen(mi.magick);
3995
+ mi.len = (unsigned char) min((size_t)UCHAR_MAX, strlen(mi.magick));
3973
3996
 
3974
3997
  // Concatenate the blob onto the header & return the result
3975
- str = rb_str_new((char *)&mi, mi.len+offsetof(DumpedImage,magick));
3976
- return rb_str_cat(str, (char *)blob, length);
3998
+ str = rb_str_new((char *)&mi, (long)(mi.len+offsetof(DumpedImage,magick)));
3999
+ return rb_str_cat(str, (char *)blob, (long)length);
3977
4000
  }
3978
4001
 
3979
4002
  /*
@@ -3988,7 +4011,7 @@ Image_dup(VALUE self)
3988
4011
  dup = Data_Wrap_Struct(CLASS_OF(self), NULL, DestroyImage, NULL);
3989
4012
  if (rb_obj_tainted(self))
3990
4013
  {
3991
- rb_obj_taint(dup);
4014
+ (void) rb_obj_taint(dup);
3992
4015
  }
3993
4016
  return rb_funcall(dup, ID_initialize_copy, 1, self);
3994
4017
  }
@@ -4088,7 +4111,7 @@ Image_edge(int argc, VALUE *argv, VALUE self)
4088
4111
  new_image = EdgeImage(image, radius, &exception);
4089
4112
  rm_check_exception(&exception, new_image, DestroyOnError);
4090
4113
 
4091
- DestroyExceptionInfo(&exception);
4114
+ (void) DestroyExceptionInfo(&exception);
4092
4115
 
4093
4116
  rm_ensure_result(new_image);
4094
4117
 
@@ -4104,7 +4127,7 @@ effect_image(
4104
4127
  VALUE self,
4105
4128
  int argc,
4106
4129
  VALUE *argv,
4107
- effector_t *effector)
4130
+ effector_t effector)
4108
4131
  {
4109
4132
  Image *image, *new_image;
4110
4133
  ExceptionInfo exception;
@@ -4133,7 +4156,7 @@ effect_image(
4133
4156
  new_image = (effector)(image, radius, sigma, &exception);
4134
4157
  rm_check_exception(&exception, new_image, DestroyOnError);
4135
4158
 
4136
- DestroyExceptionInfo(&exception);
4159
+ (void) DestroyExceptionInfo(&exception);
4137
4160
 
4138
4161
  rm_ensure_result(new_image);
4139
4162
 
@@ -4198,7 +4221,7 @@ Image_enhance(VALUE self)
4198
4221
  new_image = EnhanceImage(image, &exception);
4199
4222
  rm_check_exception(&exception, new_image, DestroyOnError);
4200
4223
 
4201
- DestroyExceptionInfo(&exception);
4224
+ (void) DestroyExceptionInfo(&exception);
4202
4225
 
4203
4226
  rm_ensure_result(new_image);
4204
4227
 
@@ -4222,7 +4245,7 @@ Image_equalize(VALUE self)
4222
4245
  (void) EqualizeImage(new_image);
4223
4246
  rm_check_image_exception(new_image, DestroyOnError);
4224
4247
 
4225
- DestroyExceptionInfo(&exception);
4248
+ (void) DestroyExceptionInfo(&exception);
4226
4249
 
4227
4250
  return rm_image_new(new_image);
4228
4251
  }
@@ -4241,7 +4264,7 @@ Image_erase_bang(VALUE self)
4241
4264
  rm_check_frozen(self);
4242
4265
  Data_Get_Struct(self, Image, image);
4243
4266
 
4244
- SetImageBackgroundColor(image);
4267
+ (void) SetImageBackgroundColor(image);
4245
4268
 
4246
4269
  rm_check_image_exception(image, RetainOnError);
4247
4270
 
@@ -4259,7 +4282,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
4259
4282
  Image *image;
4260
4283
  long x_off = 0L, y_off = 0L;
4261
4284
  unsigned long cols, rows;
4262
- unsigned long n, npixels;
4285
+ long n, npixels;
4263
4286
  unsigned int okay;
4264
4287
  char *map = "RGB";
4265
4288
  volatile unsigned int *pixels;
@@ -4290,15 +4313,15 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
4290
4313
  break;
4291
4314
  }
4292
4315
 
4293
- if ( x_off < 0 || x_off > image->columns
4294
- || y_off < 0 || y_off > image->rows
4316
+ if ( x_off < 0 || (unsigned long)x_off > image->columns
4317
+ || y_off < 0 || (unsigned long)y_off > image->rows
4295
4318
  || cols == 0 || rows == 0)
4296
4319
  {
4297
4320
  rb_raise(rb_eArgError, "invalid extract geometry");
4298
4321
  }
4299
4322
 
4300
4323
 
4301
- npixels = cols * rows * strlen(map);
4324
+ npixels = (long)(cols * rows * strlen(map));
4302
4325
  pixels = ALLOC_N(unsigned int, npixels);
4303
4326
  if (!pixels) // app recovered from exception
4304
4327
  {
@@ -4317,13 +4340,13 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
4317
4340
  rm_magick_error("ExportImagePixels failed with no explanation.", NULL);
4318
4341
  }
4319
4342
 
4320
- DestroyExceptionInfo(&exception);
4343
+ (void) DestroyExceptionInfo(&exception);
4321
4344
 
4322
4345
  ary = rb_ary_new2(npixels);
4323
4346
  for (n = 0; n < npixels; n++)
4324
4347
  {
4325
4348
  Quantum p = ScaleLongToQuantum(pixels[n]);
4326
- rb_ary_push(ary, UINT2NUM(p));
4349
+ (void) rb_ary_push(ary, UINT2NUM(p));
4327
4350
  }
4328
4351
 
4329
4352
  xfree((unsigned int *)pixels);
@@ -4382,8 +4405,8 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
4382
4405
  break;
4383
4406
  }
4384
4407
 
4385
- if ( x_off < 0 || x_off > image->columns
4386
- || y_off < 0 || y_off > image->rows
4408
+ if ( x_off < 0 || (unsigned long)x_off > image->columns
4409
+ || y_off < 0 || (unsigned long)y_off > image->rows
4387
4410
  || cols == 0 || rows == 0)
4388
4411
  {
4389
4412
  rb_raise(rb_eArgError, "invalid extract geometry");
@@ -4425,7 +4448,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
4425
4448
  // Allocate a string long enough to hold the exported pixel data.
4426
4449
  // Get a pointer to the buffer.
4427
4450
  string = rb_str_new2("");
4428
- rb_str_resize(string, (long)(sz * npixels));
4451
+ (void) rb_str_resize(string, (long)(sz * npixels));
4429
4452
  str = STRING_PTR(string);
4430
4453
 
4431
4454
  GetExceptionInfo(&exception);
@@ -4434,14 +4457,14 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
4434
4457
  if (!okay)
4435
4458
  {
4436
4459
  // Let GC have the string buffer.
4437
- rb_str_resize(string, 0);
4460
+ (void) rb_str_resize(string, 0);
4438
4461
  CHECK_EXCEPTION()
4439
4462
 
4440
4463
  // Should never get here...
4441
4464
  rm_magick_error("ExportImagePixels failed with no explanation.", NULL);
4442
4465
  }
4443
4466
 
4444
- DestroyExceptionInfo(&exception);
4467
+ (void) DestroyExceptionInfo(&exception);
4445
4468
 
4446
4469
  return string;
4447
4470
 
@@ -4561,7 +4584,7 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
4561
4584
  GetExceptionInfo(&exception);
4562
4585
  okay = IsImageSimilar(image, target, &x, &y, &exception);
4563
4586
  CHECK_EXCEPTION();
4564
- DestroyExceptionInfo(&exception);
4587
+ (void) DestroyExceptionInfo(&exception);
4565
4588
 
4566
4589
  if (!okay)
4567
4590
  {
@@ -4602,14 +4625,14 @@ flipflop(int bang, VALUE self, flipper_t flipflopper)
4602
4625
  new_image = (flipflopper)(image, &exception);
4603
4626
  rm_check_exception(&exception, new_image, DestroyOnError);
4604
4627
 
4605
- DestroyExceptionInfo(&exception);
4628
+ (void) DestroyExceptionInfo(&exception);
4606
4629
 
4607
4630
  rm_ensure_result(new_image);
4608
4631
 
4609
4632
  if (bang)
4610
4633
  {
4611
4634
  DATA_PTR(self) = new_image;
4612
- DestroyImage(image);
4635
+ (void) DestroyImage(image);
4613
4636
  return self;
4614
4637
  }
4615
4638
 
@@ -4669,7 +4692,7 @@ Image_format(VALUE self)
4669
4692
  // Deliberately ignore the exception info!
4670
4693
  GetExceptionInfo(&exception);
4671
4694
  magick_info = GetMagickInfo(image->magick, &exception);
4672
- DestroyExceptionInfo(&exception);
4695
+ (void) DestroyExceptionInfo(&exception);
4673
4696
  return magick_info ? rb_str_new2(magick_info->name) : Qnil;
4674
4697
  }
4675
4698
 
@@ -4698,7 +4721,7 @@ Image_format_eq(VALUE self, VALUE magick)
4698
4721
  m = GetMagickInfo(mgk, &exception);
4699
4722
  CHECK_EXCEPTION()
4700
4723
 
4701
- DestroyExceptionInfo(&exception);
4724
+ (void) DestroyExceptionInfo(&exception);
4702
4725
 
4703
4726
  if (!m)
4704
4727
  {
@@ -4782,7 +4805,7 @@ Image_frame(int argc, VALUE *argv, VALUE self)
4782
4805
  new_image = FrameImage(image, &frame_info, &exception);
4783
4806
  rm_check_exception(&exception, new_image, DestroyOnError);
4784
4807
 
4785
- DestroyExceptionInfo(&exception);
4808
+ (void) DestroyExceptionInfo(&exception);
4786
4809
 
4787
4810
  rm_ensure_result(new_image);
4788
4811
 
@@ -4814,7 +4837,7 @@ Image_from_blob(VALUE class, VALUE blob_arg)
4814
4837
  images = BlobToImage(info, blob, (size_t)length, &exception);
4815
4838
  rm_check_exception(&exception, images, DestroyOnError);
4816
4839
 
4817
- DestroyExceptionInfo(&exception);
4840
+ (void) DestroyExceptionInfo(&exception);
4818
4841
 
4819
4842
  rm_ensure_result(images);
4820
4843
 
@@ -4982,7 +5005,7 @@ Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self)
4982
5005
  new_image = GaussianBlurImageChannel(image, channels, radius, sigma, &exception);
4983
5006
  rm_check_exception(&exception, new_image, DestroyOnError);
4984
5007
 
4985
- DestroyExceptionInfo(&exception);
5008
+ (void) DestroyExceptionInfo(&exception);
4986
5009
 
4987
5010
  return rm_image_new(new_image);
4988
5011
 
@@ -5050,17 +5073,18 @@ Image_get_pixels(
5050
5073
  Image *image;
5051
5074
  PixelPacket *pixels;
5052
5075
  ExceptionInfo exception;
5053
- long x, y, columns, rows;
5076
+ long x, y;
5077
+ unsigned long columns, rows;
5054
5078
  long size, n;
5055
5079
  VALUE pixel_ary;
5056
5080
 
5057
5081
  Data_Get_Struct(self, Image, image);
5058
- x = NUM2LONG(x_arg);
5059
- y = NUM2LONG(y_arg);
5060
- columns = NUM2LONG(cols_arg);
5061
- rows = NUM2LONG(rows_arg);
5082
+ x = NUM2LONG(x_arg);
5083
+ y = NUM2LONG(y_arg);
5084
+ columns = NUM2ULONG(cols_arg);
5085
+ rows = NUM2ULONG(rows_arg);
5062
5086
 
5063
- if (x+columns > image->columns || y+rows > image->rows || columns < 0 || rows < 0)
5087
+ if ((x+columns) > image->columns || (y+rows) > image->rows || columns < 0 || rows < 0)
5064
5088
  {
5065
5089
  rb_raise(rb_eRangeError, "geometry (%lux%lu%+ld%+ld) exceeds image bounds"
5066
5090
  , columns, rows, x, y);
@@ -5072,7 +5096,7 @@ Image_get_pixels(
5072
5096
  pixels = (PixelPacket *)AcquireImagePixels(image, x, y, columns, rows, &exception);
5073
5097
  CHECK_EXCEPTION()
5074
5098
 
5075
- DestroyExceptionInfo(&exception);
5099
+ (void) DestroyExceptionInfo(&exception);
5076
5100
 
5077
5101
  // If the function failed, return a 0-length array.
5078
5102
  if (!pixels)
@@ -5081,7 +5105,7 @@ Image_get_pixels(
5081
5105
  }
5082
5106
 
5083
5107
  // Allocate an array big enough to contain the PixelPackets.
5084
- size = columns*rows;
5108
+ size = (long)(columns * rows);
5085
5109
  pixel_ary = rb_ary_new2(size);
5086
5110
 
5087
5111
  // Convert the PixelPackets to Magick::Pixel objects
@@ -5114,7 +5138,7 @@ Image_get_one_pixel(VALUE self, VALUE x, VALUE y)
5114
5138
  pixel = AcquireOnePixel(image, NUM2LONG(x), NUM2LONG(y), &exception);
5115
5139
  CHECK_EXCEPTION()
5116
5140
 
5117
- DestroyExceptionInfo(&exception);
5141
+ (void) DestroyExceptionInfo(&exception);
5118
5142
 
5119
5143
  return Pixel_from_PixelPacket(&pixel);
5120
5144
  }
@@ -5138,7 +5162,7 @@ Image_gray_q(VALUE self)
5138
5162
  r = IsGrayImage(image, &exception);
5139
5163
  CHECK_EXCEPTION()
5140
5164
 
5141
- DestroyExceptionInfo(&exception);
5165
+ (void) DestroyExceptionInfo(&exception);
5142
5166
 
5143
5167
  return r ? Qtrue : Qfalse;
5144
5168
  }
@@ -5209,7 +5233,7 @@ Image_implode(int argc, VALUE *argv, VALUE self)
5209
5233
 
5210
5234
  new_image = ImplodeImage(image, amount, &exception);
5211
5235
  rm_check_exception(&exception, new_image, DestroyOnError);
5212
- DestroyExceptionInfo(&exception);
5236
+ (void) DestroyExceptionInfo(&exception);
5213
5237
 
5214
5238
  rm_ensure_result(new_image);
5215
5239
 
@@ -5229,8 +5253,8 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
5229
5253
  Image *image;
5230
5254
  long x_off, y_off;
5231
5255
  unsigned long cols, rows;
5232
- unsigned long npixels;
5233
- long n, buffer_l;
5256
+ unsigned long n, npixels;
5257
+ long buffer_l;
5234
5258
  char *map;
5235
5259
  volatile VALUE pixel_arg, pixel_ary;
5236
5260
  StorageType stg_type = CharPixel;
@@ -5312,7 +5336,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
5312
5336
  {
5313
5337
  rb_raise(rb_eArgError, "pixel buffer must contain an exact multiple of the map length");
5314
5338
  }
5315
- if (buffer_l / type_sz < npixels)
5339
+ if ((unsigned long)(buffer_l / type_sz) < npixels)
5316
5340
  {
5317
5341
  rb_raise(rb_eArgError, "pixel buffer too small (need %lu channel values, got %ld)"
5318
5342
  , npixels, buffer_l/type_sz);
@@ -5330,7 +5354,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
5330
5354
  {
5331
5355
  rb_raise(rb_eArgError, "pixel array must contain an exact multiple of the map length");
5332
5356
  }
5333
- if (RARRAY(pixel_ary)->len < npixels)
5357
+ if ((unsigned long)RARRAY(pixel_ary)->len < npixels)
5334
5358
  {
5335
5359
  rb_raise(rb_eArgError, "pixel array too small (need %lu elements, got %ld)"
5336
5360
  , npixels, RARRAY(pixel_ary)->len);
@@ -5356,7 +5380,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
5356
5380
  for (n = 0; n < npixels; n++)
5357
5381
  {
5358
5382
  volatile VALUE p = rb_ary_entry(pixel_ary, n);
5359
- long q = ScaleQuantumToLong(NUM2LONG(p));
5383
+ unsigned long q = ScaleQuantumToLong((Quantum)NUM2LONG(p));
5360
5384
  pixels[n] = (int) q;
5361
5385
  }
5362
5386
  buffer = (void *) pixels;
@@ -5449,13 +5473,13 @@ Image_inspect(VALUE self)
5449
5473
  x += sprintf(buffer+x, "DirectClass ");
5450
5474
  if (image->total_colors != 0)
5451
5475
  {
5452
- if (image->total_colors >= (1 << 24))
5476
+ if (image->total_colors >= (unsigned long)(1 << 24))
5453
5477
  {
5454
5478
  x += sprintf(buffer+x, "%lumc ", image->total_colors/1024/1024);
5455
5479
  }
5456
5480
  else
5457
5481
  {
5458
- if (image->total_colors >= (1 << 16))
5482
+ if (image->total_colors >= (unsigned long)(1 << 16))
5459
5483
  {
5460
5484
  x += sprintf(buffer+x, "%lukc ", image->total_colors/1024);
5461
5485
  }
@@ -5472,11 +5496,11 @@ Image_inspect(VALUE self)
5472
5496
  // building with GM. GM defines that field as an unsigned int.
5473
5497
  if (image->total_colors <= image->colors)
5474
5498
  {
5475
- x += sprintf(buffer+x, "PseudoClass %luc ", (long) image->colors);
5499
+ x += sprintf(buffer+x, "PseudoClass %ldc ", (long) image->colors);
5476
5500
  }
5477
5501
  else
5478
5502
  {
5479
- x += sprintf(buffer+x, "PseudoClass %lu=>%luc ", image->total_colors
5503
+ x += sprintf(buffer+x, "PseudoClass %lu=>%ldc ", image->total_colors
5480
5504
  , (long)image->colors);
5481
5505
  if (image->error.mean_error_per_pixel != 0.0)
5482
5506
  {
@@ -5493,7 +5517,7 @@ Image_inspect(VALUE self)
5493
5517
  #if defined(HAVE_OLD_GETIMAGEQUANTUMDEPTH)
5494
5518
  quantum_depth = GetImageQuantumDepth(image);
5495
5519
  #else
5496
- quantum_depth = GetImageQuantumDepth(image, True);
5520
+ quantum_depth = GetImageQuantumDepth(image, MagickTrue);
5497
5521
  #endif
5498
5522
  #else
5499
5523
  quantum_depth = image->depth;
@@ -5711,6 +5735,35 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
5711
5735
  return rm_image_new(new_image);
5712
5736
  }
5713
5737
 
5738
+ /*
5739
+ Method: Image_linear_stretch(black_point <, white_point>)
5740
+ Purpose: Call LinearStretchImage
5741
+ Notes: The default for white_point is #pixels-black_point.
5742
+ See Image_contrast_stretch_channel.
5743
+ */
5744
+ VALUE
5745
+ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
5746
+ {
5747
+ #if defined(HAVE_LINEARSTRETCHIMAGE)
5748
+ Image *image, *new_image;
5749
+ double black_point, white_point;
5750
+
5751
+ Data_Get_Struct(self, Image, image);
5752
+
5753
+ get_black_white_point(image, argc, argv, &black_point, &white_point);
5754
+
5755
+ new_image = rm_clone_image(image);
5756
+
5757
+ (void) LinearStretchImage(new_image, black_point, white_point);
5758
+ rm_check_image_exception(new_image, DestroyOnError);
5759
+
5760
+ return rm_image_new(new_image);
5761
+ #else
5762
+ rm_not_implemented();
5763
+ return (VALUE)0;
5764
+ #endif
5765
+ }
5766
+
5714
5767
  /*
5715
5768
  Method: Image._load
5716
5769
  Purpose: implement marshalling
@@ -5772,11 +5825,11 @@ Image__load(VALUE class, VALUE str)
5772
5825
  blob += offsetof(DumpedImage,magick) + mi.len;
5773
5826
  length -= offsetof(DumpedImage,magick) + mi.len;
5774
5827
  image = BlobToImage(info, blob, (size_t) length, &exception);
5775
- DestroyImageInfo(info);
5828
+ (void) DestroyImageInfo(info);
5776
5829
 
5777
5830
  rm_check_exception(&exception, image, DestroyOnError);
5778
5831
 
5779
- DestroyExceptionInfo(&exception);
5832
+ (void) DestroyExceptionInfo(&exception);
5780
5833
 
5781
5834
  rm_ensure_result(image);
5782
5835
 
@@ -5805,14 +5858,14 @@ magnify(int bang, VALUE self, magnifier_t magnifier)
5805
5858
  new_image = (magnifier)(image, &exception);
5806
5859
  rm_check_exception(&exception, new_image, DestroyOnError);
5807
5860
 
5808
- DestroyExceptionInfo(&exception);
5861
+ (void) DestroyExceptionInfo(&exception);
5809
5862
 
5810
5863
  rm_ensure_result(new_image);
5811
5864
 
5812
5865
  if (bang)
5813
5866
  {
5814
5867
  DATA_PTR(self) = new_image;
5815
- DestroyImage(image);
5868
+ (void) DestroyImage(image);
5816
5869
  return self;
5817
5870
  }
5818
5871
 
@@ -5897,7 +5950,7 @@ Image_mask(VALUE self)
5897
5950
  mask = image->clip_mask;
5898
5951
  #endif
5899
5952
 
5900
- DestroyExceptionInfo(&exception);
5953
+ (void) DestroyExceptionInfo(&exception);
5901
5954
 
5902
5955
  return mask ? rm_image_new(mask) : Qnil;
5903
5956
  }
@@ -5935,9 +5988,9 @@ Image_mask_eq(VALUE self, VALUE mask)
5935
5988
  resized_image = ResizeImage(clip_mask, image->columns, image->rows
5936
5989
  , UndefinedFilter, 0.0, &exception);
5937
5990
  rm_check_exception(&exception, resized_image, DestroyOnError);
5938
- DestroyExceptionInfo(&exception);
5991
+ (void) DestroyExceptionInfo(&exception);
5939
5992
  rm_ensure_result(resized_image);
5940
- (void) DestroyImage(clip_mask);
5993
+ (void) (void) DestroyImage(clip_mask);
5941
5994
  clip_mask = resized_image;
5942
5995
  }
5943
5996
 
@@ -5951,7 +6004,7 @@ Image_mask_eq(VALUE self, VALUE mask)
5951
6004
  }
5952
6005
  for (x = 0; x < (long) clip_mask->columns; x++)
5953
6006
  {
5954
- if (clip_mask->matte == False)
6007
+ if (clip_mask->matte == MagickFalse)
5955
6008
  {
5956
6009
  q->opacity = PIXEL_INTENSITY(q);
5957
6010
  }
@@ -5960,34 +6013,34 @@ Image_mask_eq(VALUE self, VALUE mask)
5960
6013
  q->blue = q->opacity;
5961
6014
  q += 1;
5962
6015
  }
5963
- if (SyncImagePixels(clip_mask) == False)
6016
+ if (SyncImagePixels(clip_mask) == (MagickBooleanType)False)
5964
6017
  {
5965
- (void) DestroyImage(clip_mask);
6018
+ (void) (void) DestroyImage(clip_mask);
5966
6019
  rm_magick_error("SyncImagePixels failed", NULL);
5967
6020
  }
5968
6021
  }
5969
6022
 
5970
6023
  #if defined(HAVE_SETIMAGESTORAGECLASS)
5971
- if (SetImageStorageClass(clip_mask, DirectClass) == False)
6024
+ if (SetImageStorageClass(clip_mask, DirectClass) == (MagickBooleanType)False)
5972
6025
  {
5973
- (void) DestroyImage(clip_mask);
6026
+ (void) (void) DestroyImage(clip_mask);
5974
6027
  rm_magick_error("SetImageStorageClass failed", NULL);
5975
6028
  }
5976
6029
  #else
5977
6030
  if (clip_mask->storage_class == PseudoClass)
5978
6031
  {
5979
- SyncImage(image);
6032
+ SyncImage(clip_mask);
5980
6033
  clip_mask->storage_class = DirectClass;
5981
6034
  }
5982
6035
  #endif
5983
6036
 
5984
- clip_mask->matte = True;
6037
+ clip_mask->matte = MagickTrue;
5985
6038
 
5986
6039
  // SetImageClipMask clones the clip_mask image. We can
5987
6040
  // destroy our copy after SetImageClipMask is done with it.
5988
6041
 
5989
6042
  (void) SetImageClipMask(image, clip_mask);
5990
- (void) DestroyImage(clip_mask);
6043
+ (void) (void) DestroyImage(clip_mask);
5991
6044
  }
5992
6045
  else
5993
6046
  {
@@ -6043,7 +6096,7 @@ Image_matte_flood_fill(
6043
6096
  {
6044
6097
  Image *image, *new_image;
6045
6098
  PixelPacket target;
6046
- unsigned int op;
6099
+ unsigned long op;
6047
6100
  long x, y;
6048
6101
  PaintMethod pm;
6049
6102
 
@@ -6051,10 +6104,10 @@ Image_matte_flood_fill(
6051
6104
 
6052
6105
  Color_to_PixelPacket(&target, color);
6053
6106
 
6054
- op = NUM2UINT(opacity);
6107
+ op = NUM2ULONG(opacity);
6055
6108
  if (op > MaxRGB)
6056
6109
  {
6057
- rb_raise(rb_eArgError, "opacity (%d) exceeds MaxRGB", op);
6110
+ rb_raise(rb_eArgError, "opacity (%lu) exceeds MaxRGB", op);
6058
6111
  }
6059
6112
 
6060
6113
  VALUE_TO_ENUM(method, pm, PaintMethod);
@@ -6065,16 +6118,16 @@ Image_matte_flood_fill(
6065
6118
  }
6066
6119
  x = NUM2LONG(x_obj);
6067
6120
  y = NUM2LONG(y_obj);
6068
- if (x > image->columns || y > image->rows)
6121
+ if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
6069
6122
  {
6070
- rb_raise(rb_eArgError, "target out of range. %dx%d given, image is %dx%d"
6123
+ rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %lux%lu"
6071
6124
  , x, y, image->columns, image->rows);
6072
6125
  }
6073
6126
 
6074
6127
 
6075
6128
  new_image = rm_clone_image(image);
6076
6129
 
6077
- (void) MatteFloodfillImage(new_image, target, op, x, y, pm);
6130
+ (void) MatteFloodfillImage(new_image, target, (Quantum)op, x, y, pm);
6078
6131
  rm_check_image_exception(new_image, DestroyOnError);
6079
6132
 
6080
6133
  return rm_image_new(new_image);
@@ -6111,7 +6164,7 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
6111
6164
  new_image = MedianFilterImage(image, radius, &exception);
6112
6165
  rm_check_exception(&exception, new_image, DestroyOnError);
6113
6166
 
6114
- DestroyExceptionInfo(&exception);
6167
+ (void) DestroyExceptionInfo(&exception);
6115
6168
 
6116
6169
  rm_ensure_result(new_image);
6117
6170
 
@@ -6267,7 +6320,7 @@ Image_monochrome_q(VALUE self)
6267
6320
  r = IsMonochromeImage(image, &exception);
6268
6321
  CHECK_EXCEPTION()
6269
6322
 
6270
- DestroyExceptionInfo(&exception);
6323
+ (void) DestroyExceptionInfo(&exception);
6271
6324
 
6272
6325
  return r ? Qtrue : Qfalse;
6273
6326
  }
@@ -6302,7 +6355,7 @@ Image_montage_eq(
6302
6355
 
6303
6356
 
6304
6357
  /*
6305
- Static: motion_blur(int argc, VALUE *argv, VALUE self, magick_api)
6358
+ Static: motion_blur(int argc, VALUE *argv, VALUE self, Image *fp)
6306
6359
  Purpose: called from Image_motion_blur and Image_sketch
6307
6360
  */
6308
6361
  static VALUE
@@ -6344,7 +6397,7 @@ motion_blur(
6344
6397
  new_image = (fp)(image, radius, sigma, angle, &exception);
6345
6398
  rm_check_exception(&exception, new_image, DestroyOnError);
6346
6399
 
6347
- DestroyExceptionInfo(&exception);
6400
+ (void) DestroyExceptionInfo(&exception);
6348
6401
 
6349
6402
  rm_ensure_result(new_image);
6350
6403
 
@@ -6586,7 +6639,7 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
6586
6639
  // specifying it when creating the Info parm block.
6587
6640
  if (!fill)
6588
6641
  {
6589
- SetImageBackgroundColor(image);
6642
+ (void) SetImageBackgroundColor(image);
6590
6643
  }
6591
6644
  // fillobj.fill(self)
6592
6645
  else
@@ -6688,7 +6741,7 @@ Image_number_colors(VALUE self)
6688
6741
  n = (unsigned long) GetNumberColors(image, NULL, &exception);
6689
6742
  CHECK_EXCEPTION()
6690
6743
 
6691
- DestroyExceptionInfo(&exception);
6744
+ (void) DestroyExceptionInfo(&exception);
6692
6745
 
6693
6746
  return ULONG2NUM(n);
6694
6747
  }
@@ -6722,7 +6775,7 @@ Image_oil_paint(int argc, VALUE *argv, VALUE self)
6722
6775
  new_image = OilPaintImage(image, radius, &exception);
6723
6776
  rm_check_exception(&exception, new_image, DestroyOnError);
6724
6777
 
6725
- DestroyExceptionInfo(&exception);
6778
+ (void) DestroyExceptionInfo(&exception);
6726
6779
 
6727
6780
  rm_ensure_result(new_image);
6728
6781
 
@@ -6776,15 +6829,17 @@ Image_opaque_q(VALUE self)
6776
6829
  r = IsOpaqueImage(image, &exception);
6777
6830
  CHECK_EXCEPTION()
6778
6831
 
6779
- DestroyExceptionInfo(&exception);
6832
+ (void) DestroyExceptionInfo(&exception);
6780
6833
 
6781
6834
  return r ? Qtrue : Qfalse;
6782
6835
  }
6783
6836
 
6784
6837
  /*
6785
- Method: Image#ordered_dither(order=2)
6838
+ Method: Image#ordered_dither(threshold_map='2x2')
6786
6839
  Purpose: perform ordered dither on image
6787
6840
  Notes: order must be 2, 3, or 4
6841
+ (6.3.0) order can be any of the threshold strings listed
6842
+ by "convert -list Thresholds" but the default is still "2x2".
6788
6843
  I don't call OrderedDitherImages anymore. Sometime after
6789
6844
  IM 6.0.0 it quit working. IM and GM use the routines I use
6790
6845
  below to implement the "ordered-dither" option.
@@ -6794,7 +6849,7 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
6794
6849
  {
6795
6850
  Image *image, *new_image;
6796
6851
  int order;
6797
- const char *thresholds = "2x2";
6852
+ const char *threshold_map = "2x2";
6798
6853
  ExceptionInfo exception;
6799
6854
 
6800
6855
  if (argc > 1)
@@ -6803,18 +6858,25 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
6803
6858
  }
6804
6859
  if (argc == 1)
6805
6860
  {
6806
- order = NUM2INT(argv[0]);
6807
- if (order == 3)
6808
- {
6809
- thresholds = "3x3";
6810
- }
6811
- else if (order == 4)
6861
+ if (TYPE(argv[0]) == T_STRING)
6812
6862
  {
6813
- thresholds = "4x4";
6863
+ threshold_map = STRING_PTR(argv[0]);
6814
6864
  }
6815
- else if (order != 2)
6865
+ else
6816
6866
  {
6817
- rb_raise(rb_eArgError, "order must be 2, 3, or 4 (%d given)", order);
6867
+ order = NUM2INT(argv[0]);
6868
+ if (order == 3)
6869
+ {
6870
+ threshold_map = "3x3";
6871
+ }
6872
+ else if (order == 4)
6873
+ {
6874
+ threshold_map = "4x4";
6875
+ }
6876
+ else if (order != 2)
6877
+ {
6878
+ rb_raise(rb_eArgError, "order must be 2, 3, or 4 (%d given)", order);
6879
+ }
6818
6880
  }
6819
6881
  }
6820
6882
 
@@ -6825,14 +6887,19 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
6825
6887
 
6826
6888
  GetExceptionInfo(&exception);
6827
6889
 
6828
- #if defined(HAVE_RANDOMTHRESHOLDIMAGECHANNEL)
6829
- (void) RandomThresholdImageChannel(new_image, AllChannels, thresholds, &exception);
6890
+ #if defined(HAVE_ORDEREDPOSTERIZEIMAGECHANNEL)
6891
+ // ImageMagick >= 6.3.0
6892
+ (void) OrderedPosterizeImage(new_image, threshold_map, &exception);
6893
+ #elif defined(HAVE_RANDOMTHRESHOLDIMAGECHANNEL)
6894
+ // ImageMagick 6.0.0 thru 6.3.0
6895
+ (void) RandomThresholdImageChannel(new_image, AllChannels, threshold_map, &exception);
6830
6896
  #else
6831
- (void) RandomChannelThresholdImage(new_image, "all", thresholds, &exception);
6897
+ // GraphicsMagick
6898
+ (void) RandomChannelThresholdImage(new_image, "all", threshold_map, &exception);
6832
6899
  #endif
6833
6900
  rm_check_exception(&exception, new_image, DestroyOnError);
6834
6901
 
6835
- DestroyExceptionInfo(&exception);
6902
+ (void) DestroyExceptionInfo(&exception);
6836
6903
 
6837
6904
  return rm_image_new(new_image);
6838
6905
  }
@@ -6926,7 +6993,7 @@ Image_palette_q(VALUE self)
6926
6993
  r = IsPaletteImage(image, &exception);
6927
6994
  CHECK_EXCEPTION()
6928
6995
 
6929
- DestroyExceptionInfo(&exception);
6996
+ (void) DestroyExceptionInfo(&exception);
6930
6997
 
6931
6998
  return r ? Qtrue : Qfalse;
6932
6999
  }
@@ -6991,7 +7058,7 @@ Image_pixel_color(
6991
7058
  old_color = *AcquireImagePixels(image, x, y, 1, 1, &exception);
6992
7059
  CHECK_EXCEPTION()
6993
7060
 
6994
- DestroyExceptionInfo(&exception);
7061
+ (void) DestroyExceptionInfo(&exception);
6995
7062
 
6996
7063
  // PseudoClass
6997
7064
  if (image->storage_class == PseudoClass)
@@ -7008,7 +7075,7 @@ Image_pixel_color(
7008
7075
 
7009
7076
  // ImageMagick segfaults if the pixel location is out of bounds.
7010
7077
  // Do what IM does and return the background color.
7011
- if (x < 0 || y < 0 || x >= image->columns || y >= image->rows)
7078
+ if (x < 0 || y < 0 || (unsigned long)x >= image->columns || (unsigned long)y >= image->rows)
7012
7079
  {
7013
7080
  return Pixel_from_PixelPacket(&image->background_color);
7014
7081
  }
@@ -7017,7 +7084,7 @@ Image_pixel_color(
7017
7084
  // Convert to DirectClass
7018
7085
  if (image->storage_class == PseudoClass)
7019
7086
  {
7020
- SyncImage(image);
7087
+ (void) SyncImage(image);
7021
7088
  magick_free(image->colormap);
7022
7089
  image->colormap = NULL;
7023
7090
  image->storage_class = DirectClass;
@@ -7126,6 +7193,64 @@ Image_plasma(
7126
7193
  #endif
7127
7194
 
7128
7195
 
7196
+ /*
7197
+ Method: Image#polaroid([angle=-5])
7198
+ Purpose: Call PolaroidImage
7199
+ Notes: Accepts an options block to get Draw attributes for drawing
7200
+ the label. Specify self.border_color to set a non-default
7201
+ border color.
7202
+ */
7203
+ VALUE
7204
+ Image_polaroid(int argc, VALUE *argv, VALUE self)
7205
+ {
7206
+ #if defined(HAVE_POLAROIDIMAGE)
7207
+ Image *image, *clone, *new_image;
7208
+ volatile VALUE options;
7209
+ double angle = -5.0;
7210
+ Draw *draw;
7211
+ ExceptionInfo exception;
7212
+
7213
+ GetExceptionInfo(&exception);
7214
+
7215
+ Data_Get_Struct(self, Image, image);
7216
+
7217
+ switch (argc)
7218
+ {
7219
+ case 1:
7220
+ angle = NUM2DBL(argv[0]);
7221
+ case 0:
7222
+ break;
7223
+ default:
7224
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
7225
+ break;
7226
+ }
7227
+
7228
+ options = rm_polaroid_new();
7229
+ Data_Get_Struct(options, Draw, draw);
7230
+
7231
+ clone = CloneImage(image, 0, 0, MagickTrue, &exception);
7232
+ rm_check_exception(&exception, clone, DestroyOnError);
7233
+
7234
+ clone->background_color = draw->shadow_color;
7235
+
7236
+ new_image = PolaroidImage(clone, draw->info, angle, &exception);
7237
+
7238
+ rm_check_exception(&exception, clone, DestroyOnError);
7239
+ (void) DestroyImage(clone);
7240
+ (void) DestroyExceptionInfo(&exception);
7241
+
7242
+ rm_ensure_result(new_image);
7243
+
7244
+ return rm_image_new(new_image);
7245
+ #else
7246
+ rm_not_implemented();
7247
+ return (VALUE)0;
7248
+ #endif
7249
+ }
7250
+
7251
+
7252
+
7253
+
7129
7254
  /*
7130
7255
  Method: posterize
7131
7256
  Purpose: call PosterizeImage
@@ -7136,16 +7261,16 @@ Image_posterize(int argc, VALUE *argv, VALUE self)
7136
7261
  {
7137
7262
  #if defined(HAVE_POSTERIZEIMAGE)
7138
7263
  Image *image, *new_image;
7139
- MagickBooleanType dither = False;
7264
+ MagickBooleanType dither = MagickFalse;
7140
7265
  unsigned long levels = 4;
7141
7266
 
7142
7267
  switch(argc)
7143
7268
  {
7144
7269
  case 2:
7145
- dither = RTEST(argv[1]);
7270
+ dither = (MagickBooleanType) RTEST(argv[1]);
7146
7271
  /* fall through */
7147
7272
  case 1:
7148
- levels = NUM2INT(argv[0]);
7273
+ levels = NUM2ULONG(argv[0]);
7149
7274
  /* fall through */
7150
7275
  case 0:
7151
7276
  break;
@@ -7187,7 +7312,7 @@ Image_preview(VALUE self, VALUE preview)
7187
7312
  new_image = PreviewImage(image, preview_type, &exception);
7188
7313
  rm_check_exception(&exception, new_image, DestroyOnError);
7189
7314
 
7190
- DestroyExceptionInfo(&exception);
7315
+ (void) DestroyExceptionInfo(&exception);
7191
7316
 
7192
7317
  rm_ensure_result(new_image);
7193
7318
 
@@ -7343,7 +7468,7 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
7343
7468
  (void) QuantumOperatorImage(image, channel, qop, rvalue, &exception);
7344
7469
  CHECK_EXCEPTION()
7345
7470
 
7346
- DestroyExceptionInfo(&exception);
7471
+ (void) DestroyExceptionInfo(&exception);
7347
7472
 
7348
7473
  return self;
7349
7474
 
@@ -7382,6 +7507,7 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
7382
7507
  // Map QuantumExpressionOperator to MagickEvaluateOperator
7383
7508
  switch(operator)
7384
7509
  {
7510
+ default:
7385
7511
  case UndefinedQuantumOperator:
7386
7512
  qop = UndefinedEvaluateOperator;
7387
7513
  break;
@@ -7426,7 +7552,7 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
7426
7552
  (void) EvaluateImageChannel(image, channel, qop, rvalue, &exception);
7427
7553
  CHECK_EXCEPTION()
7428
7554
 
7429
- DestroyExceptionInfo(&exception);
7555
+ (void) DestroyExceptionInfo(&exception);
7430
7556
 
7431
7557
  return self;
7432
7558
 
@@ -7454,15 +7580,15 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
7454
7580
  switch (argc)
7455
7581
  {
7456
7582
  case 5:
7457
- quantize_info.measure_error = RTEST(argv[4]);
7583
+ quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
7458
7584
  case 4:
7459
- quantize_info.tree_depth = NUM2INT(argv[3]);
7585
+ quantize_info.tree_depth = NUM2UINT(argv[3]);
7460
7586
  case 3:
7461
- quantize_info.dither = RTEST(argv[2]);
7587
+ quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
7462
7588
  case 2:
7463
7589
  VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
7464
7590
  case 1:
7465
- quantize_info.number_colors = NUM2INT(argv[0]);
7591
+ quantize_info.number_colors = NUM2UINT(argv[0]);
7466
7592
  case 0:
7467
7593
  break;
7468
7594
  default:
@@ -7472,7 +7598,7 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
7472
7598
 
7473
7599
  new_image = rm_clone_image(image);
7474
7600
 
7475
- QuantizeImage(&quantize_info, new_image);
7601
+ (void) QuantizeImage(&quantize_info, new_image);
7476
7602
  rm_check_image_exception(new_image, DestroyOnError);
7477
7603
 
7478
7604
  return rm_image_new(new_image);
@@ -7498,7 +7624,7 @@ Image_radial_blur(VALUE self, VALUE angle)
7498
7624
  new_image = RadialBlurImage(image, NUM2DBL(angle), &exception);
7499
7625
  rm_check_exception(&exception, new_image, DestroyOnError);
7500
7626
 
7501
- DestroyExceptionInfo(&exception);
7627
+ (void) DestroyExceptionInfo(&exception);
7502
7628
 
7503
7629
  rm_ensure_result(new_image);
7504
7630
 
@@ -7543,7 +7669,7 @@ Image_radial_blur_channel(
7543
7669
  new_image = RadialBlurImageChannel(image, channels, NUM2DBL(argv[0]), &exception);
7544
7670
 
7545
7671
  rm_check_exception(&exception, new_image, DestroyOnError);
7546
- DestroyExceptionInfo(&exception);
7672
+ (void) DestroyExceptionInfo(&exception);
7547
7673
  rm_ensure_result(new_image);
7548
7674
 
7549
7675
  return rm_image_new(new_image);
@@ -7595,7 +7721,7 @@ Image_random_channel_threshold(
7595
7721
  (void) RandomChannelThresholdImage(new_image, channel, thresholds, &exception);
7596
7722
  rm_check_exception(&exception, new_image, DestroyOnError);
7597
7723
 
7598
- DestroyExceptionInfo(&exception);
7724
+ (void) DestroyExceptionInfo(&exception);
7599
7725
 
7600
7726
  return rm_image_new(new_image);
7601
7727
  #else
@@ -7650,7 +7776,7 @@ Image_random_threshold_channel(
7650
7776
  (void) RandomThresholdImageChannel(new_image, channels, thresholds, &exception);
7651
7777
  rm_check_exception(&exception, new_image, DestroyOnError);
7652
7778
 
7653
- DestroyExceptionInfo(&exception);
7779
+ (void) DestroyExceptionInfo(&exception);
7654
7780
 
7655
7781
  return rm_image_new(new_image);
7656
7782
 
@@ -7776,12 +7902,57 @@ rd_image(VALUE class, VALUE file, reader_t reader)
7776
7902
  images = (reader)(info, &exception);
7777
7903
  rm_check_exception(&exception, images, DestroyOnError);
7778
7904
 
7779
- DestroyExceptionInfo(&exception);
7905
+ (void) DestroyExceptionInfo(&exception);
7780
7906
 
7781
7907
  return array_from_images(images);
7782
7908
  }
7783
7909
 
7784
7910
 
7911
+ /*
7912
+ Method: Image#recolor(matrix)
7913
+ Purpose: Call RecolorImage
7914
+ */
7915
+ VALUE
7916
+ Image_recolor(VALUE self, VALUE color_matrix)
7917
+ {
7918
+ #if defined(HAVE_RECOLORIMAGE)
7919
+ Image *image, *new_image;
7920
+ unsigned long order;
7921
+ long x, len;
7922
+ double *matrix;
7923
+ ExceptionInfo exception;
7924
+
7925
+ GetExceptionInfo(&exception);
7926
+
7927
+ // Allocate color matrix from Ruby's memory
7928
+ len = RARRAY(color_matrix)->len;
7929
+ matrix = ALLOC_N(double, len);
7930
+
7931
+ for (x = 0; x < len; x++)
7932
+ {
7933
+ matrix[x] = NUM2DBL(rb_ary_entry(color_matrix, x));
7934
+ }
7935
+
7936
+ order = (unsigned long)sqrt((double)(len + 1.0));
7937
+
7938
+ Data_Get_Struct(self, Image, image);
7939
+
7940
+ // RecolorImage sets the ExceptionInfo and returns a NULL image if an error occurs.
7941
+ new_image = RecolorImage(image, order, matrix, &exception);
7942
+ xfree((void *)matrix);
7943
+
7944
+ rm_check_exception(&exception, new_image, DestroyOnError);
7945
+ (void) DestroyExceptionInfo(&exception);
7946
+
7947
+ return rm_image_new(new_image);
7948
+
7949
+ #else
7950
+ rm_not_implemented();
7951
+ return (VALUE)0;
7952
+ #endif
7953
+ }
7954
+
7955
+
7785
7956
  /*
7786
7957
  Method: Image.read_inline(content)
7787
7958
  Purpose: Read a Base64-encoded image
@@ -7837,7 +8008,7 @@ Image_read_inline(VALUE self, VALUE content)
7837
8008
 
7838
8009
  rm_check_exception(&exception, images, DestroyOnError);
7839
8010
 
7840
- DestroyExceptionInfo(&exception);
8011
+ (void) DestroyExceptionInfo(&exception);
7841
8012
 
7842
8013
  return array_from_images(images);
7843
8014
  }
@@ -7861,7 +8032,7 @@ static VALUE array_from_images(Image *images)
7861
8032
  {
7862
8033
  image = RemoveFirstImageFromList(&images);
7863
8034
  image_obj = rm_image_new(image);
7864
- rb_ary_push(image_ary, image_obj);
8035
+ (void) rb_ary_push(image_ary, image_obj);
7865
8036
  }
7866
8037
 
7867
8038
  return image_ary;
@@ -7885,7 +8056,7 @@ Image_reduce_noise(VALUE self, VALUE radius)
7885
8056
  new_image = ReduceNoiseImage(image, NUM2DBL(radius), &exception);
7886
8057
  rm_check_exception(&exception, new_image, DestroyOnError);
7887
8058
 
7888
- DestroyExceptionInfo(&exception);
8059
+ (void) DestroyExceptionInfo(&exception);
7889
8060
 
7890
8061
  return rm_image_new(new_image);
7891
8062
  }
@@ -7968,7 +8139,7 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
7968
8139
  }
7969
8140
  drows = scale * image->rows + 0.5;
7970
8141
  dcols = scale * image->columns + 0.5;
7971
- if (drows > ULONG_MAX || dcols > ULONG_MAX)
8142
+ if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
7972
8143
  {
7973
8144
  rb_raise(rb_eRangeError, "resized image too big");
7974
8145
  }
@@ -7984,14 +8155,14 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
7984
8155
  new_image = ResizeImage(image, columns, rows, filter, blur, &exception);
7985
8156
  rm_check_exception(&exception, new_image, DestroyOnError);
7986
8157
 
7987
- DestroyExceptionInfo(&exception);
8158
+ (void) DestroyExceptionInfo(&exception);
7988
8159
 
7989
8160
  rm_ensure_result(new_image);
7990
8161
 
7991
8162
  if (bang)
7992
8163
  {
7993
8164
  DATA_PTR(self) = new_image;
7994
- DestroyImage(image);
8165
+ (void) DestroyImage(image);
7995
8166
  return self;
7996
8167
  }
7997
8168
  return rm_image_new(new_image);
@@ -8027,7 +8198,7 @@ Image_roll(VALUE self, VALUE x_offset, VALUE y_offset)
8027
8198
  new_image = RollImage(image, NUM2LONG(x_offset), NUM2LONG(y_offset), &exception);
8028
8199
  rm_check_exception(&exception, new_image, DestroyOnError);
8029
8200
 
8030
- DestroyExceptionInfo(&exception);
8201
+ (void) DestroyExceptionInfo(&exception);
8031
8202
 
8032
8203
  rm_ensure_result(new_image);
8033
8204
 
@@ -8083,14 +8254,14 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
8083
8254
  new_image = RotateImage(image, degrees, &exception);
8084
8255
  rm_check_exception(&exception, new_image, DestroyOnError);
8085
8256
 
8086
- DestroyExceptionInfo(&exception);
8257
+ (void) DestroyExceptionInfo(&exception);
8087
8258
 
8088
8259
  rm_ensure_result(new_image);
8089
8260
 
8090
8261
  if (bang)
8091
8262
  {
8092
8263
  DATA_PTR(self) = new_image;
8093
- DestroyImage(image);
8264
+ (void) DestroyImage(image);
8094
8265
  return self;
8095
8266
  }
8096
8267
  return rm_image_new(new_image);
@@ -8158,7 +8329,7 @@ Image_scale_bang(int argc, VALUE *argv, VALUE self)
8158
8329
  if 2 arguments, (cols, rows)
8159
8330
  */
8160
8331
  static VALUE
8161
- scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t *scaler)
8332
+ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
8162
8333
  {
8163
8334
  Image *image, *new_image;
8164
8335
  unsigned long columns, rows;
@@ -8185,7 +8356,7 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t *scaler)
8185
8356
  }
8186
8357
  drows = scale * image->rows + 0.5;
8187
8358
  dcols = scale * image->columns + 0.5;
8188
- if (drows > ULONG_MAX || dcols > ULONG_MAX)
8359
+ if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
8189
8360
  {
8190
8361
  rb_raise(rb_eRangeError, "resized image too big");
8191
8362
  }
@@ -8201,14 +8372,14 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t *scaler)
8201
8372
  new_image = (scaler)(image, columns, rows, &exception);
8202
8373
  rm_check_exception(&exception, new_image, DestroyOnError);
8203
8374
 
8204
- DestroyExceptionInfo(&exception);
8375
+ (void) DestroyExceptionInfo(&exception);
8205
8376
 
8206
8377
  rm_ensure_result(new_image);
8207
8378
 
8208
8379
  if (bang)
8209
8380
  {
8210
8381
  DATA_PTR(self) = new_image;
8211
- DestroyImage(image);
8382
+ (void) DestroyImage(image);
8212
8383
  return self;
8213
8384
  }
8214
8385
 
@@ -8275,7 +8446,7 @@ Image_sepiatone(int argc, VALUE *argv, VALUE self)
8275
8446
  new_image = SepiaToneImage(image, threshold, &exception);
8276
8447
  rm_check_exception(&exception, new_image, DestroyOnError);
8277
8448
 
8278
- DestroyExceptionInfo(&exception);
8449
+ (void) DestroyExceptionInfo(&exception);
8279
8450
 
8280
8451
  rm_ensure_result(new_image);
8281
8452
 
@@ -8350,7 +8521,7 @@ Image_opacity_eq(VALUE self, VALUE opacity_arg)
8350
8521
  rb_raise(rb_eArgError, "opacity level (%d) exceeds MaxRGB", opacity);
8351
8522
  }
8352
8523
 
8353
- SetImageOpacity(image, opacity);
8524
+ (void) SetImageOpacity(image, (Quantum)opacity);
8354
8525
  return self;
8355
8526
  }
8356
8527
 
@@ -8383,9 +8554,9 @@ Image_properties(VALUE self)
8383
8554
  attr = GetNextImageAttribute(image);
8384
8555
  while (attr)
8385
8556
  {
8386
- rb_ary_store(ary, 0, rb_str_new2(attr->key));
8387
- rb_ary_store(ary, 1, rb_str_new2(attr->value));
8388
- rb_yield(ary);
8557
+ (void) rb_ary_store(ary, 0, rb_str_new2(attr->key));
8558
+ (void) rb_ary_store(ary, 1, rb_str_new2(attr->value));
8559
+ (void) rb_yield(ary);
8389
8560
  attr = GetNextImageAttribute(image);
8390
8561
  }
8391
8562
  #else
@@ -8411,13 +8582,13 @@ Image_properties(VALUE self)
8411
8582
  attr = GetNextImageAttribute(image);
8412
8583
  while (attr)
8413
8584
  {
8414
- rb_hash_aset(attr_hash, rb_str_new2(attr->key), rb_str_new2(attr->value));
8585
+ (void) rb_hash_aset(attr_hash, rb_str_new2(attr->key), rb_str_new2(attr->value));
8415
8586
  attr = GetNextImageAttribute(image);
8416
8587
  }
8417
8588
  #else
8418
8589
  for (attr = image->attributes; attr; attr = attr->next)
8419
8590
  {
8420
- rb_hash_aset(attr_hash, rb_str_new2(attr->key), rb_str_new2(attr->value));
8591
+ (void) rb_hash_aset(attr_hash, rb_str_new2(attr->key), rb_str_new2(attr->value));
8421
8592
  }
8422
8593
  #endif
8423
8594
  return attr_hash;
@@ -8462,7 +8633,7 @@ Image_shade(int argc, VALUE *argv, VALUE self)
8462
8633
  new_image = ShadeImage(image, shading, azimuth, elevation, &exception);
8463
8634
  rm_check_exception(&exception, new_image, DestroyOnError);
8464
8635
 
8465
- DestroyExceptionInfo(&exception);
8636
+ (void) DestroyExceptionInfo(&exception);
8466
8637
 
8467
8638
  rm_ensure_result(new_image);
8468
8639
 
@@ -8505,9 +8676,9 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
8505
8676
  case 3:
8506
8677
  sigma = NUM2DBL(argv[2]);
8507
8678
  case 2:
8508
- y_offset = NUM2ULONG(argv[1]);
8679
+ y_offset = NUM2LONG(argv[1]);
8509
8680
  case 1:
8510
- x_offset = NUM2ULONG(argv[0]);
8681
+ x_offset = NUM2LONG(argv[0]);
8511
8682
  case 0:
8512
8683
  break;
8513
8684
  default:
@@ -8521,7 +8692,7 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
8521
8692
  new_image = ShadowImage(image, opacity, sigma, x_offset, y_offset, &exception);
8522
8693
  rm_check_exception(&exception, new_image, DestroyOnError);
8523
8694
 
8524
- DestroyExceptionInfo(&exception);
8695
+ (void) DestroyExceptionInfo(&exception);
8525
8696
 
8526
8697
  rm_ensure_result(new_image);
8527
8698
 
@@ -8582,7 +8753,7 @@ Image_sharpen_channel(int argc, VALUE *argv, VALUE self)
8582
8753
  (void) SharpenImageChannel(new_image, channels, radius, sigma, &exception);
8583
8754
  rm_check_exception(&exception, new_image, DestroyOnError);
8584
8755
 
8585
- DestroyExceptionInfo(&exception);
8756
+ (void) DestroyExceptionInfo(&exception);
8586
8757
 
8587
8758
  return rm_image_new(new_image);
8588
8759
  #else
@@ -8642,7 +8813,7 @@ Image_shear(
8642
8813
  new_image = ShearImage(image, NUM2DBL(x_shear), NUM2DBL(y_shear), &exception);
8643
8814
  rm_check_exception(&exception, new_image, DestroyOnError);
8644
8815
 
8645
- DestroyExceptionInfo(&exception);
8816
+ (void) DestroyExceptionInfo(&exception);
8646
8817
 
8647
8818
  rm_ensure_result(new_image);
8648
8819
 
@@ -8671,7 +8842,7 @@ Image_sigmoidal_contrast_channel(int argc, VALUE *argv, VALUE self)
8671
8842
  switch(argc)
8672
8843
  {
8673
8844
  case 3:
8674
- sharpen = RTEST(argv[2]);
8845
+ sharpen = (MagickBooleanType) RTEST(argv[2]);
8675
8846
  case 2:
8676
8847
  midpoint = NUM2DBL(argv[1]);
8677
8848
  case 1:
@@ -8707,7 +8878,7 @@ Image_signature(VALUE self)
8707
8878
  const ImageAttribute *signature;
8708
8879
 
8709
8880
  Data_Get_Struct(self, Image, image);
8710
- SignatureImage(image);
8881
+ (void) SignatureImage(image);
8711
8882
  signature = GetImageAttribute(image, "signature");
8712
8883
  if (!signature)
8713
8884
  {
@@ -8801,8 +8972,8 @@ Image_spaceship(VALUE self, VALUE other)
8801
8972
  Data_Get_Struct(self, Image, imageA);
8802
8973
  Data_Get_Struct(other, Image, imageB);
8803
8974
 
8804
- SignatureImage(imageA);
8805
- SignatureImage(imageB);
8975
+ (void) SignatureImage(imageA);
8976
+ (void) SignatureImage(imageB);
8806
8977
  sigA = GetImageAttribute(imageA, "signature");
8807
8978
  sigB = GetImageAttribute(imageB, "signature");
8808
8979
  if (!sigA || !sigB)
@@ -8851,8 +9022,8 @@ Image_splice(int argc, VALUE *argv, VALUE self)
8851
9022
  break;
8852
9023
  }
8853
9024
 
8854
- rectangle.x = NUM2ULONG(argv[0]);
8855
- rectangle.y = NUM2ULONG(argv[1]);
9025
+ rectangle.x = NUM2LONG(argv[0]);
9026
+ rectangle.y = NUM2LONG(argv[1]);
8856
9027
  rectangle.width = NUM2ULONG(argv[2]);
8857
9028
  rectangle.height = NUM2ULONG(argv[3]);
8858
9029
 
@@ -8866,7 +9037,7 @@ Image_splice(int argc, VALUE *argv, VALUE self)
8866
9037
 
8867
9038
  rm_check_exception(&exception, new_image, DestroyOnError);
8868
9039
 
8869
- DestroyExceptionInfo(&exception);
9040
+ (void) DestroyExceptionInfo(&exception);
8870
9041
 
8871
9042
  rm_ensure_result(new_image);
8872
9043
 
@@ -8908,7 +9079,7 @@ Image_spread(int argc, VALUE *argv, VALUE self)
8908
9079
  rm_check_exception(&exception, new_image, DestroyOnError);
8909
9080
  rm_ensure_result(new_image);
8910
9081
 
8911
- DestroyExceptionInfo(&exception);
9082
+ (void) DestroyExceptionInfo(&exception);
8912
9083
 
8913
9084
  return rm_image_new(new_image);
8914
9085
  }
@@ -8934,7 +9105,7 @@ Image_statistics(VALUE self)
8934
9105
  (void) GetImageStatistics(image, &stats, &exception);
8935
9106
  CHECK_EXCEPTION()
8936
9107
 
8937
- DestroyExceptionInfo(&exception);
9108
+ (void) DestroyExceptionInfo(&exception);
8938
9109
 
8939
9110
  return Statistics_new(&stats);
8940
9111
  #else
@@ -8974,7 +9145,7 @@ Image_stegano(
8974
9145
  new_image = SteganoImage(image, watermark, &exception);
8975
9146
  rm_check_exception(&exception, new_image, DestroyOnError);
8976
9147
 
8977
- DestroyExceptionInfo(&exception);
9148
+ (void) DestroyExceptionInfo(&exception);
8978
9149
 
8979
9150
  rm_ensure_result(new_image);
8980
9151
 
@@ -9008,7 +9179,7 @@ Image_stereo(
9008
9179
  new_image = StereoImage(image, offset, &exception);
9009
9180
  rm_check_exception(&exception, new_image, DestroyOnError);
9010
9181
 
9011
- DestroyExceptionInfo(&exception);
9182
+ (void) DestroyExceptionInfo(&exception);
9012
9183
 
9013
9184
  rm_ensure_result(new_image);
9014
9185
 
@@ -9047,7 +9218,7 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
9047
9218
 
9048
9219
  if (image->storage_class == PseudoClass && class_type == DirectClass)
9049
9220
  {
9050
- SyncImage(image);
9221
+ (void) SyncImage(image);
9051
9222
  magick_free(image->colormap);
9052
9223
  image->colormap = NULL;
9053
9224
  }
@@ -9055,11 +9226,11 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
9055
9226
  {
9056
9227
  GetQuantizeInfo(&qinfo);
9057
9228
  qinfo.number_colors = MaxRGB+1;
9058
- QuantizeImage(&qinfo, image);
9229
+ (void) QuantizeImage(&qinfo, image);
9059
9230
  }
9060
9231
 
9061
9232
  #if defined(HAVE_SETIMAGESTORAGECLASS)
9062
- SetImageStorageClass(image, class_type);
9233
+ (void) SetImageStorageClass(image, class_type);
9063
9234
  #else
9064
9235
  image->storage_class = class_type;
9065
9236
  #endif
@@ -9087,25 +9258,26 @@ Image_store_pixels(
9087
9258
  Pixel *pixels, *pixel;
9088
9259
  volatile VALUE new_pixel;
9089
9260
  long n, size;
9090
- long x, y, cols, rows;
9261
+ long x, y;
9262
+ unsigned long cols, rows;
9091
9263
  unsigned int okay;
9092
9264
 
9093
9265
  Data_Get_Struct(self, Image, image);
9094
9266
 
9095
9267
  x = NUM2LONG(x_arg);
9096
9268
  y = NUM2LONG(y_arg);
9097
- cols = NUM2LONG(cols_arg);
9098
- rows = NUM2LONG(rows_arg);
9269
+ cols = NUM2ULONG(cols_arg);
9270
+ rows = NUM2ULONG(rows_arg);
9099
9271
  if (x < 0 || y < 0 || x+cols > image->columns || y+rows > image->rows)
9100
9272
  {
9101
9273
  rb_raise(rb_eRangeError, "geometry (%lux%lu%+ld%+ld) exceeds image bounds"
9102
9274
  , cols, rows, x, y);
9103
9275
  }
9104
9276
 
9105
- size = cols * rows;
9277
+ size = (long)(cols * rows);
9106
9278
  rm_check_ary_len(new_pixels, size);
9107
9279
 
9108
- SetImageType(image, TrueColorType);
9280
+ (void) SetImageType(image, TrueColorType);
9109
9281
 
9110
9282
  // Get a pointer to the pixels. Replace the values with the PixelPackets
9111
9283
  // from the pixels argument.
@@ -9169,7 +9341,7 @@ Image_swirl(VALUE self, VALUE degrees)
9169
9341
  new_image = SwirlImage(image, NUM2DBL(degrees), &exception);
9170
9342
  rm_check_exception(&exception, new_image, DestroyOnError);
9171
9343
 
9172
- DestroyExceptionInfo(&exception);
9344
+ (void) DestroyExceptionInfo(&exception);
9173
9345
 
9174
9346
  rm_ensure_result(new_image);
9175
9347
 
@@ -9210,9 +9382,9 @@ Image_texture_flood_fill(
9210
9382
  x = NUM2LONG(x_obj);
9211
9383
  y = NUM2LONG(y_obj);
9212
9384
 
9213
- if (x > image->columns || y > image->rows)
9385
+ if ((unsigned long)x > image->columns || (unsigned long)y > image->rows)
9214
9386
  {
9215
- rb_raise(rb_eArgError, "target out of range. %dx%d given, image is %dx%d"
9387
+ rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %lux%lu"
9216
9388
  , x, y, image->columns, image->rows);
9217
9389
  }
9218
9390
 
@@ -9220,7 +9392,7 @@ Image_texture_flood_fill(
9220
9392
  if (method != FillToBorderMethod && method != FloodfillMethod)
9221
9393
  {
9222
9394
  rb_raise(rb_eArgError, "paint method must be FloodfillMethod or "
9223
- "FillToBorderMethod (%d given)", method);
9395
+ "FillToBorderMethod (%d given)", (int)method);
9224
9396
  }
9225
9397
 
9226
9398
  draw_info = CloneDrawInfo(NULL, NULL);
@@ -9237,14 +9409,14 @@ Image_texture_flood_fill(
9237
9409
  // the fill color even though the fill color isn't used.
9238
9410
  if (method == FillToBorderMethod)
9239
9411
  {
9240
- draw_info->fill.red = color.red + new_image->fuzz + 1;
9412
+ draw_info->fill.red = RoundToQuantum(color.red + new_image->fuzz + 1);
9241
9413
  draw_info->fill.green = color.green;
9242
9414
  draw_info->fill.blue = color.blue;
9243
9415
  }
9244
9416
 
9245
9417
  (void) ColorFloodfillImage(new_image, draw_info, color, x, y, method);
9246
9418
 
9247
- DestroyDrawInfo(draw_info);
9419
+ (void) DestroyDrawInfo(draw_info);
9248
9420
  rm_check_image_exception(new_image, DestroyOnError);
9249
9421
 
9250
9422
 
@@ -9362,7 +9534,7 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
9362
9534
  }
9363
9535
  drows = scale * image->rows + 0.5;
9364
9536
  dcols = scale * image->columns + 0.5;
9365
- if (drows > ULONG_MAX || dcols > ULONG_MAX)
9537
+ if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
9366
9538
  {
9367
9539
  rb_raise(rb_eRangeError, "resized image too big");
9368
9540
  }
@@ -9378,14 +9550,14 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
9378
9550
  new_image = ThumbnailImage(image, columns, rows, &exception);
9379
9551
  rm_check_exception(&exception, new_image, DestroyOnError);
9380
9552
 
9381
- DestroyExceptionInfo(&exception);
9553
+ (void) DestroyExceptionInfo(&exception);
9382
9554
 
9383
9555
  rm_ensure_result(new_image);
9384
9556
 
9385
9557
  if (bang)
9386
9558
  {
9387
9559
  DATA_PTR(self) = new_image;
9388
- DestroyImage(image);
9560
+ (void) DestroyImage(image);
9389
9561
  return self;
9390
9562
  }
9391
9563
 
@@ -9433,7 +9605,7 @@ Image_ticks_per_second_eq(VALUE self, VALUE tps)
9433
9605
 
9434
9606
  rm_check_frozen(self);
9435
9607
  Data_Get_Struct(self, Image, image);
9436
- image->ticks_per_second = NUM2INT(tps);
9608
+ image->ticks_per_second = NUM2ULONG(tps);
9437
9609
  return self;
9438
9610
  #else
9439
9611
  rm_not_implemented();
@@ -9545,7 +9717,7 @@ Image_tint(int argc, VALUE *argv, VALUE self)
9545
9717
  new_image = TintImage(image, opacity, *tint, &exception);
9546
9718
  rm_check_exception(&exception, new_image, DestroyOnError);
9547
9719
 
9548
- DestroyExceptionInfo(&exception);
9720
+ (void) DestroyExceptionInfo(&exception);
9549
9721
 
9550
9722
  rm_ensure_result(new_image);
9551
9723
 
@@ -9595,7 +9767,7 @@ Image_to_blob(VALUE self)
9595
9767
  GetExceptionInfo(&exception);
9596
9768
  if (*info->magick)
9597
9769
  {
9598
- (void) SetImageInfo(info, True, &exception);
9770
+ (void) SetImageInfo(info, MagickTrue, &exception);
9599
9771
  CHECK_EXCEPTION()
9600
9772
 
9601
9773
  if (*info->magick == '\0')
@@ -9623,7 +9795,7 @@ Image_to_blob(VALUE self)
9623
9795
  blob = ImageToBlob(info, image, &length, &exception);
9624
9796
  CHECK_EXCEPTION()
9625
9797
 
9626
- DestroyExceptionInfo(&exception);
9798
+ (void) DestroyExceptionInfo(&exception);
9627
9799
 
9628
9800
  if (length == 0 || !blob)
9629
9801
  {
@@ -9663,7 +9835,7 @@ Image_to_color(VALUE self, VALUE pixel_arg)
9663
9835
  (void) QueryColorname(image, pixel, AllCompliance, name, &exception);
9664
9836
  CHECK_EXCEPTION()
9665
9837
 
9666
- DestroyExceptionInfo(&exception);
9838
+ (void) DestroyExceptionInfo(&exception);
9667
9839
 
9668
9840
  return rb_str_new2(name);
9669
9841
 
@@ -9717,7 +9889,7 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
9717
9889
 
9718
9890
  new_image = rm_clone_image(image);
9719
9891
 
9720
- (void) TransparentImage(new_image, color, opacity);
9892
+ (void) TransparentImage(new_image, color, (Quantum)opacity);
9721
9893
  rm_check_image_exception(new_image, DestroyOnError);
9722
9894
 
9723
9895
  return rm_image_new(new_image);
@@ -9846,14 +10018,14 @@ trimmer(int bang, VALUE self)
9846
10018
  new_image = CropImage(image, &geometry, &exception);
9847
10019
  rm_check_exception(&exception, new_image, DestroyOnError);
9848
10020
 
9849
- DestroyExceptionInfo(&exception);
10021
+ (void) DestroyExceptionInfo(&exception);
9850
10022
 
9851
10023
  rm_ensure_result(new_image);
9852
10024
 
9853
10025
  if (bang)
9854
10026
  {
9855
10027
  DATA_PTR(self) = new_image;
9856
- DestroyImage(image);
10028
+ (void) DestroyImage(image);
9857
10029
  return self;
9858
10030
  }
9859
10031
 
@@ -9890,7 +10062,7 @@ VALUE Image_image_type_eq(VALUE self, VALUE type)
9890
10062
  rm_check_frozen(self);
9891
10063
  Data_Get_Struct(self, Image, image);
9892
10064
  VALUE_TO_ENUM(type, it, ImageType);
9893
- SetImageType(image, it);
10065
+ (void) SetImageType(image, it);
9894
10066
 
9895
10067
  return self;
9896
10068
  }
@@ -9910,7 +10082,7 @@ VALUE Image_image_type(VALUE self)
9910
10082
  type = GetImageType(image, &exception);
9911
10083
  CHECK_EXCEPTION()
9912
10084
 
9913
- DestroyExceptionInfo(&exception);
10085
+ (void) DestroyExceptionInfo(&exception);
9914
10086
 
9915
10087
  return ImageType_new(type);
9916
10088
  }
@@ -9932,7 +10104,7 @@ Image_unique_colors(VALUE self)
9932
10104
 
9933
10105
  new_image = UniqueImageColors(image, &exception);
9934
10106
  rm_check_exception(&exception, new_image, DestroyOnError);
9935
- DestroyExceptionInfo(&exception);
10107
+ (void) DestroyExceptionInfo(&exception);
9936
10108
 
9937
10109
  rm_ensure_result(new_image);
9938
10110
 
@@ -10042,7 +10214,7 @@ Image_unsharp_mask(int argc, VALUE *argv, VALUE self)
10042
10214
  new_image = UnsharpMaskImage(image, radius, sigma, amount, threshold, &exception);
10043
10215
  rm_check_exception(&exception, new_image, DestroyOnError);
10044
10216
 
10045
- DestroyExceptionInfo(&exception);
10217
+ (void) DestroyExceptionInfo(&exception);
10046
10218
 
10047
10219
  rm_ensure_result(new_image);
10048
10220
 
@@ -10078,7 +10250,7 @@ Image_unsharp_mask_channel(int argc, VALUE *argv, VALUE self)
10078
10250
  , threshold, &exception);
10079
10251
  rm_check_exception(&exception, new_image, DestroyOnError);
10080
10252
 
10081
- DestroyExceptionInfo(&exception);
10253
+ (void) DestroyExceptionInfo(&exception);
10082
10254
 
10083
10255
  rm_ensure_result(new_image);
10084
10256
 
@@ -10106,8 +10278,8 @@ Image_vignette(int argc, VALUE *argv, VALUE self)
10106
10278
 
10107
10279
  Data_Get_Struct(self, Image, image);
10108
10280
 
10109
- horz_radius = image->columns * 0.10 + 0.5;
10110
- vert_radius = image->rows * 0.10 + 0.5;
10281
+ horz_radius = (long)(image->columns * 0.10 + 0.5);
10282
+ vert_radius = (long)(image->rows * 0.10 + 0.5);
10111
10283
 
10112
10284
  switch (argc)
10113
10285
  {
@@ -10131,7 +10303,7 @@ Image_vignette(int argc, VALUE *argv, VALUE self)
10131
10303
  new_image = VignetteImage(image, radius, sigma, horz_radius, vert_radius, &exception);
10132
10304
  rm_check_exception(&exception, new_image, DestroyOnError);
10133
10305
 
10134
- DestroyExceptionInfo(&exception);
10306
+ (void) DestroyExceptionInfo(&exception);
10135
10307
 
10136
10308
  rm_ensure_result(new_image);
10137
10309
 
@@ -10226,7 +10398,7 @@ Image_watermark(int argc, VALUE *argv, VALUE self)
10226
10398
  }
10227
10399
 
10228
10400
  blend_geometry(geometry, sizeof(geometry), src_percent, dst_percent);
10229
- CloneString(&overlay->geometry, geometry);
10401
+ (void) CloneString(&overlay->geometry, geometry);
10230
10402
 
10231
10403
  new_image = rm_clone_image(image);
10232
10404
  (void) CompositeImage(new_image, ModulateCompositeOp, overlay, x_offset, y_offset);
@@ -10269,7 +10441,7 @@ Image_wave(int argc, VALUE *argv, VALUE self)
10269
10441
  new_image = WaveImage(image, amplitude, wavelength, &exception);
10270
10442
  rm_check_exception(&exception, new_image, DestroyOnError);
10271
10443
 
10272
- DestroyExceptionInfo(&exception);
10444
+ (void) DestroyExceptionInfo(&exception);
10273
10445
 
10274
10446
  rm_ensure_result(new_image);
10275
10447
 
@@ -10277,6 +10449,151 @@ Image_wave(int argc, VALUE *argv, VALUE self)
10277
10449
  }
10278
10450
 
10279
10451
 
10452
+ /*
10453
+ Method: Image#wet_floor(initial, rate)
10454
+ Purpose: Construct a "wet floor" reflection.
10455
+ Notes: `initial' is a number between 0 and 1, inclusive, that represents
10456
+ the initial level of transparency. Smaller numbers are less
10457
+ transparent than larger numbers. 0 is fully opaque. 1.0 is
10458
+ fully transparent. The default is 0.5.
10459
+ `rate' is the rate at which the initial level of transparency
10460
+ changes to complete transparency. The default is 1.0. Values
10461
+ larger than 1.0 cause the change to occur more rapidly. The
10462
+ resulting reflection will be shorter. Values smaller than 1.0
10463
+ cause the change to occur less rapidly. The resulting
10464
+ reflection will be taller. If the rate is exactly 0 then the
10465
+ amount of transparency doesn't change at all.
10466
+ Notes: http://en.wikipedia.org/wiki/Wet_floor_effect
10467
+ */
10468
+ VALUE
10469
+ Image_wet_floor(int argc, VALUE *argv, VALUE self)
10470
+ {
10471
+ Image *image, *reflection, *flip_image;
10472
+ PixelPacket *p, *q;
10473
+ RectangleInfo geometry;
10474
+ long x, y, max_rows;
10475
+ double initial = 0.5;
10476
+ double rate = 1.0;
10477
+ double opacity, step;
10478
+ char *func;
10479
+ ExceptionInfo exception;
10480
+
10481
+ switch (argc)
10482
+ {
10483
+ case 2:
10484
+ rate = NUM2DBL(argv[1]);
10485
+ case 1:
10486
+ initial = NUM2DBL(argv[0]);
10487
+ case 0:
10488
+ break;
10489
+ default:
10490
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
10491
+ break;
10492
+ }
10493
+
10494
+
10495
+ if (initial < 0.0 || initial > 1.0)
10496
+ {
10497
+ rb_raise(rb_eArgError, "Initial transparency must be in the range 0.0-1.0 (%g)", initial);
10498
+ }
10499
+ if (rate < 0.0)
10500
+ {
10501
+ rb_raise(rb_eArgError, "Transparency change rate must be >= 0.0 (%g)", rate);
10502
+ }
10503
+
10504
+ Data_Get_Struct(self, Image, image);
10505
+
10506
+ initial *= TransparentOpacity;
10507
+
10508
+ // The number of rows in which to transition from the initial level of
10509
+ // transparency to complete transparency. rate == 0.0 -> no change.
10510
+ if (rate > 0.0)
10511
+ {
10512
+ max_rows = (long)((double)image->rows) / (3.0 * rate);
10513
+ max_rows = (long)min((unsigned long)max_rows, image->rows);
10514
+ step = (TransparentOpacity - initial) / max_rows;
10515
+ }
10516
+ else
10517
+ {
10518
+ max_rows = (long)image->rows;
10519
+ step = 0.0;
10520
+ }
10521
+
10522
+
10523
+ GetExceptionInfo(&exception);
10524
+ flip_image = FlipImage(image, &exception);
10525
+ CHECK_EXCEPTION();
10526
+
10527
+
10528
+ geometry.x = 0;
10529
+ geometry.y = 0;
10530
+ geometry.width = image->columns;
10531
+ geometry.height = max_rows;
10532
+ reflection = CropImage(flip_image, &geometry, &exception);
10533
+ (void) DestroyImage(flip_image);
10534
+ CHECK_EXCEPTION();
10535
+
10536
+
10537
+ #if defined(HAVE_SETIMAGESTORAGECLASS)
10538
+ (void) SetImageStorageClass(reflection, DirectClass);
10539
+ rm_check_image_exception(reflection, DestroyOnError);
10540
+ #else
10541
+ if (reflection->storage_class == PseudoClass)
10542
+ {
10543
+ SyncImage(reflection);
10544
+ reflection->storage_class = DirectClass;
10545
+ }
10546
+ #endif
10547
+
10548
+
10549
+ reflection->matte = MagickTrue;
10550
+ opacity = initial;
10551
+
10552
+ for (y = 0; y < max_rows; y++)
10553
+ {
10554
+ if (opacity > TransparentOpacity)
10555
+ {
10556
+ opacity = TransparentOpacity;
10557
+ }
10558
+
10559
+ p = (PixelPacket *)AcquireImagePixels(reflection, 0, y, image->columns, 1, &exception);
10560
+ rm_check_exception(&exception, reflection, RetainOnError);
10561
+
10562
+ q = SetImagePixels(reflection, 0, y, image->columns, 1);
10563
+ if (!q)
10564
+ {
10565
+ func = "SetImagePixels";
10566
+ goto error;
10567
+ }
10568
+
10569
+ for (x = 0; x < (long) image->columns; x++)
10570
+ {
10571
+ q[x] = p[x];
10572
+ // Never make a pixel *less* transparent than it already is.
10573
+ q[x].opacity = max(q[x].opacity, (Quantum)opacity);
10574
+ }
10575
+
10576
+ if (SyncImagePixels(reflection) == MagickFalse)
10577
+ {
10578
+ func = "SyncImagePixels";
10579
+ goto error;
10580
+ }
10581
+
10582
+ opacity += step;
10583
+ }
10584
+
10585
+
10586
+ (void) DestroyExceptionInfo(&exception);
10587
+ return rm_image_new(reflection);
10588
+
10589
+ error:
10590
+ (void) DestroyExceptionInfo(&exception);
10591
+ (void) DestroyImage(reflection);
10592
+ rb_raise(rb_eRuntimeError, "%s failed on row %lu", func, y);
10593
+ return (VALUE)0;
10594
+ }
10595
+
10596
+
10280
10597
  /*
10281
10598
  * Method: Image#white_threshold(red_channel [, green_channel
10282
10599
  * [, blue_channel [, opacity_channel]]]);
@@ -10338,10 +10655,10 @@ Image_write(VALUE self, VALUE file)
10338
10655
  strcpy(image->filename, info->filename);
10339
10656
 
10340
10657
  GetExceptionInfo(&exception);
10341
- (void) SetImageInfo(info, True, &exception);
10658
+ (void) SetImageInfo(info, MagickTrue, &exception);
10342
10659
  CHECK_EXCEPTION()
10343
10660
 
10344
- DestroyExceptionInfo(&exception);
10661
+ (void) DestroyExceptionInfo(&exception);
10345
10662
 
10346
10663
  if (*info->magick == '\0')
10347
10664
  {
@@ -10350,7 +10667,7 @@ Image_write(VALUE self, VALUE file)
10350
10667
  SetImageInfoFile(info, NULL);
10351
10668
  }
10352
10669
 
10353
- info->adjoin = False;
10670
+ info->adjoin = MagickFalse;
10354
10671
  (void) WriteImage(info, image);
10355
10672
  rm_check_image_exception(image, RetainOnError);
10356
10673
 
@@ -10547,7 +10864,7 @@ xform_image(
10547
10864
  VALUE y,
10548
10865
  VALUE width,
10549
10866
  VALUE height,
10550
- xformer_t *xformer)
10867
+ xformer_t xformer)
10551
10868
  {
10552
10869
  Image *image, *new_image;
10553
10870
  RectangleInfo rect;
@@ -10567,14 +10884,14 @@ xform_image(
10567
10884
  rm_check_image_exception(image, RetainOnError);
10568
10885
  rm_check_exception(&exception, new_image, DestroyOnError);
10569
10886
 
10570
- DestroyExceptionInfo(&exception);
10887
+ (void) DestroyExceptionInfo(&exception);
10571
10888
 
10572
10889
  rm_ensure_result(new_image);
10573
10890
 
10574
10891
  if (bang)
10575
10892
  {
10576
10893
  DATA_PTR(self) = new_image;
10577
- DestroyImage(image);
10894
+ (void) DestroyImage(image);
10578
10895
  return self;
10579
10896
  }
10580
10897
 
@@ -10617,9 +10934,9 @@ ChannelType extract_channels(
10617
10934
  if (channels == 0)
10618
10935
  {
10619
10936
  #if defined(HAVE_ALLCHANNELS)
10620
- channels = AllChannels;
10937
+ channels = AllChannels & ~OpacityChannel;
10621
10938
  #else
10622
- channels = 0xff;
10939
+ channels = 0xf7;
10623
10940
  #endif
10624
10941
  }
10625
10942