rmagick 3.1.0 → 3.2.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +4 -4
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop_todo.yml +6 -0
  6. data/.travis.yml +26 -8
  7. data/CHANGELOG.md +104 -0
  8. data/before_install_linux.sh +19 -10
  9. data/benchmarks/memory/README.md +50 -0
  10. data/benchmarks/memory/image_new.rb +8 -0
  11. data/benchmarks/memory/rmagick.gnuplot +16 -0
  12. data/doc/ex/coalesce.rb +2 -2
  13. data/doc/ex/drawcomp.rb +3 -3
  14. data/doc/ex/get_pixels.rb +1 -1
  15. data/doc/ex/images/Coffee.png +0 -0
  16. data/doc/ex/images/No.png +0 -0
  17. data/doc/ex/images/Snake.png +0 -0
  18. data/doc/ex/implode.rb +2 -2
  19. data/doc/ex/mask.rb +1 -1
  20. data/doc/ex/matte_fill_to_border.rb +1 -1
  21. data/doc/ex/matte_floodfill.rb +1 -1
  22. data/doc/ex/matte_replace.rb +1 -1
  23. data/doc/ex/stegano.rb +1 -1
  24. data/examples/constitute.rb +1 -1
  25. data/examples/crop_with_gravity.rb +1 -1
  26. data/examples/demo.rb +4 -4
  27. data/examples/find_similar_region.rb +1 -1
  28. data/examples/histogram.rb +3 -3
  29. data/examples/identify.rb +46 -46
  30. data/examples/image_opacity.rb +2 -2
  31. data/examples/vignette.rb +3 -3
  32. data/ext/RMagick/extconf.rb +19 -15
  33. data/ext/RMagick/rmagick.c +1 -2
  34. data/ext/RMagick/rmagick.h +59 -30
  35. data/ext/RMagick/rmdraw.c +62 -274
  36. data/ext/RMagick/rmenum.c +121 -665
  37. data/ext/RMagick/rmfill.c +7 -7
  38. data/ext/RMagick/rmilist.c +91 -7
  39. data/ext/RMagick/rmimage.c +568 -379
  40. data/ext/RMagick/rminfo.c +152 -110
  41. data/ext/RMagick/rmkinfo.c +17 -1
  42. data/ext/RMagick/rmmain.c +75 -74
  43. data/ext/RMagick/rmmontage.c +33 -33
  44. data/ext/RMagick/rmpixel.c +75 -14
  45. data/ext/RMagick/rmstruct.c +5 -5
  46. data/ext/RMagick/rmutil.c +3 -13
  47. data/lib/obsolete.rb +66 -0
  48. data/lib/rmagick/version.rb +1 -1
  49. data/lib/rmagick_internal.rb +54 -41
  50. data/spec/rmagick/image/composite_spec.rb +5 -76
  51. data/spec/rmagick/image/properties_spec.rb +1 -1
  52. data/test/Draw.rb +52 -115
  53. data/test/Enum.rb +153 -1
  54. data/test/Fill.rb +1 -1
  55. data/test/Image1.rb +97 -43
  56. data/test/Image2.rb +140 -36
  57. data/test/Image3.rb +110 -120
  58. data/test/ImageList1.rb +46 -11
  59. data/test/ImageList2.rb +11 -21
  60. data/test/Image_attributes.rb +81 -127
  61. data/test/Import_Export.rb +2 -2
  62. data/test/Info.rb +5 -1
  63. data/test/KernelInfo.rb +67 -0
  64. data/test/Magick.rb +17 -35
  65. data/test/Pixel.rb +193 -24
  66. data/test/PolaroidOptions.rb +1 -1
  67. data/test/Preview.rb +3 -35
  68. data/test/Struct.rb +45 -0
  69. data/test/appearance/Montage.rb +26 -0
  70. data/test/appearance/appearance_assertion.rb +13 -0
  71. data/test/appearance/expected/montage_border_color.jpg +0 -0
  72. data/test/lib/Obsolete.rb +30 -0
  73. data/test/lib/internal/Draw.rb +823 -0
  74. data/test/lib/internal/Geometry.rb +98 -0
  75. data/test/lib/internal/Magick.rb +40 -0
  76. data/test/test_all_basic.rb +16 -17
  77. metadata +27 -5
  78. data/doc/ex/images/Coffee.wmf +0 -0
  79. data/doc/ex/images/No.wmf +0 -0
  80. data/doc/ex/images/Snake.wmf +0 -0
@@ -14,8 +14,6 @@
14
14
 
15
15
 
16
16
  #define ENUMERATORS_CLASS_VAR "@@enumerators"
17
- #define ENUM_TO_NAME(_enum) case _enum: return #_enum;
18
- #define ENUM_SET_NAME(_enum) case _enum: name = #_enum; break;
19
17
 
20
18
 
21
19
  static VALUE Enum_type_values(VALUE);
@@ -67,6 +65,22 @@ rm_enum_new(VALUE class, VALUE sym, VALUE val)
67
65
  return rb_obj_freeze(rb_class_new_instance(2, argv, class));
68
66
  }
69
67
 
68
+ /**
69
+ * Retrieve C string value of Enum.
70
+ *
71
+ * No Ruby usage (internal function)
72
+ *
73
+ * @param enum_type the Enum object
74
+ * @return the C string value of Enum object
75
+ */
76
+ static const char *
77
+ rm_enum_to_cstr(VALUE enum_type)
78
+ {
79
+ MagickEnum *magick_enum;
80
+
81
+ Data_Get_Struct(enum_type, MagickEnum, magick_enum);
82
+ return rb_id2name(magick_enum->id);
83
+ }
70
84
 
71
85
  /**
72
86
  * Enum class alloc function.
@@ -249,10 +263,7 @@ Enum_bitwise_or(VALUE self, VALUE another)
249
263
  VALUE
250
264
  Enum_to_s(VALUE self)
251
265
  {
252
- MagickEnum *magick_enum;
253
-
254
- Data_Get_Struct(self, MagickEnum, magick_enum);
255
- return rb_str_new2(rb_id2name(magick_enum->id));
266
+ return rb_str_new2(rm_enum_to_cstr(self));
256
267
  }
257
268
 
258
269
 
@@ -361,84 +372,67 @@ Enum_type_values(VALUE class)
361
372
  return rv;
362
373
  }
363
374
 
364
-
365
375
  /**
366
- * Construct a ClassType enum object for the specified value.
376
+ * Find enum object for the specified value.
367
377
  *
368
378
  * No Ruby usage (internal function)
369
379
  *
370
- * @param cls the class type
371
- * @return a new enumerator
380
+ * @param class the class type
381
+ * @param value the value for enum
382
+ * @return a enumerator
372
383
  */
384
+
373
385
  VALUE
374
- ClassType_new(ClassType cls)
386
+ Enum_find(VALUE class, int val)
375
387
  {
376
- const char *name;
388
+ VALUE enumerators;
389
+ MagickEnum *magick_enum;
390
+ int x;
377
391
 
378
- switch(cls)
392
+ enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
393
+ enumerators = rm_check_ary_type(enumerators);
394
+
395
+ for (x = 0; x < RARRAY_LEN(enumerators); x++)
379
396
  {
380
- ENUM_SET_NAME(DirectClass)
381
- ENUM_SET_NAME(PseudoClass)
382
- default:
383
- ENUM_SET_NAME(UndefinedClass)
397
+ VALUE enumerator = rb_ary_entry(enumerators, x);
398
+ Data_Get_Struct(enumerator, MagickEnum, magick_enum);
399
+ if (magick_enum->val == val)
400
+ {
401
+ return enumerator;
402
+ }
384
403
  }
385
404
 
386
- return rm_enum_new(Class_ClassType, ID2SYM(rb_intern(name)), INT2FIX(cls));
405
+ return Qnil;
387
406
  }
388
407
 
389
408
 
390
409
  /**
391
- * Construct a ColorspaceType enum object for the specified value.
410
+ * Returns a ClassType enum object for the specified value.
392
411
  *
393
412
  * No Ruby usage (internal function)
394
413
  *
395
- * @param cs the ColorspaceType
396
- * @return a new ColorspaceType enumerator
414
+ * @param cls the class type
415
+ * @return a new enumerator
397
416
  */
398
417
  VALUE
399
- ColorspaceType_new(ColorspaceType cs)
418
+ ClassType_find(ClassType cls)
400
419
  {
401
- const char *name;
402
-
403
- switch(cs)
404
- {
405
- ENUM_SET_NAME(RGBColorspace)
406
- ENUM_SET_NAME(GRAYColorspace)
407
- ENUM_SET_NAME(TransparentColorspace)
408
- ENUM_SET_NAME(OHTAColorspace)
409
- ENUM_SET_NAME(XYZColorspace)
410
- ENUM_SET_NAME(YCbCrColorspace)
411
- ENUM_SET_NAME(YCCColorspace)
412
- ENUM_SET_NAME(YIQColorspace)
413
- ENUM_SET_NAME(YPbPrColorspace)
414
- ENUM_SET_NAME(YUVColorspace)
415
- ENUM_SET_NAME(CMYKColorspace)
416
- ENUM_SET_NAME(sRGBColorspace)
417
- ENUM_SET_NAME(Rec601YCbCrColorspace)
418
- ENUM_SET_NAME(Rec601LumaColorspace)
419
- ENUM_SET_NAME(Rec709LumaColorspace)
420
- ENUM_SET_NAME(Rec709YCbCrColorspace)
421
- ENUM_SET_NAME(CMYColorspace)
422
- #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
423
- ENUM_SET_NAME(LuvColorspace)
424
- ENUM_SET_NAME(HCLColorspace)
425
- ENUM_SET_NAME(LCHColorspace)
426
- ENUM_SET_NAME(LMSColorspace)
427
- ENUM_SET_NAME(LCHabColorspace)
428
- ENUM_SET_NAME(LCHuvColorspace)
429
- ENUM_SET_NAME(scRGBColorspace)
430
- ENUM_SET_NAME(HSIColorspace)
431
- ENUM_SET_NAME(HSVColorspace)
432
- ENUM_SET_NAME(HCLpColorspace)
433
- ENUM_SET_NAME(YDbDrColorspace)
434
- ENUM_SET_NAME(xyYColorspace)
435
- #endif
436
- default:
437
- ENUM_SET_NAME(UndefinedColorspace)
438
- }
420
+ return Enum_find(Class_ClassType, cls);
421
+ }
439
422
 
440
- return rm_enum_new(Class_ColorspaceType, ID2SYM(rb_intern(name)), INT2FIX(cs));
441
423
 
424
+ /**
425
+ * Returns a ColorspaceType enum object for the specified value.
426
+ *
427
+ * No Ruby usage (internal function)
428
+ *
429
+ * @param cs the ColorspaceType
430
+ * @return a new ColorspaceType enumerator
431
+ */
432
+ VALUE
433
+ ColorspaceType_find(ColorspaceType cs)
434
+ {
435
+ return Enum_find(Class_ColorspaceType, cs);
442
436
  }
443
437
 
444
438
 
@@ -492,7 +486,7 @@ ComplianceType_name(ComplianceType *c)
492
486
 
493
487
 
494
488
  /**
495
- * Construct a ComplianceType enum object for the specified value.
489
+ * Returns a ComplianceType enum object for the specified value.
496
490
  *
497
491
  * No Ruby usage (internal function)
498
492
  *
@@ -500,109 +494,14 @@ ComplianceType_name(ComplianceType *c)
500
494
  * @return the Ruby ComplianceType enum object
501
495
  */
502
496
  VALUE
503
- ComplianceType_new(ComplianceType compliance)
504
- {
505
- const char *name;
506
-
507
- // Turn off undefined bits
508
- compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
509
- name = ComplianceType_name(&compliance);
510
- return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
511
- }
512
-
513
-
514
-
515
- /**
516
- * Return the name of a CompositeOperator enum as a string.
517
- *
518
- * No Ruby usage (internal function)
519
- *
520
- * @param op the CompositeOperator
521
- * @return the name
522
- */
523
- static const char *
524
- CompositeOperator_name(CompositeOperator op)
497
+ ComplianceType_find(ComplianceType compliance)
525
498
  {
526
- switch (op)
527
- {
528
- ENUM_TO_NAME(AddCompositeOp)
529
- ENUM_TO_NAME(AtopCompositeOp)
530
- ENUM_TO_NAME(BlendCompositeOp)
531
- ENUM_TO_NAME(BlurCompositeOp)
532
- ENUM_TO_NAME(BumpmapCompositeOp)
533
- ENUM_TO_NAME(ChangeMaskCompositeOp)
534
- ENUM_TO_NAME(ClearCompositeOp)
535
- ENUM_TO_NAME(ColorBurnCompositeOp)
536
- ENUM_TO_NAME(ColorDodgeCompositeOp)
537
- ENUM_TO_NAME(ColorizeCompositeOp)
538
- ENUM_TO_NAME(CopyBlueCompositeOp)
539
- ENUM_TO_NAME(CopyCompositeOp)
540
- ENUM_TO_NAME(CopyCyanCompositeOp)
541
- ENUM_TO_NAME(CopyMagentaCompositeOp)
542
- ENUM_TO_NAME(CopyYellowCompositeOp)
543
- ENUM_TO_NAME(CopyBlackCompositeOp)
544
- ENUM_TO_NAME(CopyGreenCompositeOp)
545
- ENUM_TO_NAME(CopyOpacityCompositeOp)
546
- ENUM_TO_NAME(CopyRedCompositeOp)
547
- ENUM_TO_NAME(DarkenCompositeOp)
548
- ENUM_TO_NAME(DarkenIntensityCompositeOp)
549
- ENUM_TO_NAME(DistortCompositeOp)
550
- ENUM_TO_NAME(DivideCompositeOp)
551
- ENUM_TO_NAME(DivideSrcCompositeOp)
552
- ENUM_TO_NAME(DstAtopCompositeOp)
553
- ENUM_TO_NAME(DstCompositeOp)
554
- ENUM_TO_NAME(DstInCompositeOp)
555
- ENUM_TO_NAME(DstOutCompositeOp)
556
- ENUM_TO_NAME(DstOverCompositeOp)
557
- ENUM_TO_NAME(DifferenceCompositeOp)
558
- ENUM_TO_NAME(DisplaceCompositeOp)
559
- ENUM_TO_NAME(DissolveCompositeOp)
560
- ENUM_TO_NAME(ExclusionCompositeOp)
561
- ENUM_TO_NAME(HardLightCompositeOp)
562
- #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
563
- ENUM_TO_NAME(HardMixCompositeOp)
564
- #endif
565
- ENUM_TO_NAME(HueCompositeOp)
566
- ENUM_TO_NAME(InCompositeOp)
567
- ENUM_TO_NAME(LightenCompositeOp)
568
- ENUM_TO_NAME(LightenIntensityCompositeOp)
569
- ENUM_TO_NAME(LinearBurnCompositeOp)
570
- ENUM_TO_NAME(LinearDodgeCompositeOp)
571
- ENUM_TO_NAME(LinearLightCompositeOp)
572
- ENUM_TO_NAME(LuminizeCompositeOp)
573
- ENUM_TO_NAME(MathematicsCompositeOp)
574
- ENUM_TO_NAME(MinusCompositeOp)
575
- ENUM_TO_NAME(MinusSrcCompositeOp)
576
- ENUM_TO_NAME(ModulateCompositeOp)
577
- ENUM_TO_NAME(MultiplyCompositeOp)
578
- ENUM_TO_NAME(NoCompositeOp)
579
- ENUM_TO_NAME(OutCompositeOp)
580
- ENUM_TO_NAME(OverCompositeOp)
581
- ENUM_TO_NAME(OverlayCompositeOp)
582
- ENUM_TO_NAME(PegtopLightCompositeOp)
583
- ENUM_TO_NAME(PinLightCompositeOp)
584
- ENUM_TO_NAME(PlusCompositeOp)
585
- ENUM_TO_NAME(ReplaceCompositeOp)
586
- ENUM_TO_NAME(SaturateCompositeOp)
587
- ENUM_TO_NAME(ScreenCompositeOp)
588
- ENUM_TO_NAME(SoftLightCompositeOp)
589
- ENUM_TO_NAME(SrcAtopCompositeOp)
590
- ENUM_TO_NAME(SrcCompositeOp)
591
- ENUM_TO_NAME(SrcInCompositeOp)
592
- ENUM_TO_NAME(SrcOutCompositeOp)
593
- ENUM_TO_NAME(SrcOverCompositeOp)
594
- ENUM_TO_NAME(SubtractCompositeOp)
595
- ENUM_TO_NAME(ThresholdCompositeOp)
596
- ENUM_TO_NAME(VividLightCompositeOp)
597
- ENUM_TO_NAME(XorCompositeOp)
598
- default:
599
- ENUM_TO_NAME(UndefinedCompositeOp)
600
- }
499
+ return Enum_find(Class_ComplianceType, compliance);
601
500
  }
602
501
 
603
502
 
604
503
  /**
605
- * Construct a CompositeOperator enum object for the specified value.
504
+ * Returns a CompositeOperator enum object for the specified value.
606
505
  *
607
506
  * No Ruby usage (internal function)
608
507
  *
@@ -610,55 +509,14 @@ CompositeOperator_name(CompositeOperator op)
610
509
  * @return a new CompositeOperator enumerator
611
510
  */
612
511
  VALUE
613
- CompositeOperator_new(CompositeOperator op)
614
- {
615
- const char *name = CompositeOperator_name(op);
616
- return rm_enum_new(Class_CompositeOperator, ID2SYM(rb_intern(name)), INT2FIX(op));
617
- }
618
-
619
-
620
- /**
621
- * Return the name of a CompressionType enum as a string.
622
- *
623
- * No Ruby usage (internal function)
624
- *
625
- * @param ct the CompressionType
626
- * @return the name
627
- */
628
- static const char *
629
- CompressionType_name(CompressionType ct)
512
+ CompositeOperator_find(CompositeOperator op)
630
513
  {
631
- switch (ct)
632
- {
633
- ENUM_TO_NAME(NoCompression)
634
- ENUM_TO_NAME(B44Compression)
635
- ENUM_TO_NAME(B44ACompression)
636
- ENUM_TO_NAME(BZipCompression)
637
- ENUM_TO_NAME(DXT1Compression)
638
- ENUM_TO_NAME(DXT3Compression)
639
- ENUM_TO_NAME(DXT5Compression)
640
- ENUM_TO_NAME(FaxCompression)
641
- ENUM_TO_NAME(Group4Compression)
642
- ENUM_TO_NAME(JPEGCompression)
643
- ENUM_TO_NAME(JPEG2000Compression)
644
- ENUM_TO_NAME(LosslessJPEGCompression)
645
- ENUM_TO_NAME(LZWCompression)
646
- ENUM_TO_NAME(PizCompression)
647
- ENUM_TO_NAME(Pxr24Compression)
648
- ENUM_TO_NAME(RLECompression)
649
- ENUM_TO_NAME(ZipCompression)
650
- ENUM_TO_NAME(ZipSCompression)
651
- ENUM_TO_NAME(LZMACompression)
652
- ENUM_TO_NAME(JBIG1Compression)
653
- ENUM_TO_NAME(JBIG2Compression)
654
- default:
655
- ENUM_TO_NAME(UndefinedCompression)
656
- }
514
+ return Enum_find(Class_CompositeOperator, op);
657
515
  }
658
516
 
659
517
 
660
518
  /**
661
- * Construct a CompressionType enum object for the specified value.
519
+ * Returns a CompressionType enum object for the specified value.
662
520
  *
663
521
  * No Ruby usage (internal function)
664
522
  *
@@ -666,37 +524,14 @@ CompressionType_name(CompressionType ct)
666
524
  * @return a new CompressionType enumerator
667
525
  */
668
526
  VALUE
669
- CompressionType_new(CompressionType ct)
527
+ CompressionType_find(CompressionType ct)
670
528
  {
671
- const char *name = CompressionType_name(ct);
672
- return rm_enum_new(Class_CompressionType, ID2SYM(rb_intern(name)), INT2FIX(ct));
529
+ return Enum_find(Class_CompressionType, ct);
673
530
  }
674
531
 
675
532
 
676
533
  /**
677
- * Return the name of a DisposeType enum as a string.
678
- *
679
- * No Ruby usage (internal function)
680
- *
681
- * @param type the DisposeType
682
- * @return the name
683
- */
684
- static const char *
685
- DisposeType_name(DisposeType type)
686
- {
687
- switch(type)
688
- {
689
- ENUM_TO_NAME(BackgroundDispose)
690
- ENUM_TO_NAME(NoneDispose)
691
- ENUM_TO_NAME(PreviousDispose)
692
- default:
693
- ENUM_TO_NAME(UndefinedDispose)
694
- }
695
- }
696
-
697
-
698
- /**
699
- * Construct a DisposeType enum object for the specified value..new.
534
+ * Returns a DisposeType enum object for the specified value..new.
700
535
  *
701
536
  * No Ruby usage (internal function)
702
537
  *
@@ -704,36 +539,14 @@ DisposeType_name(DisposeType type)
704
539
  * @return a new DisposeType enumerator
705
540
  */
706
541
  VALUE
707
- DisposeType_new(DisposeType type)
542
+ DisposeType_find(DisposeType type)
708
543
  {
709
- const char *name = DisposeType_name(type);
710
- return rm_enum_new(Class_DisposeType, ID2SYM(rb_intern(name)), INT2FIX(type));
544
+ return Enum_find(Class_DisposeType, type);
711
545
  }
712
546
 
713
547
 
714
548
  /**
715
- * Return the name of a EndianType enum as a string.
716
- *
717
- * No Ruby usage (internal function)
718
- *
719
- * @param type the EndianType
720
- * @return the name
721
- */
722
- static const char *
723
- EndianType_name(EndianType type)
724
- {
725
- switch(type)
726
- {
727
- ENUM_TO_NAME(LSBEndian)
728
- ENUM_TO_NAME(MSBEndian)
729
- default:
730
- ENUM_TO_NAME(UndefinedEndian)
731
- }
732
- }
733
-
734
-
735
- /**
736
- * Construct an EndianType enum object.
549
+ * Returns an EndianType enum object.
737
550
  *
738
551
  * No Ruby usage (internal function)
739
552
  *
@@ -741,112 +554,29 @@ EndianType_name(EndianType type)
741
554
  * @return a new EndianType enumerator
742
555
  */
743
556
  VALUE
744
- EndianType_new(EndianType type)
745
- {
746
- const char *name = EndianType_name(type);
747
- return rm_enum_new(Class_EndianType, ID2SYM(rb_intern(name)), INT2FIX(type));
748
- }
749
-
750
-
751
- /**
752
- * Return the name of a FilterTypes enum as a string.
753
- *
754
- * No Ruby usage (internal function)
755
- *
756
- * @param type the FilterTypes
757
- * @return the name
758
- */
759
- static const char *
760
- FilterTypes_name(FilterTypes type)
557
+ EndianType_find(EndianType type)
761
558
  {
762
- switch(type)
763
- {
764
- ENUM_TO_NAME(PointFilter)
765
- ENUM_TO_NAME(BoxFilter)
766
- ENUM_TO_NAME(TriangleFilter)
767
- ENUM_TO_NAME(HermiteFilter)
768
- ENUM_TO_NAME(HanningFilter)
769
- ENUM_TO_NAME(HammingFilter)
770
- ENUM_TO_NAME(BlackmanFilter)
771
- ENUM_TO_NAME(GaussianFilter)
772
- ENUM_TO_NAME(QuadraticFilter)
773
- ENUM_TO_NAME(CubicFilter)
774
- ENUM_TO_NAME(CatromFilter)
775
- ENUM_TO_NAME(MitchellFilter)
776
- ENUM_TO_NAME(LanczosFilter)
777
- ENUM_TO_NAME(BesselFilter)
778
- ENUM_TO_NAME(SincFilter)
779
- ENUM_TO_NAME(KaiserFilter)
780
- ENUM_TO_NAME(WelshFilter)
781
- ENUM_TO_NAME(ParzenFilter)
782
- ENUM_TO_NAME(LagrangeFilter)
783
- ENUM_TO_NAME(BohmanFilter)
784
- ENUM_TO_NAME(BartlettFilter)
785
- // ENUM_TO_NAME(JincFilter) is alias of BesselFilter
786
- ENUM_TO_NAME(SincFastFilter)
787
- ENUM_TO_NAME(LanczosSharpFilter)
788
- ENUM_TO_NAME(Lanczos2Filter)
789
- ENUM_TO_NAME(Lanczos2SharpFilter)
790
- ENUM_TO_NAME(RobidouxFilter)
791
- ENUM_TO_NAME(RobidouxSharpFilter)
792
- ENUM_TO_NAME(CosineFilter)
793
- ENUM_TO_NAME(SplineFilter)
794
- #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
795
- ENUM_TO_NAME(LanczosRadiusFilter)
796
- #endif
797
- default:
798
- ENUM_TO_NAME(UndefinedFilter)
799
- }
559
+ return Enum_find(Class_EndianType, type);
800
560
  }
801
561
 
802
562
 
803
563
  /**
804
- * Construct an FilterTypes enum object for the specified value.
564
+ * Returns a FilterType enum object for the specified value.
805
565
  *
806
566
  * No Ruby usage (internal function)
807
567
  *
808
- * @param type the FilterTypes
809
- * @return a new FilterTypes enumerator
568
+ * @param type the FilterType
569
+ * @return a new FilterType enumerator
810
570
  */
811
571
  VALUE
812
- FilterTypes_new(FilterTypes type)
813
- {
814
- const char *name = FilterTypes_name(type);
815
- return rm_enum_new(Class_FilterTypes, ID2SYM(rb_intern(name)), INT2FIX(type));
816
- }
817
-
818
-
819
- /**
820
- * Return the name of a GravityType enum as a string.
821
- *
822
- * No Ruby usage (internal function)
823
- *
824
- * @param type the GravityType
825
- * @return the name
826
- */
827
- static const char *
828
- GravityType_name(GravityType type)
572
+ FilterType_find(FilterType type)
829
573
  {
830
- switch(type)
831
- {
832
- ENUM_TO_NAME(NorthWestGravity)
833
- ENUM_TO_NAME(NorthGravity)
834
- ENUM_TO_NAME(NorthEastGravity)
835
- ENUM_TO_NAME(WestGravity)
836
- ENUM_TO_NAME(CenterGravity)
837
- ENUM_TO_NAME(EastGravity)
838
- ENUM_TO_NAME(SouthWestGravity)
839
- ENUM_TO_NAME(SouthGravity)
840
- ENUM_TO_NAME(SouthEastGravity)
841
- ENUM_TO_NAME(StaticGravity)
842
- default:
843
- ENUM_TO_NAME(UndefinedGravity)
844
- }
574
+ return Enum_find(Class_FilterType, type);
845
575
  }
846
576
 
847
577
 
848
578
  /**
849
- * Construct an GravityType enum object for the specified value.
579
+ * Returns a GravityType enum object for the specified value.
850
580
  *
851
581
  * No Ruby usage (internal function)
852
582
  *
@@ -854,96 +584,14 @@ GravityType_name(GravityType type)
854
584
  * @return a new GravityType enumerator
855
585
  */
856
586
  VALUE
857
- GravityType_new(GravityType type)
858
- {
859
- const char *name = GravityType_name(type);
860
- return rm_enum_new(Class_GravityType, ID2SYM(rb_intern(name)), INT2FIX(type));
861
- }
862
-
863
-
864
- /**
865
- * Return the name of a ImageLayerMethod enum as a string.
866
- *
867
- * No Ruby usage (internal function)
868
- *
869
- * @param method the ImageLayerMethod
870
- * @return the name
871
- */
872
- static const char *
873
- ImageLayerMethod_name(ImageLayerMethod method)
587
+ GravityType_find(GravityType type)
874
588
  {
875
- switch(method)
876
- {
877
- ENUM_TO_NAME(CompareAnyLayer)
878
- ENUM_TO_NAME(CompareClearLayer)
879
- ENUM_TO_NAME(CompareOverlayLayer)
880
- ENUM_TO_NAME(OptimizeLayer)
881
- ENUM_TO_NAME(OptimizePlusLayer)
882
- ENUM_TO_NAME(CoalesceLayer)
883
- ENUM_TO_NAME(DisposeLayer)
884
- ENUM_TO_NAME(OptimizeTransLayer)
885
- ENUM_TO_NAME(OptimizeImageLayer)
886
- ENUM_TO_NAME(RemoveDupsLayer)
887
- ENUM_TO_NAME(RemoveZeroLayer)
888
- ENUM_TO_NAME(CompositeLayer)
889
- ENUM_TO_NAME(MergeLayer)
890
- ENUM_TO_NAME(MosaicLayer)
891
- ENUM_TO_NAME(FlattenLayer)
892
- ENUM_TO_NAME(TrimBoundsLayer)
893
- default:
894
- ENUM_TO_NAME(UndefinedLayer)
895
- }
589
+ return Enum_find(Class_GravityType, type);
896
590
  }
897
591
 
898
592
 
899
593
  /**
900
- * Construct an ImageLayerMethod enum object for the specified value.
901
- *
902
- * No Ruby usage (internal function)
903
- *
904
- * @param method the ImageLayerMethod
905
- * @return a new ImageLayerMethod enumerator
906
- */
907
- VALUE
908
- ImageLayerMethod_new(ImageLayerMethod method)
909
- {
910
- const char *name = ImageLayerMethod_name(method);
911
- return rm_enum_new(Class_ImageLayerMethod, ID2SYM(rb_intern(name)), INT2FIX(method));
912
- }
913
-
914
-
915
- /**
916
- * Return the name of a ImageType enum as a string.
917
- *
918
- * No Ruby usage (internal function)
919
- *
920
- * @param type the ImageType
921
- * @return the name
922
- */
923
- static const char *
924
- ImageType_name(ImageType type)
925
- {
926
- switch(type)
927
- {
928
- ENUM_TO_NAME(BilevelType)
929
- ENUM_TO_NAME(GrayscaleType)
930
- ENUM_TO_NAME(GrayscaleMatteType)
931
- ENUM_TO_NAME(PaletteType)
932
- ENUM_TO_NAME(PaletteMatteType)
933
- ENUM_TO_NAME(TrueColorType)
934
- ENUM_TO_NAME(TrueColorMatteType)
935
- ENUM_TO_NAME(ColorSeparationType)
936
- ENUM_TO_NAME(ColorSeparationMatteType)
937
- ENUM_TO_NAME(OptimizeType)
938
- ENUM_TO_NAME(PaletteBilevelMatteType)
939
- default:
940
- ENUM_TO_NAME(UndefinedType)
941
- }
942
- }
943
-
944
-
945
- /**
946
- * Construct an ImageType enum object for the specified value.
594
+ * Returns an ImageType enum object for the specified value.
947
595
  *
948
596
  * No Ruby usage (internal function)
949
597
  *
@@ -951,41 +599,14 @@ ImageType_name(ImageType type)
951
599
  * @return a new ImageType enumerator
952
600
  */
953
601
  VALUE
954
- ImageType_new(ImageType type)
955
- {
956
- const char *name = ImageType_name(type);
957
- return rm_enum_new(Class_ImageType, ID2SYM(rb_intern(name)), INT2FIX(type));
958
- }
959
-
960
-
961
- /**
962
- * Return the name of a InterlaceType enum as a string.
963
- *
964
- * No Ruby usage (internal function)
965
- *
966
- * @param interlace the InterlaceType
967
- * @return the name
968
- */
969
- static const char *
970
- InterlaceType_name(InterlaceType interlace)
602
+ ImageType_find(ImageType type)
971
603
  {
972
- switch(interlace)
973
- {
974
- ENUM_TO_NAME(GIFInterlace)
975
- ENUM_TO_NAME(JPEGInterlace)
976
- ENUM_TO_NAME(PNGInterlace)
977
- ENUM_TO_NAME(NoInterlace)
978
- ENUM_TO_NAME(LineInterlace)
979
- ENUM_TO_NAME(PlaneInterlace)
980
- ENUM_TO_NAME(PartitionInterlace)
981
- default:
982
- ENUM_TO_NAME(UndefinedInterlace)
983
- }
604
+ return Enum_find(Class_ImageType, type);
984
605
  }
985
606
 
986
607
 
987
608
  /**
988
- * Construct an InterlaceType enum object for the specified value.
609
+ * Returns an InterlaceType enum object for the specified value.
989
610
  *
990
611
  * No Ruby usage (internal function)
991
612
  *
@@ -993,90 +614,14 @@ InterlaceType_name(InterlaceType interlace)
993
614
  * @return a new InterlaceType enumerator
994
615
  */
995
616
  VALUE
996
- InterlaceType_new(InterlaceType interlace)
997
- {
998
- const char *name = InterlaceType_name(interlace);
999
- return rm_enum_new(Class_InterlaceType, ID2SYM(rb_intern(name)), INT2FIX(interlace));
1000
- }
1001
-
1002
-
1003
- /**
1004
- * Return the name of a InterpolatePixelMethod enum as a string.
1005
- *
1006
- * No Ruby usage (internal function)
1007
- *
1008
- * @param interpolate the InterpolatePixelMethod
1009
- * @return the name
1010
- */
1011
- static const char *
1012
- InterpolatePixelMethod_name(InterpolatePixelMethod interpolate)
1013
- {
1014
- switch(interpolate)
1015
- {
1016
- ENUM_TO_NAME(AverageInterpolatePixel)
1017
- ENUM_TO_NAME(BicubicInterpolatePixel)
1018
- ENUM_TO_NAME(BilinearInterpolatePixel)
1019
- ENUM_TO_NAME(FilterInterpolatePixel)
1020
- ENUM_TO_NAME(IntegerInterpolatePixel)
1021
- ENUM_TO_NAME(MeshInterpolatePixel)
1022
- ENUM_TO_NAME(NearestNeighborInterpolatePixel)
1023
- ENUM_TO_NAME(SplineInterpolatePixel)
1024
- ENUM_TO_NAME(Average9InterpolatePixel)
1025
- ENUM_TO_NAME(Average16InterpolatePixel)
1026
- ENUM_TO_NAME(BlendInterpolatePixel)
1027
- ENUM_TO_NAME(BackgroundInterpolatePixel)
1028
- ENUM_TO_NAME(CatromInterpolatePixel)
1029
- default:
1030
- ENUM_TO_NAME(UndefinedInterpolatePixel)
1031
- }
1032
- }
1033
-
1034
-
1035
- /**
1036
- * Construct an InterpolatePixelMethod enum object for the specified value.
1037
- *
1038
- * No Ruby usage (internal function)
1039
- *
1040
- * @param interpolate the InterpolatePixelMethod
1041
- * @return a new InterpolatePixelMethod enumerator
1042
- */
1043
- VALUE
1044
- InterpolatePixelMethod_new(InterpolatePixelMethod interpolate)
617
+ InterlaceType_find(InterlaceType interlace)
1045
618
  {
1046
- const char *name = InterpolatePixelMethod_name(interpolate);
1047
- return rm_enum_new(Class_InterpolatePixelMethod, ID2SYM(rb_intern(name)), INT2FIX(interpolate));
619
+ return Enum_find(Class_InterlaceType, interlace);
1048
620
  }
1049
621
 
1050
622
 
1051
623
  /**
1052
- * Return the name of a OrientationType enum as a string.
1053
- *
1054
- * No Ruby usage (internal function)
1055
- *
1056
- * @param type the OreintationType
1057
- * @return the name
1058
- */
1059
- static const char *
1060
- OrientationType_name(OrientationType type)
1061
- {
1062
- switch(type)
1063
- {
1064
- ENUM_TO_NAME(TopLeftOrientation)
1065
- ENUM_TO_NAME(TopRightOrientation)
1066
- ENUM_TO_NAME(BottomRightOrientation)
1067
- ENUM_TO_NAME(BottomLeftOrientation)
1068
- ENUM_TO_NAME(LeftTopOrientation)
1069
- ENUM_TO_NAME(RightTopOrientation)
1070
- ENUM_TO_NAME(RightBottomOrientation)
1071
- ENUM_TO_NAME(LeftBottomOrientation)
1072
- default:
1073
- ENUM_TO_NAME(UndefinedOrientation)
1074
- }
1075
- }
1076
-
1077
-
1078
- /**
1079
- * Construct an OrientationType enum object for the specified value.
624
+ * Returns an OrientationType enum object for the specified value.
1080
625
  *
1081
626
  * No Ruby usage (internal function)
1082
627
  *
@@ -1084,33 +629,24 @@ OrientationType_name(OrientationType type)
1084
629
  * @return a new OrientationType enumerator
1085
630
  */
1086
631
  VALUE
1087
- OrientationType_new(OrientationType type)
632
+ OrientationType_find(OrientationType type)
1088
633
  {
1089
- const char *name = OrientationType_name(type);
1090
- return rm_enum_new(Class_OrientationType, ID2SYM(rb_intern(name)), INT2FIX(type));
634
+ return Enum_find(Class_OrientationType, type);
1091
635
  }
1092
636
 
1093
637
 
1094
638
  /**
1095
- * Return the name of a RenderingIntent enum as a string.
639
+ * Returns a PixelInterpolateMethod enum object for the specified value.
1096
640
  *
1097
641
  * No Ruby usage (internal function)
1098
642
  *
1099
- * @param intent the RenderingIntent
1100
- * @return the name
643
+ * @param interpolate the PixelInterpolateMethod
644
+ * @return a new PixelInterpolateMethod enumerator
1101
645
  */
1102
- static const char *
1103
- RenderingIntent_name(RenderingIntent intent)
646
+ VALUE
647
+ PixelInterpolateMethod_find(PixelInterpolateMethod interpolate)
1104
648
  {
1105
- switch(intent)
1106
- {
1107
- ENUM_TO_NAME(SaturationIntent)
1108
- ENUM_TO_NAME(PerceptualIntent)
1109
- ENUM_TO_NAME(AbsoluteIntent)
1110
- ENUM_TO_NAME(RelativeIntent)
1111
- default:
1112
- ENUM_TO_NAME(UndefinedIntent)
1113
- }
649
+ return Enum_find(Class_PixelInterpolateMethod, interpolate);
1114
650
  }
1115
651
 
1116
652
 
@@ -1123,36 +659,14 @@ RenderingIntent_name(RenderingIntent intent)
1123
659
  * @return a new RenderingIntent enumerator
1124
660
  */
1125
661
  VALUE
1126
- RenderingIntent_new(RenderingIntent intent)
1127
- {
1128
- const char *name = RenderingIntent_name(intent);
1129
- return rm_enum_new(Class_RenderingIntent, ID2SYM(rb_intern(name)), INT2FIX(intent));
1130
- }
1131
-
1132
-
1133
- /**
1134
- * Return the name of a ResolutionType enum as a string.
1135
- *
1136
- * No Ruby usage (internal function)
1137
- *
1138
- * @param type the ResolutionType
1139
- * @return the name
1140
- */
1141
- static const char *
1142
- ResolutionType_name(ResolutionType type)
662
+ RenderingIntent_find(RenderingIntent intent)
1143
663
  {
1144
- switch(type)
1145
- {
1146
- ENUM_TO_NAME(PixelsPerInchResolution)
1147
- ENUM_TO_NAME(PixelsPerCentimeterResolution)
1148
- default:
1149
- ENUM_TO_NAME(UndefinedResolution)
1150
- }
664
+ return Enum_find(Class_RenderingIntent, intent);
1151
665
  }
1152
666
 
1153
667
 
1154
668
  /**
1155
- * Construct an ResolutionType enum object for the specified value.
669
+ * Returns a ResolutionType enum object for the specified value.
1156
670
  *
1157
671
  * No Ruby usage (internal function)
1158
672
  *
@@ -1160,10 +674,9 @@ ResolutionType_name(ResolutionType type)
1160
674
  * @return a new ResolutionType enumerator
1161
675
  */
1162
676
  VALUE
1163
- ResolutionType_new(ResolutionType type)
677
+ ResolutionType_find(ResolutionType type)
1164
678
  {
1165
- const char *name = ResolutionType_name(type);
1166
- return rm_enum_new(Class_ResolutionType, ID2SYM(rb_intern(name)), INT2FIX(type));
679
+ return Enum_find(Class_ResolutionType, type);
1167
680
  }
1168
681
 
1169
682
 
@@ -1178,18 +691,12 @@ ResolutionType_new(ResolutionType type)
1178
691
  const char *
1179
692
  StorageType_name(StorageType type)
1180
693
  {
1181
- switch (type)
694
+ VALUE storage = Enum_find(Class_StorageType, type);
695
+ if (NIL_P(storage))
1182
696
  {
1183
- ENUM_TO_NAME(CharPixel)
1184
- ENUM_TO_NAME(DoublePixel)
1185
- ENUM_TO_NAME(FloatPixel)
1186
- ENUM_TO_NAME(IntegerPixel)
1187
- ENUM_TO_NAME(LongPixel)
1188
- ENUM_TO_NAME(QuantumPixel)
1189
- ENUM_TO_NAME(ShortPixel)
1190
- default:
1191
- ENUM_TO_NAME(UndefinedPixel)
697
+ return "UndefinedPixel";
1192
698
  }
699
+ return rm_enum_to_cstr(storage);
1193
700
  }
1194
701
 
1195
702
 
@@ -1202,28 +709,19 @@ StorageType_name(StorageType type)
1202
709
  * @return the string
1203
710
  */
1204
711
  const char *
1205
- StretchType_name(StretchType stretch)
712
+ StretchType_name(StretchType type)
1206
713
  {
1207
- switch (stretch)
714
+ VALUE stretch = Enum_find(Class_StretchType, type);
715
+ if (NIL_P(stretch))
1208
716
  {
1209
- ENUM_TO_NAME(NormalStretch)
1210
- ENUM_TO_NAME(UltraCondensedStretch)
1211
- ENUM_TO_NAME(ExtraCondensedStretch)
1212
- ENUM_TO_NAME(CondensedStretch)
1213
- ENUM_TO_NAME(SemiCondensedStretch)
1214
- ENUM_TO_NAME(SemiExpandedStretch)
1215
- ENUM_TO_NAME(ExpandedStretch)
1216
- ENUM_TO_NAME(ExtraExpandedStretch)
1217
- ENUM_TO_NAME(UltraExpandedStretch)
1218
- ENUM_TO_NAME(AnyStretch)
1219
- default:
1220
- ENUM_TO_NAME(UndefinedStretch)
717
+ return "UndefinedStretch";
1221
718
  }
719
+ return rm_enum_to_cstr(stretch);
1222
720
  }
1223
721
 
1224
722
 
1225
723
  /**
1226
- * Construct a StretchType enum for a specified StretchType value.
724
+ * Returns a StretchType enum for a specified StretchType value.
1227
725
  *
1228
726
  * No Ruby usage (internal function)
1229
727
  *
@@ -1231,10 +729,9 @@ StretchType_name(StretchType stretch)
1231
729
  * @return a Ruby StretchType enum
1232
730
  */
1233
731
  VALUE
1234
- StretchType_new(StretchType stretch)
732
+ StretchType_find(StretchType stretch)
1235
733
  {
1236
- const char *name = StretchType_name(stretch);
1237
- return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
734
+ return Enum_find(Class_StretchType, stretch);
1238
735
  }
1239
736
 
1240
737
 
@@ -1247,22 +744,19 @@ StretchType_new(StretchType stretch)
1247
744
  * @return the string
1248
745
  */
1249
746
  const char *
1250
- StyleType_name(StyleType style)
747
+ StyleType_name(StyleType type)
1251
748
  {
1252
- switch (style)
749
+ VALUE style = Enum_find(Class_StyleType, type);
750
+ if (NIL_P(style))
1253
751
  {
1254
- ENUM_TO_NAME(NormalStyle)
1255
- ENUM_TO_NAME(ItalicStyle)
1256
- ENUM_TO_NAME(ObliqueStyle)
1257
- ENUM_TO_NAME(AnyStyle)
1258
- default:
1259
- ENUM_TO_NAME(UndefinedStyle)
752
+ return "UndefinedStyle";
1260
753
  }
754
+ return rm_enum_to_cstr(style);
1261
755
  }
1262
756
 
1263
757
 
1264
758
  /**
1265
- * Construct a StyleType enum for a specified StyleType value.
759
+ * Returns a StyleType enum for a specified StyleType value.
1266
760
  *
1267
761
  * No Ruby usage (internal function)
1268
762
  *
@@ -1270,51 +764,14 @@ StyleType_name(StyleType style)
1270
764
  * @return a Ruby StyleType enum
1271
765
  */
1272
766
  VALUE
1273
- StyleType_new(StyleType style)
767
+ StyleType_find(StyleType style)
1274
768
  {
1275
- const char *name = StyleType_name(style);
1276
- return rm_enum_new(Class_StyleType, ID2SYM(rb_intern(name)), INT2FIX(style));
1277
- }
1278
-
1279
-
1280
- /**
1281
- * Return the string representation of a VirtualPixelMethod value.
1282
- *
1283
- * No Ruby usage (internal function)
1284
- *
1285
- * @param method the VirtualPixelMethod
1286
- * @return the name
1287
- */
1288
- static const char *
1289
- VirtualPixelMethod_name(VirtualPixelMethod method)
1290
- {
1291
- switch (method)
1292
- {
1293
- ENUM_TO_NAME(EdgeVirtualPixelMethod)
1294
- ENUM_TO_NAME(MirrorVirtualPixelMethod)
1295
- ENUM_TO_NAME(TileVirtualPixelMethod)
1296
- ENUM_TO_NAME(TransparentVirtualPixelMethod)
1297
- ENUM_TO_NAME(BackgroundVirtualPixelMethod)
1298
- ENUM_TO_NAME(DitherVirtualPixelMethod)
1299
- ENUM_TO_NAME(RandomVirtualPixelMethod)
1300
- ENUM_TO_NAME(ConstantVirtualPixelMethod)
1301
- ENUM_TO_NAME(MaskVirtualPixelMethod)
1302
- ENUM_TO_NAME(BlackVirtualPixelMethod)
1303
- ENUM_TO_NAME(GrayVirtualPixelMethod)
1304
- ENUM_TO_NAME(WhiteVirtualPixelMethod)
1305
- ENUM_TO_NAME(HorizontalTileVirtualPixelMethod)
1306
- ENUM_TO_NAME(VerticalTileVirtualPixelMethod)
1307
- ENUM_TO_NAME(HorizontalTileEdgeVirtualPixelMethod)
1308
- ENUM_TO_NAME(VerticalTileEdgeVirtualPixelMethod)
1309
- ENUM_TO_NAME(CheckerTileVirtualPixelMethod)
1310
- default:
1311
- ENUM_TO_NAME(UndefinedVirtualPixelMethod)
1312
- }
769
+ return Enum_find(Class_StyleType, style);
1313
770
  }
1314
771
 
1315
772
 
1316
773
  /**
1317
- * Construct a VirtualPixelMethod enum for a specified VirtualPixelMethod value.
774
+ * Returns a VirtualPixelMethod enum for a specified VirtualPixelMethod value.
1318
775
  *
1319
776
  * No Ruby usage (internal function)
1320
777
  *
@@ -1322,8 +779,7 @@ VirtualPixelMethod_name(VirtualPixelMethod method)
1322
779
  * @return a new VirtualPixelMethod enumerator
1323
780
  */
1324
781
  VALUE
1325
- VirtualPixelMethod_new(VirtualPixelMethod style)
782
+ VirtualPixelMethod_find(VirtualPixelMethod style)
1326
783
  {
1327
- const char *name = VirtualPixelMethod_name(style);
1328
- return rm_enum_new(Class_VirtualPixelMethod, ID2SYM(rb_intern(name)), INT2FIX(style));
784
+ return Enum_find(Class_VirtualPixelMethod, style);
1329
785
  }