rmagick 2.8.0 → 2.9.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.
- data/ChangeLog +10 -2
- data/README.html +7 -7
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +5 -5
- data/doc/draw.html +131 -20
- data/doc/ex/InitialCoords.rb +1 -1
- data/doc/ex/NewCoordSys.rb +2 -2
- data/doc/ex/OrigCoordSys.rb +1 -1
- data/doc/ex/RotateScale.rb +2 -2
- data/doc/ex/Skew.rb +2 -2
- data/doc/ex/ViewBox.rb +1 -1
- data/doc/ex/arc.rb +4 -2
- data/doc/ex/arcs02.rb +1 -1
- data/doc/ex/bounding_box.rb +3 -0
- data/doc/ex/cbezier1.rb +2 -0
- data/doc/ex/cbezier2.rb +2 -0
- data/doc/ex/cbezier3.rb +2 -0
- data/doc/ex/cbezier4.rb +2 -0
- data/doc/ex/cbezier5.rb +2 -0
- data/doc/ex/cbezier6.rb +2 -0
- data/doc/ex/channel.rb +1 -0
- data/doc/ex/circle.rb +2 -0
- data/doc/ex/cubic01.rb +1 -1
- data/doc/ex/cubic02.rb +1 -1
- data/doc/ex/ellipse.rb +2 -0
- data/doc/ex/font_styles.rb +12 -10
- data/doc/ex/get_type_metrics.rb +2 -0
- data/doc/ex/grav.rb +2 -0
- data/doc/ex/image.rb +1 -1
- data/doc/ex/line.rb +2 -0
- data/doc/ex/opacity.rb +6 -4
- data/doc/ex/path.rb +2 -0
- data/doc/ex/polaroid.rb +2 -0
- data/doc/ex/qbezierpath.rb +3 -0
- data/doc/ex/rectangle.rb +2 -0
- data/doc/ex/rotate.rb +2 -0
- data/doc/ex/roundrect.rb +2 -0
- data/doc/ex/skewx.rb +2 -0
- data/doc/ex/skewy.rb +2 -0
- data/doc/ex/stroke_dasharray.rb +2 -0
- data/doc/ex/stroke_width.rb +2 -0
- data/doc/ex/text.rb +3 -2
- data/doc/ex/text01.rb +1 -1
- data/doc/ex/text_styles.rb +1 -1
- data/doc/ex/text_undercolor.rb +2 -0
- data/doc/ex/translate.rb +3 -1
- data/doc/ilist.html +2 -2
- data/doc/image1.html +2 -2
- data/doc/image2.html +2 -2
- data/doc/image3.html +37 -6
- data/doc/imageattrs.html +2 -2
- data/doc/imusage.html +3 -3
- data/doc/index.html +3 -3
- data/doc/info.html +2 -2
- data/doc/magick.html +2 -2
- data/doc/optequiv.html +24 -2
- data/doc/rvg.html +2 -2
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +2 -2
- data/doc/rvgpattern.html +2 -2
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +2 -2
- data/doc/rvgtut.html +2 -2
- data/doc/rvguse.html +2 -2
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +2 -2
- data/doc/usage.html +6 -4
- data/ext/RMagick/MANIFEST +6 -1
- data/ext/RMagick/extconf.rb +18 -2
- data/ext/RMagick/rmagick.c +312 -0
- data/ext/RMagick/rmagick.h +137 -61
- data/ext/RMagick/rmdraw.c +271 -377
- data/ext/RMagick/rmenum.c +1016 -0
- data/ext/RMagick/rmimage.c +172 -16
- data/ext/RMagick/rminfo.c +5 -5
- data/ext/RMagick/rmmain.c +50 -303
- data/ext/RMagick/rmmontage.c +386 -0
- data/ext/RMagick/rmpixel.c +816 -0
- data/ext/RMagick/rmstruct.c +887 -0
- data/ext/RMagick/rmutil.c +25 -2634
- data/lib/RMagick.rb +46 -2
- data/lib/rvg/misc.rb +5 -4
- data/lib/rvg/stylable.rb +7 -1
- data/rmagick.gemspec +1 -1
- metadata +7 -2
data/ext/RMagick/rmutil.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmutil.c,v 1.
|
1
|
+
/* $Id: rmutil.c,v 1.177 2009/01/01 23:36:00 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmutil.c
|
@@ -9,16 +9,8 @@
|
|
9
9
|
#include "rmagick.h"
|
10
10
|
#include <errno.h>
|
11
11
|
|
12
|
-
static const char *ComplianceType_name(ComplianceType *);
|
13
|
-
static const char *StyleType_name(StyleType);
|
14
|
-
static const char *StretchType_name(StretchType);
|
15
|
-
static void Color_Name_to_PixelPacket(PixelPacket *, VALUE);
|
16
|
-
static VALUE Enum_type_values(VALUE);
|
17
|
-
static VALUE Enum_type_inspect(VALUE);
|
18
12
|
static void handle_exception(ExceptionInfo *, Image *, ErrorRetention);
|
19
|
-
static VALUE Pixel_from_MagickPixelPacket(const MagickPixelPacket *);
|
20
13
|
|
21
|
-
#define ENUMERATORS_CLASS_VAR "@@enumerators"
|
22
14
|
|
23
15
|
/*
|
24
16
|
Extern: magick_safe_malloc, magick_malloc, magick_free, magick_realloc
|
@@ -517,2663 +509,62 @@ rm_cur_image(VALUE img)
|
|
517
509
|
|
518
510
|
|
519
511
|
/*
|
520
|
-
|
521
|
-
Purpose:
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
{
|
526
|
-
PrimaryInfo pi;
|
527
|
-
char buff[100];
|
528
|
-
|
529
|
-
PrimaryInfo_to_PrimaryInfo(&pi, self);
|
530
|
-
sprintf(buff, "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
|
531
|
-
return rb_str_new2(buff);
|
532
|
-
}
|
533
|
-
|
534
|
-
|
535
|
-
/*
|
536
|
-
Method: Magick::Chromaticity#to_s
|
537
|
-
Purpose: Create a string representation of a Magick::Chromaticity
|
538
|
-
*/
|
539
|
-
VALUE
|
540
|
-
ChromaticityInfo_to_s(VALUE self)
|
541
|
-
{
|
542
|
-
ChromaticityInfo ci;
|
543
|
-
char buff[200];
|
544
|
-
|
545
|
-
ChromaticityInfo_to_ChromaticityInfo(&ci, self);
|
546
|
-
sprintf(buff, "red_primary=(x=%g,y=%g) "
|
547
|
-
"green_primary=(x=%g,y=%g) "
|
548
|
-
"blue_primary=(x=%g,y=%g) "
|
549
|
-
"white_point=(x=%g,y=%g) ",
|
550
|
-
ci.red_primary.x, ci.red_primary.y,
|
551
|
-
ci.green_primary.x, ci.green_primary.y,
|
552
|
-
ci.blue_primary.x, ci.blue_primary.y,
|
553
|
-
ci.white_point.x, ci.white_point.y);
|
554
|
-
return rb_str_new2(buff);
|
555
|
-
}
|
556
|
-
|
557
|
-
|
558
|
-
/*
|
559
|
-
Method: Magick::Pixel#to_s
|
560
|
-
Purpose: Create a string representation of a Magick::Pixel
|
561
|
-
*/
|
562
|
-
VALUE
|
563
|
-
Pixel_to_s(VALUE self)
|
564
|
-
{
|
565
|
-
Pixel *pixel;
|
566
|
-
char buff[100];
|
567
|
-
|
568
|
-
Data_Get_Struct(self, Pixel, pixel);
|
569
|
-
sprintf(buff, "red=" QuantumFormat ", green=" QuantumFormat ", blue=" QuantumFormat ", opacity=" QuantumFormat
|
570
|
-
, pixel->red, pixel->green, pixel->blue, pixel->opacity);
|
571
|
-
return rb_str_new2(buff);
|
572
|
-
}
|
573
|
-
|
574
|
-
|
575
|
-
/*
|
576
|
-
Method: Magick::Pixel.from_color(string)
|
577
|
-
Purpose: Construct an Magick::Pixel corresponding to the given color name.
|
578
|
-
Notes: the "inverse" is Image *#to_color, b/c the conversion of a pixel
|
579
|
-
to a color name requires both a color depth and if the opacity
|
580
|
-
value has meaning (i.e. whether image->matte == True or not).
|
581
|
-
|
582
|
-
Also see Magick::Pixel#to_color, below.
|
583
|
-
*/
|
584
|
-
VALUE
|
585
|
-
Pixel_from_color(VALUE class, VALUE name)
|
586
|
-
{
|
587
|
-
PixelPacket pp;
|
588
|
-
ExceptionInfo exception;
|
589
|
-
MagickBooleanType okay;
|
590
|
-
|
591
|
-
class = class; // defeat "never referenced" message from icc
|
592
|
-
|
593
|
-
GetExceptionInfo(&exception);
|
594
|
-
okay = QueryColorDatabase(StringValuePtr(name), &pp, &exception);
|
595
|
-
CHECK_EXCEPTION()
|
596
|
-
(void) DestroyExceptionInfo(&exception);
|
597
|
-
|
598
|
-
if (!okay)
|
599
|
-
{
|
600
|
-
rb_raise(rb_eArgError, "invalid color name: %s", StringValuePtr(name));
|
601
|
-
}
|
602
|
-
|
603
|
-
return Pixel_from_PixelPacket(&pp);
|
604
|
-
}
|
605
|
-
|
606
|
-
|
607
|
-
/*
|
608
|
-
Static: rm_set_magick_pixel_packet
|
609
|
-
Purpose: Convert a PixelPacket to a MagickPixelPacket
|
610
|
-
Notes: Same code as the private function SetMagickPixelPacket
|
611
|
-
in ImageMagick.
|
612
|
-
*/
|
613
|
-
void
|
614
|
-
rm_set_magick_pixel_packet(Pixel *pixel, IndexPacket *index_packet, MagickPixelPacket *pp)
|
615
|
-
{
|
616
|
-
pp->red = (MagickRealType) pixel->red;
|
617
|
-
pp->green = (MagickRealType) pixel->green;
|
618
|
-
pp->blue = (MagickRealType) pixel->blue;
|
619
|
-
pp->opacity = (MagickRealType) (pp->matte ? pixel->opacity : OpaqueOpacity);
|
620
|
-
pp->index = (MagickRealType) ((pp->colorspace == CMYKColorspace) && (index_packet ? *index_packet : 0));
|
621
|
-
}
|
622
|
-
|
623
|
-
|
624
|
-
/*
|
625
|
-
Method: Magick::Pixel#to_color(compliance=AllCompliance, matte=false,
|
626
|
-
depth=QuantumDepth, hex=false)
|
627
|
-
Purpose: return the color name corresponding to the pixel values
|
628
|
-
Notes: the conversion respects the value of the 'opacity' field
|
629
|
-
in the Pixel.
|
512
|
+
Extern: rm_pixelpacket_to_color_name
|
513
|
+
Purpose: Map the color intensity to a named color
|
514
|
+
Returns: the named color as a String
|
515
|
+
Notes: See below for the equivalent function that accepts an Info
|
516
|
+
structure instead of an Image.
|
630
517
|
*/
|
631
518
|
VALUE
|
632
|
-
|
519
|
+
rm_pixelpacket_to_color_name(Image *image, PixelPacket *color)
|
633
520
|
{
|
634
|
-
Info *info;
|
635
|
-
Image *image;
|
636
|
-
Pixel *pixel;
|
637
|
-
MagickPixelPacket mpp;
|
638
|
-
MagickBooleanType hex = MagickFalse;
|
639
521
|
char name[MaxTextExtent];
|
640
522
|
ExceptionInfo exception;
|
641
|
-
ComplianceType compliance = AllCompliance;
|
642
|
-
unsigned int matte = MagickFalse;
|
643
|
-
unsigned int depth = QuantumDepth;
|
644
|
-
|
645
|
-
switch (argc)
|
646
|
-
{
|
647
|
-
case 4:
|
648
|
-
hex = RTEST(argv[3]);
|
649
|
-
case 3:
|
650
|
-
depth = NUM2UINT(argv[2]);
|
651
|
-
|
652
|
-
// Ensure depth is appropriate for the way xMagick was compiled.
|
653
|
-
switch (depth)
|
654
|
-
{
|
655
|
-
case 8:
|
656
|
-
#if QuantumDepth == 16 || QuantumDepth == 32
|
657
|
-
case 16:
|
658
|
-
#endif
|
659
|
-
#if QuantumDepth == 32
|
660
|
-
case 32:
|
661
|
-
#endif
|
662
|
-
break;
|
663
|
-
default:
|
664
|
-
rb_raise(rb_eArgError, "invalid depth (%d)", depth);
|
665
|
-
break;
|
666
|
-
}
|
667
|
-
case 2:
|
668
|
-
matte = RTEST(argv[1]);
|
669
|
-
case 1:
|
670
|
-
VALUE_TO_ENUM(argv[0], compliance, ComplianceType);
|
671
|
-
case 0:
|
672
|
-
break;
|
673
|
-
default:
|
674
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
675
|
-
}
|
676
|
-
|
677
|
-
Data_Get_Struct(self, Pixel, pixel);
|
678
|
-
|
679
|
-
info = CloneImageInfo(NULL);
|
680
|
-
image = AcquireImage(info);
|
681
|
-
image->depth = depth;
|
682
|
-
image->matte = matte;
|
683
|
-
(void) DestroyImageInfo(info);
|
684
|
-
|
685
|
-
GetMagickPixelPacket(image, &mpp);
|
686
|
-
rm_set_magick_pixel_packet(pixel, NULL, &mpp);
|
687
523
|
|
688
524
|
GetExceptionInfo(&exception);
|
689
525
|
|
690
|
-
|
691
|
-
// Support for hex-format color names moved out of QueryMagickColorname
|
692
|
-
// in 6.4.1-9. The 'hex' argument was removed as well.
|
693
|
-
if (hex)
|
694
|
-
{
|
695
|
-
if (compliance == XPMCompliance)
|
696
|
-
{
|
697
|
-
mpp.matte = MagickFalse;
|
698
|
-
mpp.depth = (unsigned long) min(1.0 * image->depth, 16.0);
|
699
|
-
}
|
700
|
-
(void) GetColorTuple(&mpp, MagickTrue, name);
|
701
|
-
}
|
702
|
-
else
|
703
|
-
{
|
704
|
-
(void) QueryMagickColorname(image, &mpp, compliance, name, &exception);
|
705
|
-
}
|
706
|
-
#else
|
707
|
-
(void) QueryMagickColorname(image, &mpp, compliance, hex, name, &exception);
|
708
|
-
#endif
|
709
|
-
(void) DestroyImage(image);
|
526
|
+
(void) QueryColorname(image, color, X11Compliance, name, &exception);
|
710
527
|
CHECK_EXCEPTION()
|
711
528
|
(void) DestroyExceptionInfo(&exception);
|
712
529
|
|
713
|
-
// Always return a string, even if it's ""
|
714
530
|
return rb_str_new2(name);
|
715
531
|
}
|
716
532
|
|
717
533
|
|
718
534
|
/*
|
719
|
-
|
720
|
-
Purpose:
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
Pixel *pixel;
|
727
|
-
double hue, saturation, luminosity;
|
728
|
-
volatile VALUE hsl;
|
729
|
-
|
730
|
-
Data_Get_Struct(self, Pixel, pixel);
|
731
|
-
#if defined(HAVE_CONVERTRGBTOHSL)
|
732
|
-
rb_warning("Pixel#to_HSL is deprecated; use to_hsla");
|
733
|
-
ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &saturation, &luminosity);
|
734
|
-
#else
|
735
|
-
TransformHSL(pixel->red, pixel->green, pixel->blue, &hue, &saturation, &luminosity);
|
736
|
-
#endif
|
737
|
-
|
738
|
-
hsl = rb_ary_new3(3, rb_float_new(hue), rb_float_new(saturation),
|
739
|
-
rb_float_new(luminosity));
|
740
|
-
|
741
|
-
return hsl;
|
742
|
-
}
|
743
|
-
|
744
|
-
|
745
|
-
/*
|
746
|
-
Method: Pixel.from_HSL *** DEPRECATED ***
|
747
|
-
Purpose: Constructs an RGB pixel from the array
|
748
|
-
[hue, saturation, luminosity].
|
749
|
-
*/
|
750
|
-
VALUE
|
751
|
-
Pixel_from_HSL(VALUE class, VALUE hsl)
|
752
|
-
{
|
753
|
-
PixelPacket rgb;
|
754
|
-
double hue, saturation, luminosity;
|
755
|
-
|
756
|
-
class = class; // defeat "never referenced" message from icc
|
757
|
-
memset(&rgb, 0, sizeof(rgb));
|
758
|
-
|
759
|
-
hsl = rb_Array(hsl); // Ensure array
|
760
|
-
if (RARRAY_LEN(hsl) < 3)
|
761
|
-
{
|
762
|
-
rb_raise(rb_eArgError, "array argument must have at least 3 elements");
|
763
|
-
}
|
764
|
-
|
765
|
-
hue = NUM2DBL(rb_ary_entry(hsl, 0));
|
766
|
-
saturation = NUM2DBL(rb_ary_entry(hsl, 1));
|
767
|
-
luminosity = NUM2DBL(rb_ary_entry(hsl, 2));
|
768
|
-
|
769
|
-
#if defined(HAVE_CONVERTHSLTORGB)
|
770
|
-
rb_warning("Pixel#from_HSL is deprecated; use from_hsla");
|
771
|
-
ConvertHSLToRGB(hue, saturation, luminosity,
|
772
|
-
&rgb.red, &rgb.green, &rgb.blue);
|
773
|
-
#else
|
774
|
-
HSLTransform(hue, saturation, luminosity,
|
775
|
-
&rgb.red, &rgb.green, &rgb.blue);
|
776
|
-
#endif
|
777
|
-
return Pixel_from_PixelPacket(&rgb);
|
778
|
-
}
|
779
|
-
|
780
|
-
|
781
|
-
/*
|
782
|
-
Method: Pixel#from_hsla(hue, saturation, lightness, alpha=1)
|
783
|
-
Purpose: Replace brain-dead from_HSL, above.
|
784
|
-
Notes: 0 <= hue < 360, 0 <= saturation <= 1, 0 <= lightness <= 1
|
785
|
-
0 <= alpha <= 1 (0 is transparent, 1 is opaque)
|
786
|
-
*/
|
787
|
-
VALUE
|
788
|
-
Pixel_from_hsla(int argc, VALUE *argv, VALUE class)
|
789
|
-
{
|
790
|
-
double h, s, l, a = 1.0;
|
791
|
-
MagickPixelPacket pp;
|
792
|
-
ExceptionInfo exception;
|
793
|
-
char name[50];
|
794
|
-
MagickBooleanType alpha = MagickFalse;
|
795
|
-
|
796
|
-
class = class; // defeat "unused parameter" message.
|
797
|
-
|
798
|
-
switch (argc)
|
799
|
-
{
|
800
|
-
case 4:
|
801
|
-
a = NUM2DBL(argv[3]);
|
802
|
-
alpha = MagickTrue;
|
803
|
-
case 3:
|
804
|
-
l = NUM2DBL(argv[2]);
|
805
|
-
s = NUM2DBL(argv[1]);
|
806
|
-
h = NUM2DBL(argv[0]);
|
807
|
-
break;
|
808
|
-
default:
|
809
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 3 or 4)", argc);
|
810
|
-
break;
|
811
|
-
}
|
812
|
-
|
813
|
-
if (alpha && (a < 0.0 || a > 1.0))
|
814
|
-
{
|
815
|
-
rb_raise(rb_eRangeError, "alpha %g out of range [0.0, 1.0]", a);
|
816
|
-
}
|
817
|
-
if (l < 0.0 || l > 100.0)
|
818
|
-
{
|
819
|
-
rb_raise(rb_eRangeError, "lightness %g out of range [0.0, 100.0]", l);
|
820
|
-
}
|
821
|
-
if (s < 0.0 || s > 100.0)
|
822
|
-
{
|
823
|
-
rb_raise(rb_eRangeError, "saturation %g out of range [0.0, 100.0]", s);
|
824
|
-
}
|
825
|
-
if (h < 0.0 || h >= 360.0)
|
826
|
-
{
|
827
|
-
rb_raise(rb_eRangeError, "hue %g out of range [0.0, 360.0)", h);
|
828
|
-
}
|
829
|
-
|
830
|
-
memset(name, 0, sizeof(name));
|
831
|
-
if (alpha)
|
832
|
-
{
|
833
|
-
sprintf(name, "hsla(%-2.1f,%-2.1f,%-2.1f,%-2.1f)", h, s, l, a);
|
834
|
-
}
|
835
|
-
else
|
836
|
-
{
|
837
|
-
sprintf(name, "hsl(%-2.1f,%-2.1f,%-2.1f)", h, s, l);
|
838
|
-
}
|
839
|
-
|
840
|
-
GetExceptionInfo(&exception);
|
841
|
-
|
842
|
-
(void) QueryMagickColor(name, &pp, &exception);
|
843
|
-
CHECK_EXCEPTION()
|
844
|
-
|
845
|
-
(void) DestroyExceptionInfo(&exception);
|
846
|
-
|
847
|
-
return Pixel_from_MagickPixelPacket(&pp);
|
848
|
-
}
|
849
|
-
|
850
|
-
|
851
|
-
/*
|
852
|
-
Method: Pixel#to_hsla()
|
853
|
-
Purpose: Replace brain-dead to_HSL, above.
|
854
|
-
Notes: Returns [hue, saturation, lightness, alpha] in the same ranges as from_hsla()
|
855
|
-
*/
|
856
|
-
VALUE
|
857
|
-
Pixel_to_hsla(VALUE self)
|
858
|
-
{
|
859
|
-
double hue, sat, lum, alpha;
|
860
|
-
Pixel *pixel;
|
861
|
-
volatile VALUE hsla;
|
862
|
-
|
863
|
-
Data_Get_Struct(self, Pixel, pixel);
|
864
|
-
|
865
|
-
#if defined(HAVE_CONVERTRGBTOHSL)
|
866
|
-
ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
|
867
|
-
#else
|
868
|
-
TransformHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
|
869
|
-
#endif
|
870
|
-
hue *= 360.0;
|
871
|
-
sat *= 100.0;
|
872
|
-
lum *= 100.0;
|
873
|
-
|
874
|
-
if (pixel->opacity == OpaqueOpacity)
|
875
|
-
{
|
876
|
-
alpha = 1.0;
|
877
|
-
}
|
878
|
-
else if (pixel->opacity == TransparentOpacity)
|
879
|
-
{
|
880
|
-
alpha = 0.0;
|
881
|
-
}
|
882
|
-
else
|
883
|
-
{
|
884
|
-
alpha = ROUND_TO_QUANTUM(QuantumRange - (pixel->opacity / QuantumRange));
|
885
|
-
}
|
886
|
-
|
887
|
-
hsla = rb_ary_new3(4, rb_float_new(hue), rb_float_new(sat), rb_float_new(lum), rb_float_new(alpha));
|
888
|
-
return hsla;
|
889
|
-
}
|
890
|
-
|
891
|
-
|
892
|
-
/*
|
893
|
-
Method: Pixel#eql?
|
894
|
-
Purpose: For use with Hash
|
895
|
-
*/
|
896
|
-
VALUE
|
897
|
-
Pixel_eql_q(VALUE self, VALUE other)
|
898
|
-
{
|
899
|
-
return NUM2INT(Pixel_spaceship(self, other)) == 0 ? Qtrue : Qfalse;
|
900
|
-
}
|
901
|
-
|
535
|
+
Extern: rm_pixelpacket_to_color_name_info
|
536
|
+
Purpose: Map the color intensity to a named color
|
537
|
+
Returns: the named color as a String
|
538
|
+
Notes: Accepts an Info structure instead of an Image (see above).
|
539
|
+
Simply create an Image from the Info, call QueryColorname,
|
540
|
+
and then destroy the Image.
|
541
|
+
If the Info structure is NULL, creates a new one.
|
902
542
|
|
903
|
-
|
904
|
-
|
905
|
-
Purpose: Compare pixel values for equality
|
543
|
+
Note that the default depth is always used, and the matte
|
544
|
+
value is set to False, which means "don't use the alpha channel".
|
906
545
|
*/
|
907
546
|
VALUE
|
908
|
-
|
547
|
+
rm_pixelpacket_to_color_name_info(Info *info, PixelPacket *color)
|
909
548
|
{
|
910
549
|
Image *image;
|
911
|
-
Info *
|
912
|
-
|
913
|
-
Pixel *this, *that;
|
914
|
-
ColorspaceType colorspace = RGBColorspace;
|
915
|
-
double fuzz = 0.0;
|
916
|
-
unsigned int equal;
|
917
|
-
|
918
|
-
switch (argc)
|
919
|
-
{
|
920
|
-
case 3:
|
921
|
-
VALUE_TO_ENUM(argv[2], colorspace, ColorspaceType);
|
922
|
-
case 2:
|
923
|
-
fuzz = NUM2DBL(argv[1]);
|
924
|
-
case 1:
|
925
|
-
// Allow 1 argument
|
926
|
-
break;
|
927
|
-
default:
|
928
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 3)", argc);
|
929
|
-
break;
|
930
|
-
}
|
931
|
-
|
932
|
-
Data_Get_Struct(self, Pixel, this);
|
933
|
-
Data_Get_Struct(argv[0], Pixel, that);
|
934
|
-
|
935
|
-
// The IsColorSimilar function expects to get the
|
936
|
-
// colorspace and fuzz parameters from an Image structure.
|
550
|
+
Info *my_info;
|
551
|
+
volatile VALUE color_name;
|
937
552
|
|
938
|
-
|
939
|
-
if (!info)
|
940
|
-
{
|
941
|
-
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
942
|
-
}
|
553
|
+
my_info = info ? info : CloneImageInfo(NULL);
|
943
554
|
|
944
555
|
image = AcquireImage(info);
|
945
|
-
|
946
|
-
|
947
|
-
(void) DestroyImageInfo(info);
|
948
|
-
|
949
|
-
if (!image)
|
950
|
-
{
|
951
|
-
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
952
|
-
}
|
953
|
-
|
954
|
-
image->colorspace = colorspace;
|
955
|
-
image->fuzz = fuzz;
|
956
|
-
|
957
|
-
equal = IsColorSimilar(image, this, that);
|
556
|
+
image->matte = MagickFalse;
|
557
|
+
color_name = rm_pixelpacket_to_color_name(image, color);
|
958
558
|
(void) DestroyImage(image);
|
959
|
-
|
960
|
-
return equal ? Qtrue : Qfalse;
|
961
|
-
}
|
962
|
-
|
963
|
-
|
964
|
-
/*
|
965
|
-
Method: Pixel#hash
|
966
|
-
Notes: INT2FIX left-shifts 1 bit. Sacrifice 1 bit
|
967
|
-
from the opacity attribute to the FIXNUM_FLAG.
|
968
|
-
*/
|
969
|
-
VALUE
|
970
|
-
Pixel_hash(VALUE self)
|
971
|
-
{
|
972
|
-
Pixel *pixel;
|
973
|
-
unsigned int hash;
|
974
|
-
|
975
|
-
Data_Get_Struct(self, Pixel, pixel);
|
976
|
-
|
977
|
-
hash = ScaleQuantumToChar(pixel->red) << 24;
|
978
|
-
hash += ScaleQuantumToChar(pixel->green) << 16;
|
979
|
-
hash += ScaleQuantumToChar(pixel->blue) << 8;
|
980
|
-
hash += ScaleQuantumToChar(pixel->opacity);
|
981
|
-
hash >>= 1;
|
982
|
-
|
983
|
-
return INT2FIX(hash);
|
984
|
-
|
985
|
-
}
|
986
|
-
|
987
|
-
|
988
|
-
/*
|
989
|
-
Method: Pixel#intensity
|
990
|
-
Purpose: Return the "intensity" of a pixel
|
991
|
-
*/
|
992
|
-
VALUE
|
993
|
-
Pixel_intensity(VALUE self)
|
994
|
-
{
|
995
|
-
Pixel *pixel;
|
996
|
-
Quantum intensity;
|
997
|
-
|
998
|
-
Data_Get_Struct(self, Pixel, pixel);
|
999
|
-
|
1000
|
-
intensity = ROUND_TO_QUANTUM((0.299*pixel->red)
|
1001
|
-
+ (0.587*pixel->green)
|
1002
|
-
+ (0.114*pixel->blue));
|
1003
|
-
|
1004
|
-
return QUANTUM2NUM((unsigned long) intensity);
|
1005
|
-
}
|
1006
|
-
|
1007
|
-
|
1008
|
-
/*
|
1009
|
-
Methods: Pixel RGBA attribute accessors
|
1010
|
-
Purpose: Get/set Pixel attributes
|
1011
|
-
Note: Pixel is Observable. Setters call changed, notify_observers
|
1012
|
-
Note: Setters return their argument values for backward compatibility
|
1013
|
-
to when Pixel was a Struct class.
|
1014
|
-
*/
|
1015
|
-
|
1016
|
-
DEF_ATTR_READER(Pixel, red, int)
|
1017
|
-
DEF_ATTR_READER(Pixel, green, int)
|
1018
|
-
DEF_ATTR_READER(Pixel, blue, int)
|
1019
|
-
DEF_ATTR_READER(Pixel, opacity, int)
|
1020
|
-
DEF_PIXEL_CHANNEL_WRITER(red)
|
1021
|
-
DEF_PIXEL_CHANNEL_WRITER(green)
|
1022
|
-
DEF_PIXEL_CHANNEL_WRITER(blue)
|
1023
|
-
DEF_PIXEL_CHANNEL_WRITER(opacity)
|
1024
|
-
|
1025
|
-
|
1026
|
-
/*
|
1027
|
-
Methods: Pixel CMYK attribute accessors
|
1028
|
-
Purpose: Get/set Pixel attributes
|
1029
|
-
Note: Pixel is Observable. Setters call changed, notify_observers
|
1030
|
-
Note: Setters return their argument values for backward compatibility
|
1031
|
-
to when Pixel was a Struct class.
|
1032
|
-
*/
|
1033
|
-
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(cyan, red)
|
1034
|
-
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(magenta, green)
|
1035
|
-
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(yellow, blue)
|
1036
|
-
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(black, opacity)
|
1037
|
-
|
1038
|
-
|
1039
|
-
/*
|
1040
|
-
Method: Pixel#<=>
|
1041
|
-
Purpose: Support Comparable mixin
|
1042
|
-
*/
|
1043
|
-
VALUE
|
1044
|
-
Pixel_spaceship(VALUE self, VALUE other)
|
1045
|
-
{
|
1046
|
-
Pixel *this, *that;
|
1047
|
-
|
1048
|
-
Data_Get_Struct(self, Pixel, this);
|
1049
|
-
Data_Get_Struct(other, Pixel, that);
|
1050
|
-
|
1051
|
-
if (this->red != that->red)
|
1052
|
-
{
|
1053
|
-
return INT2NUM((this->red - that->red)/abs(this->red - that->red));
|
1054
|
-
}
|
1055
|
-
else if(this->green != that->green)
|
1056
|
-
{
|
1057
|
-
return INT2NUM((this->green - that->green)/abs(this->green - that->green));
|
1058
|
-
}
|
1059
|
-
else if(this->blue != that->blue)
|
1060
|
-
{
|
1061
|
-
return INT2NUM((this->blue - that->blue)/abs(this->blue - that->blue));
|
1062
|
-
}
|
1063
|
-
else if(this->opacity != that->opacity)
|
559
|
+
if (!info)
|
1064
560
|
{
|
1065
|
-
|
1066
|
-
}
|
1067
|
-
|
1068
|
-
// Values are equal, check class.
|
1069
|
-
|
1070
|
-
return rb_funcall(CLASS_OF(self), rb_intern("<=>"), 1, CLASS_OF(other));
|
1071
|
-
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
|
1075
|
-
/*
|
1076
|
-
Static: destroy_Pixel
|
1077
|
-
Purpose: Free the storage associated with a Pixel object
|
1078
|
-
*/
|
1079
|
-
static void
|
1080
|
-
destroy_Pixel(Pixel *pixel)
|
1081
|
-
{
|
1082
|
-
xfree(pixel);
|
1083
|
-
}
|
1084
|
-
|
1085
|
-
|
1086
|
-
/*
|
1087
|
-
Extern: Pixel_alloc
|
1088
|
-
Purpose: Allocate a Pixel object
|
1089
|
-
*/
|
1090
|
-
VALUE
|
1091
|
-
Pixel_alloc(VALUE class)
|
1092
|
-
{
|
1093
|
-
Pixel *pixel;
|
1094
|
-
|
1095
|
-
pixel = ALLOC(Pixel);
|
1096
|
-
memset(pixel, '\0', sizeof(Pixel));
|
1097
|
-
return Data_Wrap_Struct(class, NULL, destroy_Pixel, pixel);
|
1098
|
-
}
|
1099
|
-
|
1100
|
-
|
1101
|
-
/*
|
1102
|
-
Method: Pixel#initialize(red=0,green=0,blue=0,opacity=0)
|
1103
|
-
Notes: For backward compatibility, arguments may be nil.
|
1104
|
-
*/
|
1105
|
-
VALUE
|
1106
|
-
Pixel_initialize(int argc, VALUE *argv, VALUE self)
|
1107
|
-
{
|
1108
|
-
Pixel *pixel;
|
1109
|
-
|
1110
|
-
Data_Get_Struct(self, Pixel, pixel);
|
1111
|
-
|
1112
|
-
switch(argc)
|
1113
|
-
{
|
1114
|
-
case 4:
|
1115
|
-
if (argv[3] != Qnil)
|
1116
|
-
{
|
1117
|
-
pixel->opacity = APP2QUANTUM(argv[3]);
|
1118
|
-
}
|
1119
|
-
case 3:
|
1120
|
-
if (argv[2] != Qnil)
|
1121
|
-
{
|
1122
|
-
pixel->blue = APP2QUANTUM(argv[2]);
|
1123
|
-
}
|
1124
|
-
case 2:
|
1125
|
-
if (argv[1] != Qnil)
|
1126
|
-
{
|
1127
|
-
pixel->green = APP2QUANTUM(argv[1]);
|
1128
|
-
}
|
1129
|
-
case 1:
|
1130
|
-
if (argv[0] != Qnil)
|
1131
|
-
{
|
1132
|
-
pixel->red = APP2QUANTUM(argv[0]);
|
1133
|
-
}
|
1134
|
-
case 0:
|
1135
|
-
break;
|
1136
|
-
default:
|
1137
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 4)", argc);
|
1138
|
-
}
|
1139
|
-
|
1140
|
-
return self;
|
1141
|
-
}
|
1142
|
-
|
1143
|
-
|
1144
|
-
/*
|
1145
|
-
Method: Pixel#===
|
1146
|
-
Purpose: "Case equal" operator for Pixel
|
1147
|
-
*/
|
1148
|
-
|
1149
|
-
VALUE
|
1150
|
-
Pixel_case_eq(VALUE self, VALUE other)
|
1151
|
-
{
|
1152
|
-
Pixel *this, *that;
|
1153
|
-
|
1154
|
-
if (CLASS_OF(self) == CLASS_OF(other))
|
1155
|
-
{
|
1156
|
-
Data_Get_Struct(self, Pixel, this);
|
1157
|
-
Data_Get_Struct(other, Pixel, that);
|
1158
|
-
return (this->red == that->red
|
1159
|
-
&& this->blue == that->blue
|
1160
|
-
&& this->green == that->green
|
1161
|
-
&& this->opacity == that->opacity) ? Qtrue : Qfalse;
|
1162
|
-
}
|
1163
|
-
|
1164
|
-
return Qfalse;
|
1165
|
-
}
|
1166
|
-
|
1167
|
-
|
1168
|
-
VALUE
|
1169
|
-
Pixel_dup(VALUE self)
|
1170
|
-
{
|
1171
|
-
Pixel *pixel;
|
1172
|
-
volatile VALUE dup;
|
1173
|
-
|
1174
|
-
pixel = ALLOC(Pixel);
|
1175
|
-
memset(pixel, '\0', sizeof(Pixel));
|
1176
|
-
dup = Data_Wrap_Struct(CLASS_OF(self), NULL, destroy_Pixel, pixel);
|
1177
|
-
if (rb_obj_tainted(self))
|
1178
|
-
{
|
1179
|
-
(void) rb_obj_taint(dup);
|
1180
|
-
}
|
1181
|
-
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
|
1185
|
-
/*
|
1186
|
-
Method: Pixel#clone
|
1187
|
-
Notes: see dup, init_copy
|
1188
|
-
*/
|
1189
|
-
VALUE
|
1190
|
-
Pixel_clone(VALUE self)
|
1191
|
-
{
|
1192
|
-
volatile VALUE clone;
|
1193
|
-
|
1194
|
-
clone = Pixel_dup(self);
|
1195
|
-
if (OBJ_FROZEN(self))
|
1196
|
-
{
|
1197
|
-
OBJ_FREEZE(clone);
|
1198
|
-
}
|
1199
|
-
|
1200
|
-
return clone;
|
1201
|
-
}
|
1202
|
-
|
1203
|
-
|
1204
|
-
/*
|
1205
|
-
Method: Pixel#initialize_copy
|
1206
|
-
Purpose: initialize clone, dup methods
|
1207
|
-
*/
|
1208
|
-
VALUE
|
1209
|
-
Pixel_init_copy(VALUE self, VALUE orig)
|
1210
|
-
{
|
1211
|
-
Pixel *copy, *original;
|
1212
|
-
|
1213
|
-
Data_Get_Struct(orig, Pixel, original);
|
1214
|
-
Data_Get_Struct(self, Pixel, copy);
|
1215
|
-
|
1216
|
-
*copy = *original;
|
1217
|
-
|
1218
|
-
return self;
|
1219
|
-
}
|
1220
|
-
|
1221
|
-
|
1222
|
-
/*
|
1223
|
-
Method: Magick::Rectangle#to_s
|
1224
|
-
Purpose: Create a string representation of a Magick::Rectangle
|
1225
|
-
*/
|
1226
|
-
VALUE
|
1227
|
-
RectangleInfo_to_s(VALUE self)
|
1228
|
-
{
|
1229
|
-
RectangleInfo rect;
|
1230
|
-
char buff[100];
|
1231
|
-
|
1232
|
-
Rectangle_to_RectangleInfo(&rect, self);
|
1233
|
-
sprintf(buff, "width=%lu, height=%lu, x=%ld, y=%ld"
|
1234
|
-
, rect.width, rect.height, rect.x, rect.y);
|
1235
|
-
return rb_str_new2(buff);
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
|
1239
|
-
/*
|
1240
|
-
Method: Magick::SegmentInfo#to_s
|
1241
|
-
Purpose: Create a string representation of a Magick::Segment
|
1242
|
-
*/
|
1243
|
-
VALUE
|
1244
|
-
SegmentInfo_to_s(VALUE self)
|
1245
|
-
{
|
1246
|
-
SegmentInfo segment;
|
1247
|
-
char buff[100];
|
1248
|
-
|
1249
|
-
Segment_to_SegmentInfo(&segment, self);
|
1250
|
-
sprintf(buff, "x1=%g, y1=%g, x2=%g, y2=%g"
|
1251
|
-
, segment.x1, segment.y1, segment.x2, segment.y2);
|
1252
|
-
return rb_str_new2(buff);
|
1253
|
-
}
|
1254
|
-
|
1255
|
-
|
1256
|
-
/*
|
1257
|
-
Extern: PixelPacket_to_Color_Name
|
1258
|
-
Purpose: Map the color intensity to a named color
|
1259
|
-
Returns: the named color as a String
|
1260
|
-
Notes: See below for the equivalent function that accepts an Info
|
1261
|
-
structure instead of an Image.
|
1262
|
-
*/
|
1263
|
-
VALUE
|
1264
|
-
PixelPacket_to_Color_Name(Image *image, PixelPacket *color)
|
1265
|
-
{
|
1266
|
-
char name[MaxTextExtent];
|
1267
|
-
ExceptionInfo exception;
|
1268
|
-
|
1269
|
-
GetExceptionInfo(&exception);
|
1270
|
-
|
1271
|
-
(void) QueryColorname(image, color, X11Compliance, name, &exception);
|
1272
|
-
CHECK_EXCEPTION()
|
1273
|
-
(void) DestroyExceptionInfo(&exception);
|
1274
|
-
|
1275
|
-
return rb_str_new2(name);
|
1276
|
-
}
|
1277
|
-
|
1278
|
-
|
1279
|
-
/*
|
1280
|
-
Extern: PixelPacket_to_Color_Name_Info
|
1281
|
-
Purpose: Map the color intensity to a named color
|
1282
|
-
Returns: the named color as a String
|
1283
|
-
Notes: Accepts an Info structure instead of an Image (see above).
|
1284
|
-
Simply create an Image from the Info, call QueryColorname,
|
1285
|
-
and then destroy the Image.
|
1286
|
-
If the Info structure is NULL, creates a new one.
|
1287
|
-
|
1288
|
-
Note that the default depth is always used, and the matte
|
1289
|
-
value is set to False, which means "don't use the alpha channel".
|
1290
|
-
*/
|
1291
|
-
VALUE
|
1292
|
-
PixelPacket_to_Color_Name_Info(Info *info, PixelPacket *color)
|
1293
|
-
{
|
1294
|
-
Image *image;
|
1295
|
-
Info *my_info;
|
1296
|
-
volatile VALUE color_name;
|
1297
|
-
|
1298
|
-
my_info = info ? info : CloneImageInfo(NULL);
|
1299
|
-
|
1300
|
-
image = AcquireImage(info);
|
1301
|
-
image->matte = MagickFalse;
|
1302
|
-
color_name = PixelPacket_to_Color_Name(image, color);
|
1303
|
-
(void) DestroyImage(image);
|
1304
|
-
if (!info)
|
1305
|
-
{
|
1306
|
-
(void) DestroyImageInfo(my_info);
|
561
|
+
(void) DestroyImageInfo(my_info);
|
1307
562
|
}
|
1308
563
|
|
1309
564
|
return color_name;
|
1310
565
|
}
|
1311
566
|
|
1312
567
|
|
1313
|
-
/*
|
1314
|
-
Static: Color_Name_to_PixelPacket
|
1315
|
-
Purpose: Convert a color name to a PixelPacket
|
1316
|
-
Raises: ArgumentError
|
1317
|
-
*/
|
1318
|
-
static void
|
1319
|
-
Color_Name_to_PixelPacket(PixelPacket *color, VALUE name_arg)
|
1320
|
-
{
|
1321
|
-
MagickBooleanType okay;
|
1322
|
-
char *name;
|
1323
|
-
ExceptionInfo exception;
|
1324
|
-
|
1325
|
-
GetExceptionInfo(&exception);
|
1326
|
-
name = StringValuePtr(name_arg);
|
1327
|
-
okay = QueryColorDatabase(name, color, &exception);
|
1328
|
-
(void) DestroyExceptionInfo(&exception);
|
1329
|
-
if (!okay)
|
1330
|
-
{
|
1331
|
-
rb_raise(rb_eArgError, "invalid color name %s", name);
|
1332
|
-
}
|
1333
|
-
}
|
1334
|
-
|
1335
|
-
|
1336
|
-
/*
|
1337
|
-
Extern: AffineMatrix_to_AffineMatrix
|
1338
|
-
Purpose: Convert a Magick::AffineMatrix object to a AffineMatrix structure.
|
1339
|
-
Notes: If not initialized, the defaults are [sx,rx,ry,sy,tx,ty] = [1,0,0,1,0,0]
|
1340
|
-
*/
|
1341
|
-
void
|
1342
|
-
AffineMatrix_to_AffineMatrix(AffineMatrix *am, VALUE st)
|
1343
|
-
{
|
1344
|
-
volatile VALUE values, v;
|
1345
|
-
|
1346
|
-
if (CLASS_OF(st) != Class_AffineMatrix)
|
1347
|
-
{
|
1348
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
1349
|
-
rb_class2name(CLASS_OF(st)));
|
1350
|
-
}
|
1351
|
-
values = rb_funcall(st, rm_ID_values, 0);
|
1352
|
-
v = rb_ary_entry(values, 0);
|
1353
|
-
am->sx = v == Qnil ? 1.0 : NUM2DBL(v);
|
1354
|
-
v = rb_ary_entry(values, 1);
|
1355
|
-
am->rx = v == Qnil ? 0.0 : NUM2DBL(v);
|
1356
|
-
v = rb_ary_entry(values, 2);
|
1357
|
-
am->ry = v == Qnil ? 0.0 : NUM2DBL(v);
|
1358
|
-
v = rb_ary_entry(values, 3);
|
1359
|
-
am->sy = v == Qnil ? 1.0 : NUM2DBL(v);
|
1360
|
-
v = rb_ary_entry(values, 4);
|
1361
|
-
am->tx = v == Qnil ? 0.0 : NUM2DBL(v);
|
1362
|
-
v = rb_ary_entry(values, 5);
|
1363
|
-
am->ty = v == Qnil ? 0.0 : NUM2DBL(v);
|
1364
|
-
}
|
1365
|
-
|
1366
|
-
|
1367
|
-
/*
|
1368
|
-
Extern: ClassType_new
|
1369
|
-
Purpose: Construct a ClassType enum object for the specified value
|
1370
|
-
*/
|
1371
|
-
VALUE
|
1372
|
-
ClassType_new(ClassType cls)
|
1373
|
-
{
|
1374
|
-
const char *name;
|
1375
|
-
|
1376
|
-
switch(cls)
|
1377
|
-
{
|
1378
|
-
default:
|
1379
|
-
case UndefinedClass:
|
1380
|
-
name = "UndefineClass";
|
1381
|
-
break;
|
1382
|
-
case DirectClass:
|
1383
|
-
name = "DirectClass";
|
1384
|
-
break;
|
1385
|
-
case PseudoClass:
|
1386
|
-
name = "PseudoClass";
|
1387
|
-
break;
|
1388
|
-
}
|
1389
|
-
|
1390
|
-
return rm_enum_new(Class_ClassType, ID2SYM(rb_intern(name)), INT2FIX(cls));
|
1391
|
-
}
|
1392
|
-
|
1393
|
-
|
1394
|
-
/*
|
1395
|
-
Extern: ColorspaceType_new
|
1396
|
-
Purpose: construct a ColorspaceType enum object for the specified value
|
1397
|
-
*/
|
1398
|
-
VALUE
|
1399
|
-
ColorspaceType_new(ColorspaceType cs)
|
1400
|
-
{
|
1401
|
-
const char *name;
|
1402
|
-
|
1403
|
-
switch(cs)
|
1404
|
-
{
|
1405
|
-
default:
|
1406
|
-
case UndefinedColorspace:
|
1407
|
-
name = "UndefinedColorspace";
|
1408
|
-
break;
|
1409
|
-
case RGBColorspace:
|
1410
|
-
name = "RGBColorspace";
|
1411
|
-
break;
|
1412
|
-
case GRAYColorspace:
|
1413
|
-
name = "GRAYColorspace";
|
1414
|
-
break;
|
1415
|
-
case TransparentColorspace:
|
1416
|
-
name = "TransparentColorspace";
|
1417
|
-
break;
|
1418
|
-
case OHTAColorspace:
|
1419
|
-
name = "OHTAColorspace";
|
1420
|
-
break;
|
1421
|
-
case XYZColorspace:
|
1422
|
-
name = "XYZColorspace";
|
1423
|
-
break;
|
1424
|
-
case YCbCrColorspace:
|
1425
|
-
name = "YCbCrColorspace";
|
1426
|
-
break;
|
1427
|
-
case YCCColorspace:
|
1428
|
-
name = "YCCColorspace";
|
1429
|
-
break;
|
1430
|
-
case YIQColorspace:
|
1431
|
-
name = "YIQColorspace";
|
1432
|
-
break;
|
1433
|
-
case YPbPrColorspace:
|
1434
|
-
name = "YPbPrColorspace";
|
1435
|
-
break;
|
1436
|
-
case YUVColorspace:
|
1437
|
-
name = "YUVColorspace";
|
1438
|
-
break;
|
1439
|
-
case CMYKColorspace:
|
1440
|
-
name = "CMYKColorspace";
|
1441
|
-
break;
|
1442
|
-
case sRGBColorspace:
|
1443
|
-
name = "sRGBColorspace";
|
1444
|
-
break;
|
1445
|
-
case HSLColorspace:
|
1446
|
-
name = "HSLColorspace";
|
1447
|
-
break;
|
1448
|
-
case HWBColorspace:
|
1449
|
-
name = "HWBColorspace";
|
1450
|
-
break;
|
1451
|
-
case HSBColorspace:
|
1452
|
-
name = "HSBColorspace";
|
1453
|
-
break;
|
1454
|
-
case LABColorspace:
|
1455
|
-
name = "LABColorspace";
|
1456
|
-
break;
|
1457
|
-
case Rec601YCbCrColorspace:
|
1458
|
-
name = "Rec601YCbCrColorspace";
|
1459
|
-
break;
|
1460
|
-
case Rec601LumaColorspace:
|
1461
|
-
name = "Rec601LumaColorspace";
|
1462
|
-
break;
|
1463
|
-
case Rec709LumaColorspace:
|
1464
|
-
name = "Rec709LumaColorspace";
|
1465
|
-
break;
|
1466
|
-
case Rec709YCbCrColorspace:
|
1467
|
-
name = "Rec709YCbCrColorspace";
|
1468
|
-
break;
|
1469
|
-
case LogColorspace:
|
1470
|
-
name = "LogColorspace";
|
1471
|
-
break;
|
1472
|
-
#if defined(HAVE_ENUM_CMYCOLORSPACE)
|
1473
|
-
case CMYColorspace:
|
1474
|
-
name = "CMYColorspace";
|
1475
|
-
break;
|
1476
|
-
#endif
|
1477
|
-
}
|
1478
|
-
|
1479
|
-
return rm_enum_new(Class_ColorspaceType, ID2SYM(rb_intern(name)), INT2FIX(cs));
|
1480
|
-
|
1481
|
-
}
|
1482
|
-
|
1483
|
-
|
1484
|
-
/*
|
1485
|
-
* Static: ComplianceType_new
|
1486
|
-
Purpose: construct a ComplianceType enum object for the specified value
|
1487
|
-
*/
|
1488
|
-
static VALUE
|
1489
|
-
ComplianceType_new(ComplianceType compliance)
|
1490
|
-
{
|
1491
|
-
const char *name;
|
1492
|
-
|
1493
|
-
// Turn off undefined bits
|
1494
|
-
compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
|
1495
|
-
name = ComplianceType_name(&compliance);
|
1496
|
-
return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
|
1497
|
-
}
|
1498
|
-
|
1499
|
-
|
1500
|
-
/*
|
1501
|
-
Static: CompositeOperator_new
|
1502
|
-
Purpose: return the name of a CompositeOperator enum as a string
|
1503
|
-
*/
|
1504
|
-
static const char *
|
1505
|
-
CompositeOperator_name(CompositeOperator op)
|
1506
|
-
{
|
1507
|
-
switch (op)
|
1508
|
-
{
|
1509
|
-
ENUM_TO_NAME(UndefinedCompositeOp)
|
1510
|
-
ENUM_TO_NAME(NoCompositeOp)
|
1511
|
-
ENUM_TO_NAME(AddCompositeOp)
|
1512
|
-
ENUM_TO_NAME(AtopCompositeOp)
|
1513
|
-
ENUM_TO_NAME(BumpmapCompositeOp)
|
1514
|
-
#if defined(HAVE_ENUM_CHANGEMASKCOMPOSITEOP)
|
1515
|
-
ENUM_TO_NAME(ChangeMaskCompositeOp)
|
1516
|
-
#endif
|
1517
|
-
ENUM_TO_NAME(ClearCompositeOp)
|
1518
|
-
ENUM_TO_NAME(ColorBurnCompositeOp)
|
1519
|
-
ENUM_TO_NAME(BlendCompositeOp)
|
1520
|
-
ENUM_TO_NAME(ColorDodgeCompositeOp)
|
1521
|
-
ENUM_TO_NAME(ExclusionCompositeOp)
|
1522
|
-
ENUM_TO_NAME(HardLightCompositeOp)
|
1523
|
-
ENUM_TO_NAME(SoftLightCompositeOp)
|
1524
|
-
ENUM_TO_NAME(ColorizeCompositeOp)
|
1525
|
-
ENUM_TO_NAME(CopyBlueCompositeOp)
|
1526
|
-
ENUM_TO_NAME(CopyCompositeOp)
|
1527
|
-
ENUM_TO_NAME(CopyCyanCompositeOp)
|
1528
|
-
ENUM_TO_NAME(CopyMagentaCompositeOp)
|
1529
|
-
ENUM_TO_NAME(CopyYellowCompositeOp)
|
1530
|
-
ENUM_TO_NAME(CopyBlackCompositeOp)
|
1531
|
-
ENUM_TO_NAME(CopyGreenCompositeOp)
|
1532
|
-
ENUM_TO_NAME(CopyOpacityCompositeOp)
|
1533
|
-
ENUM_TO_NAME(CopyRedCompositeOp)
|
1534
|
-
ENUM_TO_NAME(DarkenCompositeOp)
|
1535
|
-
#if defined(HAVE_ENUM_DIVIDECOMPOSITEOP)
|
1536
|
-
ENUM_TO_NAME(DivideCompositeOp)
|
1537
|
-
#endif
|
1538
|
-
ENUM_TO_NAME(DstAtopCompositeOp)
|
1539
|
-
ENUM_TO_NAME(DstCompositeOp)
|
1540
|
-
ENUM_TO_NAME(DstInCompositeOp)
|
1541
|
-
ENUM_TO_NAME(DstOutCompositeOp)
|
1542
|
-
ENUM_TO_NAME(DstOverCompositeOp)
|
1543
|
-
ENUM_TO_NAME(DifferenceCompositeOp)
|
1544
|
-
ENUM_TO_NAME(DisplaceCompositeOp)
|
1545
|
-
ENUM_TO_NAME(DissolveCompositeOp)
|
1546
|
-
ENUM_TO_NAME(HueCompositeOp)
|
1547
|
-
ENUM_TO_NAME(InCompositeOp)
|
1548
|
-
ENUM_TO_NAME(LightenCompositeOp)
|
1549
|
-
#if defined(HAVE_ENUM_LINEARLIGHTCOMPOSITEOP)
|
1550
|
-
ENUM_TO_NAME(LinearLightCompositeOp)
|
1551
|
-
#endif
|
1552
|
-
ENUM_TO_NAME(LuminizeCompositeOp)
|
1553
|
-
ENUM_TO_NAME(MinusCompositeOp)
|
1554
|
-
ENUM_TO_NAME(ModulateCompositeOp)
|
1555
|
-
ENUM_TO_NAME(MultiplyCompositeOp)
|
1556
|
-
ENUM_TO_NAME(OutCompositeOp)
|
1557
|
-
ENUM_TO_NAME(OverCompositeOp)
|
1558
|
-
ENUM_TO_NAME(OverlayCompositeOp)
|
1559
|
-
ENUM_TO_NAME(PlusCompositeOp)
|
1560
|
-
ENUM_TO_NAME(ReplaceCompositeOp)
|
1561
|
-
ENUM_TO_NAME(SaturateCompositeOp)
|
1562
|
-
ENUM_TO_NAME(ScreenCompositeOp)
|
1563
|
-
ENUM_TO_NAME(SrcAtopCompositeOp)
|
1564
|
-
ENUM_TO_NAME(SrcCompositeOp)
|
1565
|
-
ENUM_TO_NAME(SrcInCompositeOp)
|
1566
|
-
ENUM_TO_NAME(SrcOutCompositeOp)
|
1567
|
-
ENUM_TO_NAME(SrcOverCompositeOp)
|
1568
|
-
ENUM_TO_NAME(SubtractCompositeOp)
|
1569
|
-
ENUM_TO_NAME(ThresholdCompositeOp)
|
1570
|
-
ENUM_TO_NAME(XorCompositeOp)
|
1571
|
-
}
|
1572
|
-
|
1573
|
-
return "UndefinedCompositeOp";
|
1574
|
-
}
|
1575
|
-
|
1576
|
-
|
1577
|
-
/*
|
1578
|
-
External: CompositeOperator_new
|
1579
|
-
Purpose: Construct a CompositeOperator enum object for the specified value
|
1580
|
-
*/
|
1581
|
-
VALUE
|
1582
|
-
CompositeOperator_new(CompositeOperator op)
|
1583
|
-
{
|
1584
|
-
const char *name = CompositeOperator_name(op);
|
1585
|
-
return rm_enum_new(Class_CompositeOperator, ID2SYM(rb_intern(name)), INT2FIX(op));
|
1586
|
-
}
|
1587
|
-
|
1588
|
-
|
1589
|
-
/*
|
1590
|
-
Static: CompressionType_name
|
1591
|
-
Purpose: Return the name of a CompressionType enum as a string
|
1592
|
-
*/
|
1593
|
-
static const char *
|
1594
|
-
CompressionType_name(CompressionType ct)
|
1595
|
-
{
|
1596
|
-
switch (ct)
|
1597
|
-
{
|
1598
|
-
ENUM_TO_NAME(UndefinedCompression)
|
1599
|
-
ENUM_TO_NAME(NoCompression)
|
1600
|
-
ENUM_TO_NAME(BZipCompression)
|
1601
|
-
#if defined(HAVE_ENUM_DXT1COMPRESSION)
|
1602
|
-
ENUM_TO_NAME(DXT1Compression)
|
1603
|
-
#endif
|
1604
|
-
#if defined(HAVE_ENUM_DXT3COMPRESSION)
|
1605
|
-
ENUM_TO_NAME(DXT3Compression)
|
1606
|
-
#endif
|
1607
|
-
#if defined(HAVE_ENUM_DXT5COMPRESSION)
|
1608
|
-
ENUM_TO_NAME(DXT5Compression)
|
1609
|
-
#endif
|
1610
|
-
ENUM_TO_NAME(FaxCompression)
|
1611
|
-
ENUM_TO_NAME(Group4Compression)
|
1612
|
-
ENUM_TO_NAME(JPEGCompression)
|
1613
|
-
ENUM_TO_NAME(JPEG2000Compression)
|
1614
|
-
ENUM_TO_NAME(LosslessJPEGCompression)
|
1615
|
-
ENUM_TO_NAME(LZWCompression)
|
1616
|
-
ENUM_TO_NAME(RLECompression)
|
1617
|
-
ENUM_TO_NAME(ZipCompression)
|
1618
|
-
}
|
1619
|
-
|
1620
|
-
return "UndefinedCompression";
|
1621
|
-
}
|
1622
|
-
|
1623
|
-
|
1624
|
-
/*
|
1625
|
-
* External: CompressionType_new
|
1626
|
-
Purpose: Construct a CompressionType enum object for the specified value
|
1627
|
-
*/
|
1628
|
-
VALUE
|
1629
|
-
CompressionType_new(CompressionType ct)
|
1630
|
-
{
|
1631
|
-
const char *name = CompressionType_name(ct);
|
1632
|
-
return rm_enum_new(Class_CompressionType, ID2SYM(rb_intern(name)), INT2FIX(ct));
|
1633
|
-
}
|
1634
|
-
|
1635
|
-
|
1636
|
-
/*
|
1637
|
-
Static: DisposeType_name
|
1638
|
-
Purpose: Return the name of a DisposeType enum as a string
|
1639
|
-
*/
|
1640
|
-
static const char *
|
1641
|
-
DisposeType_name(DisposeType type)
|
1642
|
-
{
|
1643
|
-
switch(type)
|
1644
|
-
{
|
1645
|
-
ENUM_TO_NAME(UndefinedDispose)
|
1646
|
-
ENUM_TO_NAME(BackgroundDispose)
|
1647
|
-
ENUM_TO_NAME(NoneDispose)
|
1648
|
-
ENUM_TO_NAME(PreviousDispose)
|
1649
|
-
}
|
1650
|
-
|
1651
|
-
return "UndefinedDispose";
|
1652
|
-
}
|
1653
|
-
|
1654
|
-
|
1655
|
-
/*
|
1656
|
-
External: DisposeType.new
|
1657
|
-
Purpose: Construct a DisposeType enum object for the specified value..new
|
1658
|
-
*/
|
1659
|
-
VALUE
|
1660
|
-
DisposeType_new(DisposeType type)
|
1661
|
-
{
|
1662
|
-
const char *name = DisposeType_name(type);
|
1663
|
-
return rm_enum_new(Class_DisposeType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
1664
|
-
}
|
1665
|
-
|
1666
|
-
|
1667
|
-
/*
|
1668
|
-
Static: FilterTypes_name
|
1669
|
-
Purpose: Return the name of a FilterTypes enum as a string
|
1670
|
-
*/
|
1671
|
-
static const char *
|
1672
|
-
FilterTypes_name(FilterTypes type)
|
1673
|
-
{
|
1674
|
-
switch(type)
|
1675
|
-
{
|
1676
|
-
ENUM_TO_NAME(UndefinedFilter)
|
1677
|
-
ENUM_TO_NAME(PointFilter)
|
1678
|
-
ENUM_TO_NAME(BoxFilter)
|
1679
|
-
ENUM_TO_NAME(TriangleFilter)
|
1680
|
-
ENUM_TO_NAME(HermiteFilter)
|
1681
|
-
ENUM_TO_NAME(HanningFilter)
|
1682
|
-
ENUM_TO_NAME(HammingFilter)
|
1683
|
-
ENUM_TO_NAME(BlackmanFilter)
|
1684
|
-
ENUM_TO_NAME(GaussianFilter)
|
1685
|
-
ENUM_TO_NAME(QuadraticFilter)
|
1686
|
-
ENUM_TO_NAME(CubicFilter)
|
1687
|
-
ENUM_TO_NAME(CatromFilter)
|
1688
|
-
ENUM_TO_NAME(MitchellFilter)
|
1689
|
-
ENUM_TO_NAME(LanczosFilter)
|
1690
|
-
ENUM_TO_NAME(BesselFilter)
|
1691
|
-
ENUM_TO_NAME(SincFilter)
|
1692
|
-
#if defined(HAVE_ENUM_KAISERFILTER)
|
1693
|
-
ENUM_TO_NAME(KaiserFilter)
|
1694
|
-
#endif
|
1695
|
-
#if defined(HAVE_ENUM_WELSHFILTER)
|
1696
|
-
ENUM_TO_NAME(WelshFilter)
|
1697
|
-
#endif
|
1698
|
-
#if defined(HAVE_ENUM_PARZENFILTER)
|
1699
|
-
ENUM_TO_NAME(ParzenFilter)
|
1700
|
-
#endif
|
1701
|
-
#if defined(HAVE_ENUM_LAGRANGEFILTER)
|
1702
|
-
ENUM_TO_NAME(LagrangeFilter)
|
1703
|
-
#endif
|
1704
|
-
#if defined(HAVE_ENUM_BOHMANFILTER)
|
1705
|
-
ENUM_TO_NAME(BohmanFilter)
|
1706
|
-
#endif
|
1707
|
-
#if defined(HAVE_ENUM_BARTLETTFILTER)
|
1708
|
-
ENUM_TO_NAME(BartlettFilter)
|
1709
|
-
#endif
|
1710
|
-
#if defined(HAVE_ENUM_SENTINELFILTER)
|
1711
|
-
// not a real filter name - defeat gcc warning message
|
1712
|
-
case SentinelFilter:
|
1713
|
-
break;
|
1714
|
-
#endif
|
1715
|
-
}
|
1716
|
-
|
1717
|
-
return "UndefinedFilter";
|
1718
|
-
}
|
1719
|
-
|
1720
|
-
|
1721
|
-
/*
|
1722
|
-
External: FilterTypes.new
|
1723
|
-
Purpose: Construct an FilterTypes enum object for the specified value
|
1724
|
-
*/
|
1725
|
-
VALUE
|
1726
|
-
FilterTypes_new(FilterTypes type)
|
1727
|
-
{
|
1728
|
-
const char *name = FilterTypes_name(type);
|
1729
|
-
return rm_enum_new(Class_FilterTypes, ID2SYM(rb_intern(name)), INT2FIX(type));
|
1730
|
-
}
|
1731
|
-
|
1732
|
-
|
1733
|
-
/*
|
1734
|
-
Static: EndianType_name
|
1735
|
-
Purpose: Return the name of a EndianType enum as a string
|
1736
|
-
*/
|
1737
|
-
static const char *
|
1738
|
-
EndianType_name(EndianType type)
|
1739
|
-
{
|
1740
|
-
switch(type)
|
1741
|
-
{
|
1742
|
-
ENUM_TO_NAME(UndefinedEndian)
|
1743
|
-
ENUM_TO_NAME(LSBEndian)
|
1744
|
-
ENUM_TO_NAME(MSBEndian)
|
1745
|
-
}
|
1746
|
-
return "UndefinedEndian";
|
1747
|
-
}
|
1748
|
-
|
1749
|
-
|
1750
|
-
/*
|
1751
|
-
External: EndianType.new
|
1752
|
-
Purpose: Construct an EndianType enum object
|
1753
|
-
*/
|
1754
|
-
VALUE
|
1755
|
-
EndianType_new(EndianType type)
|
1756
|
-
{
|
1757
|
-
const char *name = EndianType_name(type);
|
1758
|
-
return rm_enum_new(Class_EndianType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
1759
|
-
}
|
1760
|
-
|
1761
|
-
|
1762
|
-
/*
|
1763
|
-
Static: GravityType_name
|
1764
|
-
Purpose: Return the name of a GravityType enum as a string
|
1765
|
-
*/
|
1766
|
-
static const char *
|
1767
|
-
GravityType_name(GravityType type)
|
1768
|
-
{
|
1769
|
-
switch(type)
|
1770
|
-
{
|
1771
|
-
ENUM_TO_NAME(ForgetGravity)
|
1772
|
-
ENUM_TO_NAME(NorthWestGravity)
|
1773
|
-
ENUM_TO_NAME(NorthGravity)
|
1774
|
-
ENUM_TO_NAME(NorthEastGravity)
|
1775
|
-
ENUM_TO_NAME(WestGravity)
|
1776
|
-
ENUM_TO_NAME(CenterGravity)
|
1777
|
-
ENUM_TO_NAME(EastGravity)
|
1778
|
-
ENUM_TO_NAME(SouthWestGravity)
|
1779
|
-
ENUM_TO_NAME(SouthGravity)
|
1780
|
-
ENUM_TO_NAME(SouthEastGravity)
|
1781
|
-
ENUM_TO_NAME(StaticGravity)
|
1782
|
-
}
|
1783
|
-
|
1784
|
-
// Defeat "duplicate case value" error.
|
1785
|
-
return "UndefinedGravity";
|
1786
|
-
}
|
1787
|
-
|
1788
|
-
|
1789
|
-
/*
|
1790
|
-
External: GravityType.new
|
1791
|
-
Purpose: Construct an GravityType enum object for the specified value
|
1792
|
-
*/
|
1793
|
-
VALUE
|
1794
|
-
GravityType_new(GravityType type)
|
1795
|
-
{
|
1796
|
-
const char *name = GravityType_name(type);
|
1797
|
-
return rm_enum_new(Class_GravityType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
1798
|
-
}
|
1799
|
-
|
1800
|
-
|
1801
|
-
/*
|
1802
|
-
Static: ImageType_name
|
1803
|
-
Purpose: Return the name of a ImageType enum as a string
|
1804
|
-
*/
|
1805
|
-
static const char *
|
1806
|
-
ImageType_name(ImageType type)
|
1807
|
-
{
|
1808
|
-
switch(type)
|
1809
|
-
{
|
1810
|
-
ENUM_TO_NAME(UndefinedType)
|
1811
|
-
ENUM_TO_NAME(BilevelType)
|
1812
|
-
ENUM_TO_NAME(GrayscaleType)
|
1813
|
-
ENUM_TO_NAME(GrayscaleMatteType)
|
1814
|
-
ENUM_TO_NAME(PaletteType)
|
1815
|
-
ENUM_TO_NAME(PaletteMatteType)
|
1816
|
-
ENUM_TO_NAME(TrueColorType)
|
1817
|
-
ENUM_TO_NAME(TrueColorMatteType)
|
1818
|
-
ENUM_TO_NAME(ColorSeparationType)
|
1819
|
-
ENUM_TO_NAME(ColorSeparationMatteType)
|
1820
|
-
ENUM_TO_NAME(OptimizeType)
|
1821
|
-
ENUM_TO_NAME(PaletteBilevelMatteType)
|
1822
|
-
}
|
1823
|
-
|
1824
|
-
return "UndefinedType";
|
1825
|
-
}
|
1826
|
-
|
1827
|
-
|
1828
|
-
/*
|
1829
|
-
External: ImageType.new
|
1830
|
-
Purpose: Construct an ImageType enum object for the specified value
|
1831
|
-
*/
|
1832
|
-
VALUE
|
1833
|
-
ImageType_new(ImageType type)
|
1834
|
-
{
|
1835
|
-
const char *name = ImageType_name(type);
|
1836
|
-
return rm_enum_new(Class_ImageType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
1837
|
-
}
|
1838
|
-
|
1839
|
-
|
1840
|
-
/*
|
1841
|
-
Static: InterlaceType_name
|
1842
|
-
Purpose: Return the name of a InterlaceType enum as a string
|
1843
|
-
*/
|
1844
|
-
static const char *
|
1845
|
-
InterlaceType_name(InterlaceType interlace)
|
1846
|
-
{
|
1847
|
-
switch(interlace)
|
1848
|
-
{
|
1849
|
-
ENUM_TO_NAME(UndefinedInterlace)
|
1850
|
-
#if defined(HAVE_ENUM_GIFINTERLACE)
|
1851
|
-
ENUM_TO_NAME(GIFInterlace)
|
1852
|
-
#endif
|
1853
|
-
#if defined(HAVE_ENUM_JPEGINTERLACE)
|
1854
|
-
ENUM_TO_NAME(JPEGInterlace)
|
1855
|
-
#endif
|
1856
|
-
#if defined(HAVE_ENUM_PNGINTERLACE)
|
1857
|
-
ENUM_TO_NAME(PNGInterlace)
|
1858
|
-
#endif
|
1859
|
-
ENUM_TO_NAME(NoInterlace)
|
1860
|
-
ENUM_TO_NAME(LineInterlace)
|
1861
|
-
ENUM_TO_NAME(PlaneInterlace)
|
1862
|
-
ENUM_TO_NAME(PartitionInterlace)
|
1863
|
-
}
|
1864
|
-
|
1865
|
-
return "UndefinedInterlace";
|
1866
|
-
}
|
1867
|
-
|
1868
|
-
|
1869
|
-
/*
|
1870
|
-
External: InterlaceType_new
|
1871
|
-
Purpose: Construct an InterlaceType enum object for the specified value.
|
1872
|
-
*/
|
1873
|
-
VALUE
|
1874
|
-
InterlaceType_new(InterlaceType interlace)
|
1875
|
-
{
|
1876
|
-
const char *name = InterlaceType_name(interlace);
|
1877
|
-
return rm_enum_new(Class_InterlaceType, ID2SYM(rb_intern(name)), INT2FIX(interlace));
|
1878
|
-
}
|
1879
|
-
|
1880
|
-
|
1881
|
-
/*
|
1882
|
-
Static: InterpolatePixelMethod_name
|
1883
|
-
Purpose: Return the name of a InterpolatePixelMethod enum as a string
|
1884
|
-
*/
|
1885
|
-
static const char *
|
1886
|
-
InterpolatePixelMethod_name(InterpolatePixelMethod interpolate)
|
1887
|
-
{
|
1888
|
-
switch(interpolate)
|
1889
|
-
{
|
1890
|
-
ENUM_TO_NAME(UndefinedInterpolatePixel)
|
1891
|
-
ENUM_TO_NAME(AverageInterpolatePixel)
|
1892
|
-
ENUM_TO_NAME(BicubicInterpolatePixel)
|
1893
|
-
ENUM_TO_NAME(BilinearInterpolatePixel)
|
1894
|
-
ENUM_TO_NAME(FilterInterpolatePixel)
|
1895
|
-
ENUM_TO_NAME(IntegerInterpolatePixel)
|
1896
|
-
ENUM_TO_NAME(MeshInterpolatePixel)
|
1897
|
-
ENUM_TO_NAME(NearestNeighborInterpolatePixel)
|
1898
|
-
#if defined(HAVE_ENUM_SPLINEINTERPOLATEPIXEL)
|
1899
|
-
ENUM_TO_NAME(SplineInterpolatePixel)
|
1900
|
-
#endif
|
1901
|
-
}
|
1902
|
-
|
1903
|
-
return "UndefinedInterpolatePixel";
|
1904
|
-
}
|
1905
|
-
|
1906
|
-
|
1907
|
-
/*
|
1908
|
-
External: InterpolatePixelMethod_new
|
1909
|
-
Purpose: Construct an InterpolatePixelMethod enum object for the specified value.
|
1910
|
-
*/
|
1911
|
-
VALUE
|
1912
|
-
InterpolatePixelMethod_new(InterpolatePixelMethod interpolate)
|
1913
|
-
{
|
1914
|
-
const char *name = InterpolatePixelMethod_name(interpolate);
|
1915
|
-
return rm_enum_new(Class_InterpolatePixelMethod, ID2SYM(rb_intern(name)), INT2FIX(interpolate));
|
1916
|
-
}
|
1917
|
-
|
1918
|
-
|
1919
|
-
/*
|
1920
|
-
External: MagickLayerMethod_new
|
1921
|
-
Purpose: Construct an MagickLayerMethod enum object for the specified value.
|
1922
|
-
*/
|
1923
|
-
static const char *
|
1924
|
-
LAYERMETHODTYPE_NAME(LAYERMETHODTYPE method)
|
1925
|
-
{
|
1926
|
-
switch(method)
|
1927
|
-
{
|
1928
|
-
ENUM_TO_NAME(UndefinedLayer)
|
1929
|
-
ENUM_TO_NAME(CompareAnyLayer)
|
1930
|
-
ENUM_TO_NAME(CompareClearLayer)
|
1931
|
-
ENUM_TO_NAME(CompareOverlayLayer)
|
1932
|
-
ENUM_TO_NAME(OptimizeLayer)
|
1933
|
-
ENUM_TO_NAME(OptimizePlusLayer)
|
1934
|
-
ENUM_TO_NAME(CoalesceLayer)
|
1935
|
-
ENUM_TO_NAME(DisposeLayer)
|
1936
|
-
#if defined(HAVE_ENUM_OPTIMIZETRANSLAYER)
|
1937
|
-
ENUM_TO_NAME(OptimizeTransLayer)
|
1938
|
-
#endif
|
1939
|
-
#if defined(HAVE_ENUM_OPTIMIZEIMAGELAYER)
|
1940
|
-
ENUM_TO_NAME(OptimizeImageLayer)
|
1941
|
-
#endif
|
1942
|
-
#if defined(HAVE_ENUM_REMOVEDUPSLAYER)
|
1943
|
-
ENUM_TO_NAME(RemoveDupsLayer)
|
1944
|
-
#endif
|
1945
|
-
#if defined(HAVE_ENUM_REMOVEZEROLAYER)
|
1946
|
-
ENUM_TO_NAME(RemoveZeroLayer)
|
1947
|
-
#endif
|
1948
|
-
#if defined(HAVE_ENUM_COMPOSITELAYER)
|
1949
|
-
ENUM_TO_NAME(CompositeLayer)
|
1950
|
-
#endif
|
1951
|
-
#if defined(HAVE_ENUM_MERGELAYER)
|
1952
|
-
ENUM_TO_NAME(MergeLayer)
|
1953
|
-
#endif
|
1954
|
-
#if defined(HAVE_ENUM_MOSAICLAYER)
|
1955
|
-
ENUM_TO_NAME(MosaicLayer)
|
1956
|
-
#endif
|
1957
|
-
#if defined(HAVE_ENUM_FLATTENLAYER)
|
1958
|
-
ENUM_TO_NAME(FlattenLayer)
|
1959
|
-
#endif
|
1960
|
-
#if defined(HAVE_ENUM_TRIMBOUNDSLAYER)
|
1961
|
-
ENUM_TO_NAME(TrimBoundsLayer)
|
1962
|
-
#endif
|
1963
|
-
}
|
1964
|
-
|
1965
|
-
return "UndefinedLayer";
|
1966
|
-
}
|
1967
|
-
|
1968
|
-
|
1969
|
-
VALUE
|
1970
|
-
LAYERMETHODTYPE_NEW(LAYERMETHODTYPE method)
|
1971
|
-
{
|
1972
|
-
const char *name = LAYERMETHODTYPE_NAME(method);
|
1973
|
-
return rm_enum_new(CLASS_LAYERMETHODTYPE, ID2SYM(rb_intern(name)), INT2FIX(method));
|
1974
|
-
}
|
1975
|
-
|
1976
|
-
|
1977
|
-
/*
|
1978
|
-
Static: RenderingIntent_name
|
1979
|
-
Purpose: Return the name of a RenderingIntent enum as a string
|
1980
|
-
*/
|
1981
|
-
static const char *
|
1982
|
-
RenderingIntent_name(RenderingIntent intent)
|
1983
|
-
{
|
1984
|
-
switch(intent)
|
1985
|
-
{
|
1986
|
-
ENUM_TO_NAME(UndefinedIntent)
|
1987
|
-
ENUM_TO_NAME(SaturationIntent)
|
1988
|
-
ENUM_TO_NAME(PerceptualIntent)
|
1989
|
-
ENUM_TO_NAME(AbsoluteIntent)
|
1990
|
-
ENUM_TO_NAME(RelativeIntent)
|
1991
|
-
}
|
1992
|
-
|
1993
|
-
return "UndefinedIntent";
|
1994
|
-
}
|
1995
|
-
|
1996
|
-
|
1997
|
-
/*
|
1998
|
-
External: RenderingIntent_new
|
1999
|
-
Purpose: Construct an RenderingIntent enum object for the specified value.
|
2000
|
-
*/
|
2001
|
-
VALUE
|
2002
|
-
RenderingIntent_new(RenderingIntent intent)
|
2003
|
-
{
|
2004
|
-
const char *name = RenderingIntent_name(intent);
|
2005
|
-
return rm_enum_new(Class_RenderingIntent, ID2SYM(rb_intern(name)), INT2FIX(intent));
|
2006
|
-
}
|
2007
|
-
|
2008
|
-
|
2009
|
-
/*
|
2010
|
-
Static: ResolutionType_name
|
2011
|
-
Purpose: Return the name of a ResolutionType enum as a string
|
2012
|
-
*/
|
2013
|
-
static const char *
|
2014
|
-
ResolutionType_name(ResolutionType type)
|
2015
|
-
{
|
2016
|
-
switch(type)
|
2017
|
-
{
|
2018
|
-
ENUM_TO_NAME(UndefinedResolution)
|
2019
|
-
ENUM_TO_NAME(PixelsPerInchResolution)
|
2020
|
-
ENUM_TO_NAME(PixelsPerCentimeterResolution)
|
2021
|
-
}
|
2022
|
-
|
2023
|
-
return "UndefinedResolution";
|
2024
|
-
}
|
2025
|
-
|
2026
|
-
|
2027
|
-
/*
|
2028
|
-
External: ResolutionType_new
|
2029
|
-
Purpose: Construct an ResolutionType enum object for the specified value.
|
2030
|
-
*/
|
2031
|
-
VALUE
|
2032
|
-
ResolutionType_new(ResolutionType type)
|
2033
|
-
{
|
2034
|
-
const char *name = ResolutionType_name(type);
|
2035
|
-
return rm_enum_new(Class_ResolutionType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
2036
|
-
}
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
/*
|
2041
|
-
Static: OrientationType_name
|
2042
|
-
Purpose: Return the name of a OrientationType enum as a string
|
2043
|
-
*/
|
2044
|
-
static const char *
|
2045
|
-
OrientationType_name(OrientationType type)
|
2046
|
-
{
|
2047
|
-
switch(type)
|
2048
|
-
{
|
2049
|
-
ENUM_TO_NAME(UndefinedOrientation)
|
2050
|
-
ENUM_TO_NAME(TopLeftOrientation)
|
2051
|
-
ENUM_TO_NAME(TopRightOrientation)
|
2052
|
-
ENUM_TO_NAME(BottomRightOrientation)
|
2053
|
-
ENUM_TO_NAME(BottomLeftOrientation)
|
2054
|
-
ENUM_TO_NAME(LeftTopOrientation)
|
2055
|
-
ENUM_TO_NAME(RightTopOrientation)
|
2056
|
-
ENUM_TO_NAME(RightBottomOrientation)
|
2057
|
-
ENUM_TO_NAME(LeftBottomOrientation)
|
2058
|
-
}
|
2059
|
-
|
2060
|
-
return "UndefinedOrientation";
|
2061
|
-
}
|
2062
|
-
|
2063
|
-
|
2064
|
-
/*
|
2065
|
-
External: OrientationType_new
|
2066
|
-
Purpose: Construct an OrientationType enum object for the specified value.
|
2067
|
-
*/
|
2068
|
-
VALUE
|
2069
|
-
OrientationType_new(OrientationType type)
|
2070
|
-
{
|
2071
|
-
const char *name = OrientationType_name(type);
|
2072
|
-
return rm_enum_new(Class_OrientationType, ID2SYM(rb_intern(name)), INT2FIX(type));
|
2073
|
-
}
|
2074
|
-
|
2075
|
-
|
2076
|
-
/*
|
2077
|
-
External: Color_from_ColorInfo
|
2078
|
-
Purpose: Convert a ColorInfo structure to a Magick::Color
|
2079
|
-
*/
|
2080
|
-
VALUE
|
2081
|
-
Color_from_ColorInfo(const ColorInfo *ci)
|
2082
|
-
{
|
2083
|
-
ComplianceType compliance_type;
|
2084
|
-
volatile VALUE name;
|
2085
|
-
volatile VALUE compliance;
|
2086
|
-
volatile VALUE color;
|
2087
|
-
|
2088
|
-
name = rb_str_new2(ci->name);
|
2089
|
-
|
2090
|
-
compliance_type = ci->compliance;
|
2091
|
-
compliance = ComplianceType_new(compliance_type);
|
2092
|
-
color = Pixel_from_MagickPixelPacket(&(ci->color));
|
2093
|
-
|
2094
|
-
return rb_funcall(Class_Color, rm_ID_new, 3
|
2095
|
-
, name, compliance, color);
|
2096
|
-
}
|
2097
|
-
|
2098
|
-
|
2099
|
-
/*
|
2100
|
-
External: Color_to_ColorInfo
|
2101
|
-
Purpose: Convert a Magick::Color to a ColorInfo structure
|
2102
|
-
*/
|
2103
|
-
void
|
2104
|
-
Color_to_ColorInfo(ColorInfo *ci, VALUE st)
|
2105
|
-
{
|
2106
|
-
Pixel *pixel;
|
2107
|
-
volatile VALUE members, m;
|
2108
|
-
|
2109
|
-
if (CLASS_OF(st) != Class_Color)
|
2110
|
-
{
|
2111
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2112
|
-
rb_class2name(CLASS_OF(st)));
|
2113
|
-
}
|
2114
|
-
|
2115
|
-
memset(ci, '\0', sizeof(ColorInfo));
|
2116
|
-
|
2117
|
-
members = rb_funcall(st, rm_ID_values, 0);
|
2118
|
-
|
2119
|
-
m = rb_ary_entry(members, 0);
|
2120
|
-
if (m != Qnil)
|
2121
|
-
{
|
2122
|
-
(void) CloneString((char **)&(ci->name), StringValuePtr(m));
|
2123
|
-
}
|
2124
|
-
m = rb_ary_entry(members, 1);
|
2125
|
-
if (m != Qnil)
|
2126
|
-
{
|
2127
|
-
VALUE_TO_ENUM(m, ci->compliance, ComplianceType);
|
2128
|
-
}
|
2129
|
-
m = rb_ary_entry(members, 2);
|
2130
|
-
if (m != Qnil)
|
2131
|
-
{
|
2132
|
-
Data_Get_Struct(m, Pixel, pixel);
|
2133
|
-
// For >= 6.3.0, ColorInfo.color is a MagickPixelPacket so we have to
|
2134
|
-
// convert the PixelPacket.
|
2135
|
-
GetMagickPixelPacket(NULL, &ci->color);
|
2136
|
-
ci->color.red = (MagickRealType) pixel->red;
|
2137
|
-
ci->color.green = (MagickRealType) pixel->green;
|
2138
|
-
ci->color.blue = (MagickRealType) pixel->blue;
|
2139
|
-
ci->color.opacity = (MagickRealType) OpaqueOpacity;
|
2140
|
-
ci->color.index = (MagickRealType) 0;
|
2141
|
-
}
|
2142
|
-
}
|
2143
|
-
|
2144
|
-
|
2145
|
-
/*
|
2146
|
-
Static: destroy_ColorInfo
|
2147
|
-
Purpose: free the storage allocated by Color_to_ColorInfo, above.
|
2148
|
-
*/
|
2149
|
-
static void
|
2150
|
-
destroy_ColorInfo(ColorInfo *ci)
|
2151
|
-
{
|
2152
|
-
magick_free((void*)ci->name);
|
2153
|
-
ci->name = NULL;
|
2154
|
-
}
|
2155
|
-
|
2156
|
-
|
2157
|
-
/*
|
2158
|
-
Method: Color#to_s
|
2159
|
-
Purpose: Return a string representation of a Magick::Color object
|
2160
|
-
*/
|
2161
|
-
VALUE
|
2162
|
-
Color_to_s(VALUE self)
|
2163
|
-
{
|
2164
|
-
ColorInfo ci;
|
2165
|
-
char buff[1024];
|
2166
|
-
|
2167
|
-
Color_to_ColorInfo(&ci, self);
|
2168
|
-
|
2169
|
-
sprintf(buff, "name=%s, compliance=%s, "
|
2170
|
-
#if (QuantumDepth == 32 || QuantumDepth == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
|
2171
|
-
"color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.opacity=%Lg ",
|
2172
|
-
#else
|
2173
|
-
"color.red=%g, color.green=%g, color.blue=%g, color.opacity=%g ",
|
2174
|
-
#endif
|
2175
|
-
ci.name,
|
2176
|
-
ComplianceType_name(&ci.compliance),
|
2177
|
-
ci.color.red, ci.color.green, ci.color.blue, ci.color.opacity);
|
2178
|
-
|
2179
|
-
destroy_ColorInfo(&ci);
|
2180
|
-
return rb_str_new2(buff);
|
2181
|
-
}
|
2182
|
-
|
2183
|
-
|
2184
|
-
/*
|
2185
|
-
Extern: Pixel_from_PixelPacket
|
2186
|
-
Purpose: Create a Magick::Pixel object from a PixelPacket structure.
|
2187
|
-
Notes: bypasses normal Pixel.new, Pixel#initialize methods
|
2188
|
-
*/
|
2189
|
-
VALUE
|
2190
|
-
Pixel_from_PixelPacket(const PixelPacket *pp)
|
2191
|
-
{
|
2192
|
-
Pixel *pixel;
|
2193
|
-
|
2194
|
-
pixel = ALLOC(Pixel);
|
2195
|
-
*pixel = *pp;
|
2196
|
-
return Data_Wrap_Struct(Class_Pixel, NULL, destroy_Pixel, pixel);
|
2197
|
-
}
|
2198
|
-
|
2199
|
-
|
2200
|
-
/*
|
2201
|
-
Static: Pixel_from_MagickPixelPacket
|
2202
|
-
Purpose: Create a Magick::Pixel object from a MagickPixelPacket structure.
|
2203
|
-
Notes: bypasses normal Pixel.new, Pixel#initialize methods
|
2204
|
-
*/
|
2205
|
-
static VALUE
|
2206
|
-
Pixel_from_MagickPixelPacket(const MagickPixelPacket *pp)
|
2207
|
-
{
|
2208
|
-
Pixel *pixel;
|
2209
|
-
|
2210
|
-
pixel = ALLOC(Pixel);
|
2211
|
-
pixel->red = ROUND_TO_QUANTUM(pp->red);
|
2212
|
-
pixel->green = ROUND_TO_QUANTUM(pp->green);
|
2213
|
-
pixel->blue = ROUND_TO_QUANTUM(pp->blue);
|
2214
|
-
pixel->opacity = ROUND_TO_QUANTUM(pp->opacity);
|
2215
|
-
|
2216
|
-
return Data_Wrap_Struct(Class_Pixel, NULL, destroy_Pixel, pixel);
|
2217
|
-
}
|
2218
|
-
|
2219
|
-
|
2220
|
-
/*
|
2221
|
-
* Static: color_arg_rescue
|
2222
|
-
* Purpose: raise ArgumentError if the color name cannot be converted
|
2223
|
-
* to a string via rb_str_to_str.
|
2224
|
-
*/
|
2225
|
-
static VALUE
|
2226
|
-
color_arg_rescue(VALUE arg)
|
2227
|
-
{
|
2228
|
-
rb_raise(rb_eTypeError, "argument must be color name or pixel (%s given)",
|
2229
|
-
rb_class2name(CLASS_OF(arg)));
|
2230
|
-
return (VALUE)0;
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
|
2234
|
-
/*
|
2235
|
-
Extern: Color_to_PixelPacket
|
2236
|
-
Purpose: Convert either a String color name or
|
2237
|
-
a Magick::Pixel to a PixelPacket
|
2238
|
-
*/
|
2239
|
-
void
|
2240
|
-
Color_to_PixelPacket(PixelPacket *pp, VALUE color)
|
2241
|
-
{
|
2242
|
-
Pixel *pixel;
|
2243
|
-
|
2244
|
-
// Allow color name or Pixel
|
2245
|
-
if (CLASS_OF(color) == Class_Pixel)
|
2246
|
-
{
|
2247
|
-
Data_Get_Struct(color, Pixel, pixel);
|
2248
|
-
*pp = *pixel;
|
2249
|
-
}
|
2250
|
-
else
|
2251
|
-
{
|
2252
|
-
// require 'to_str' here instead of just 'to_s'.
|
2253
|
-
color = rb_rescue(rb_str_to_str, color, color_arg_rescue, color);
|
2254
|
-
Color_Name_to_PixelPacket(pp, color);
|
2255
|
-
}
|
2256
|
-
}
|
2257
|
-
|
2258
|
-
|
2259
|
-
/*
|
2260
|
-
Extern: Color_to_MagickPixelPacket
|
2261
|
-
Purpose: Convert either a String color name or
|
2262
|
-
a Magick::Pixel to a MagickPixelPacket
|
2263
|
-
Notes: The channel values in a MagickPixelPacket are doubles.
|
2264
|
-
*/
|
2265
|
-
void
|
2266
|
-
Color_to_MagickPixelPacket(Image *image, MagickPixelPacket *mpp, VALUE color)
|
2267
|
-
{
|
2268
|
-
PixelPacket pp;
|
2269
|
-
|
2270
|
-
// image can be NULL
|
2271
|
-
GetMagickPixelPacket(image, mpp);
|
2272
|
-
|
2273
|
-
memset(&pp, '\0', sizeof(pp));
|
2274
|
-
Color_to_PixelPacket(&pp, color);
|
2275
|
-
mpp->red = (MagickRealType) pp.red;
|
2276
|
-
mpp->green = (MagickRealType) pp.green;
|
2277
|
-
mpp->blue = (MagickRealType) pp.blue;
|
2278
|
-
mpp->opacity = (MagickRealType) pp.opacity;
|
2279
|
-
}
|
2280
|
-
|
2281
|
-
|
2282
|
-
/*
|
2283
|
-
Extern: PrimaryInfo_from_PrimaryInfo(pp)
|
2284
|
-
Purpose: Create a Magick::PrimaryInfo object from a PrimaryInfo structure.
|
2285
|
-
*/
|
2286
|
-
VALUE
|
2287
|
-
PrimaryInfo_from_PrimaryInfo(PrimaryInfo *p)
|
2288
|
-
{
|
2289
|
-
return rb_funcall(Class_Primary, rm_ID_new, 3
|
2290
|
-
, INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
|
2291
|
-
}
|
2292
|
-
|
2293
|
-
|
2294
|
-
/*
|
2295
|
-
Extern: PrimaryInfo_to_PrimaryInfo
|
2296
|
-
Purpose: Convert a Magick::PrimaryInfo object to a PrimaryInfo structure
|
2297
|
-
*/
|
2298
|
-
void
|
2299
|
-
PrimaryInfo_to_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
|
2300
|
-
{
|
2301
|
-
volatile VALUE members, m;
|
2302
|
-
|
2303
|
-
if (CLASS_OF(sp) != Class_Primary)
|
2304
|
-
{
|
2305
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2306
|
-
rb_class2name(CLASS_OF(sp)));
|
2307
|
-
}
|
2308
|
-
members = rb_funcall(sp, rm_ID_values, 0);
|
2309
|
-
m = rb_ary_entry(members, 0);
|
2310
|
-
pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
|
2311
|
-
m = rb_ary_entry(members, 1);
|
2312
|
-
pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
|
2313
|
-
m = rb_ary_entry(members, 2);
|
2314
|
-
pi->z = m == Qnil ? 0.0 : NUM2DBL(m);
|
2315
|
-
}
|
2316
|
-
|
2317
|
-
|
2318
|
-
/*
|
2319
|
-
Extern: PointInfo_to_Point(pp)
|
2320
|
-
Purpose: Create a Magick::Point object from a PointInfo structure.
|
2321
|
-
*/
|
2322
|
-
VALUE
|
2323
|
-
PointInfo_to_Point(PointInfo *p)
|
2324
|
-
{
|
2325
|
-
return rb_funcall(Class_Point, rm_ID_new, 2
|
2326
|
-
, INT2FIX(p->x), INT2FIX(p->y));
|
2327
|
-
}
|
2328
|
-
|
2329
|
-
|
2330
|
-
/*
|
2331
|
-
Extern: Point_to_PointInfo
|
2332
|
-
Purpose: Convert a Magick::Point object to a PointInfo structure
|
2333
|
-
*/
|
2334
|
-
void
|
2335
|
-
Point_to_PointInfo(PointInfo *pi, VALUE sp)
|
2336
|
-
{
|
2337
|
-
volatile VALUE members, m;
|
2338
|
-
|
2339
|
-
if (CLASS_OF(sp) != Class_Point)
|
2340
|
-
{
|
2341
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2342
|
-
rb_class2name(CLASS_OF(sp)));
|
2343
|
-
}
|
2344
|
-
members = rb_funcall(sp, rm_ID_values, 0);
|
2345
|
-
m = rb_ary_entry(members, 0);
|
2346
|
-
pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
|
2347
|
-
m = rb_ary_entry(members, 1);
|
2348
|
-
pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
|
2349
|
-
}
|
2350
|
-
|
2351
|
-
|
2352
|
-
/*
|
2353
|
-
Extern: ChromaticityInfo_new(pp)
|
2354
|
-
Purpose: Create a Magick::ChromaticityInfo object from a
|
2355
|
-
ChromaticityInfo structure.
|
2356
|
-
*/
|
2357
|
-
VALUE
|
2358
|
-
ChromaticityInfo_new(ChromaticityInfo *ci)
|
2359
|
-
{
|
2360
|
-
volatile VALUE red_primary;
|
2361
|
-
volatile VALUE green_primary;
|
2362
|
-
volatile VALUE blue_primary;
|
2363
|
-
volatile VALUE white_point;
|
2364
|
-
|
2365
|
-
red_primary = PrimaryInfo_from_PrimaryInfo(&ci->red_primary);
|
2366
|
-
green_primary = PrimaryInfo_from_PrimaryInfo(&ci->green_primary);
|
2367
|
-
blue_primary = PrimaryInfo_from_PrimaryInfo(&ci->blue_primary);
|
2368
|
-
white_point = PrimaryInfo_from_PrimaryInfo(&ci->white_point);
|
2369
|
-
|
2370
|
-
return rb_funcall(Class_Chromaticity, rm_ID_new, 4
|
2371
|
-
, red_primary, green_primary, blue_primary, white_point);
|
2372
|
-
}
|
2373
|
-
|
2374
|
-
|
2375
|
-
/*
|
2376
|
-
Extern: ChromaticityInfo_to_ChromaticityInfo
|
2377
|
-
Purpose: Extract the elements from a Magick::ChromaticityInfo
|
2378
|
-
and store in a ChromaticityInfo structure.
|
2379
|
-
*/
|
2380
|
-
void
|
2381
|
-
ChromaticityInfo_to_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
2382
|
-
{
|
2383
|
-
volatile VALUE chrom_members;
|
2384
|
-
volatile VALUE red_primary, green_primary, blue_primary, white_point;
|
2385
|
-
volatile VALUE entry_members, x, y;
|
2386
|
-
ID values_id;
|
2387
|
-
|
2388
|
-
if (CLASS_OF(chrom) != Class_Chromaticity)
|
2389
|
-
{
|
2390
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2391
|
-
rb_class2name(CLASS_OF(chrom)));
|
2392
|
-
}
|
2393
|
-
values_id = rm_ID_values;
|
2394
|
-
|
2395
|
-
// Get the struct members in an array
|
2396
|
-
chrom_members = rb_funcall(chrom, values_id, 0);
|
2397
|
-
red_primary = rb_ary_entry(chrom_members, 0);
|
2398
|
-
green_primary = rb_ary_entry(chrom_members, 1);
|
2399
|
-
blue_primary = rb_ary_entry(chrom_members, 2);
|
2400
|
-
white_point = rb_ary_entry(chrom_members, 3);
|
2401
|
-
|
2402
|
-
// Get the red_primary PrimaryInfo members in an array
|
2403
|
-
entry_members = rb_funcall(red_primary, values_id, 0);
|
2404
|
-
x = rb_ary_entry(entry_members, 0); // red_primary.x
|
2405
|
-
ci->red_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
2406
|
-
y = rb_ary_entry(entry_members, 1); // red_primary.y
|
2407
|
-
ci->red_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
|
2408
|
-
ci->red_primary.z = 0.0;
|
2409
|
-
|
2410
|
-
// Get the green_primary PrimaryInfo members in an array
|
2411
|
-
entry_members = rb_funcall(green_primary, values_id, 0);
|
2412
|
-
x = rb_ary_entry(entry_members, 0); // green_primary.x
|
2413
|
-
ci->green_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
2414
|
-
y = rb_ary_entry(entry_members, 1); // green_primary.y
|
2415
|
-
ci->green_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
|
2416
|
-
ci->green_primary.z = 0.0;
|
2417
|
-
|
2418
|
-
// Get the blue_primary PrimaryInfo members in an array
|
2419
|
-
entry_members = rb_funcall(blue_primary, values_id, 0);
|
2420
|
-
x = rb_ary_entry(entry_members, 0); // blue_primary.x
|
2421
|
-
ci->blue_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
2422
|
-
y = rb_ary_entry(entry_members, 1); // blue_primary.y
|
2423
|
-
ci->blue_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
|
2424
|
-
ci->blue_primary.z = 0.0;
|
2425
|
-
|
2426
|
-
// Get the white_point PrimaryInfo members in an array
|
2427
|
-
entry_members = rb_funcall(white_point, values_id, 0);
|
2428
|
-
x = rb_ary_entry(entry_members, 0); // white_point.x
|
2429
|
-
ci->white_point.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
2430
|
-
y = rb_ary_entry(entry_members, 1); // white_point.y
|
2431
|
-
ci->white_point.y = y == Qnil ? 0.0 : NUM2DBL(y);
|
2432
|
-
ci->white_point.z = 0.0;
|
2433
|
-
}
|
2434
|
-
|
2435
|
-
|
2436
|
-
/*
|
2437
|
-
External: Rectangle_from_RectangleInfo
|
2438
|
-
Purpose: Convert a RectangleInfo structure to a Magick::Rectangle
|
2439
|
-
*/
|
2440
|
-
VALUE
|
2441
|
-
Rectangle_from_RectangleInfo(RectangleInfo *rect)
|
2442
|
-
{
|
2443
|
-
volatile VALUE width;
|
2444
|
-
volatile VALUE height;
|
2445
|
-
volatile VALUE x, y;
|
2446
|
-
|
2447
|
-
width = UINT2NUM(rect->width);
|
2448
|
-
height = UINT2NUM(rect->height);
|
2449
|
-
x = INT2NUM(rect->x);
|
2450
|
-
y = INT2NUM(rect->y);
|
2451
|
-
return rb_funcall(Class_Rectangle, rm_ID_new, 4
|
2452
|
-
, width, height, x, y);
|
2453
|
-
}
|
2454
|
-
|
2455
|
-
|
2456
|
-
/*
|
2457
|
-
External: Rectangle_to_RectangleInfo
|
2458
|
-
Purpose: Convert a Magick::Rectangle to a RectangleInfo structure.
|
2459
|
-
*/
|
2460
|
-
void
|
2461
|
-
Rectangle_to_RectangleInfo(RectangleInfo *rect, VALUE sr)
|
2462
|
-
{
|
2463
|
-
volatile VALUE members, m;
|
2464
|
-
|
2465
|
-
if (CLASS_OF(sr) != Class_Rectangle)
|
2466
|
-
{
|
2467
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2468
|
-
rb_class2name(CLASS_OF(sr)));
|
2469
|
-
}
|
2470
|
-
members = rb_funcall(sr, rm_ID_values, 0);
|
2471
|
-
m = rb_ary_entry(members, 0);
|
2472
|
-
rect->width = m == Qnil ? 0 : NUM2ULONG(m);
|
2473
|
-
m = rb_ary_entry(members, 1);
|
2474
|
-
rect->height = m == Qnil ? 0 : NUM2ULONG(m);
|
2475
|
-
m = rb_ary_entry(members, 2);
|
2476
|
-
rect->x = m == Qnil ? 0 : NUM2LONG (m);
|
2477
|
-
m = rb_ary_entry(members, 3);
|
2478
|
-
rect->y = m == Qnil ? 0 : NUM2LONG (m);
|
2479
|
-
}
|
2480
|
-
|
2481
|
-
|
2482
|
-
/*
|
2483
|
-
External: Segment_from_SegmentInfo
|
2484
|
-
Purpose: Convert a SegmentInfo structure to a Magick::Segment
|
2485
|
-
*/
|
2486
|
-
VALUE
|
2487
|
-
Segment_from_SegmentInfo(SegmentInfo *segment)
|
2488
|
-
{
|
2489
|
-
volatile VALUE x1, y1, x2, y2;
|
2490
|
-
|
2491
|
-
x1 = rb_float_new(segment->x1);
|
2492
|
-
y1 = rb_float_new(segment->y1);
|
2493
|
-
x2 = rb_float_new(segment->x2);
|
2494
|
-
y2 = rb_float_new(segment->y2);
|
2495
|
-
return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
|
2496
|
-
}
|
2497
|
-
|
2498
|
-
|
2499
|
-
/*
|
2500
|
-
External: Segment_to_SegmentInfo
|
2501
|
-
Purpose: Convert a Magick::Segment to a SegmentInfo structure.
|
2502
|
-
*/
|
2503
|
-
void
|
2504
|
-
Segment_to_SegmentInfo(SegmentInfo *segment, VALUE s)
|
2505
|
-
{
|
2506
|
-
volatile VALUE members, m;
|
2507
|
-
|
2508
|
-
if (CLASS_OF(s) != Class_Segment)
|
2509
|
-
{
|
2510
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2511
|
-
rb_class2name(CLASS_OF(s)));
|
2512
|
-
}
|
2513
|
-
|
2514
|
-
members = rb_funcall(s, rm_ID_values, 0);
|
2515
|
-
m = rb_ary_entry(members, 0);
|
2516
|
-
segment->x1 = m == Qnil ? 0.0 : NUM2DBL(m);
|
2517
|
-
m = rb_ary_entry(members, 1);
|
2518
|
-
segment->y1 = m == Qnil ? 0.0 : NUM2DBL(m);
|
2519
|
-
m = rb_ary_entry(members, 2);
|
2520
|
-
segment->x2 = m == Qnil ? 0.0 : NUM2DBL(m);
|
2521
|
-
m = rb_ary_entry(members, 3);
|
2522
|
-
segment->y2 = m == Qnil ? 0.0 : NUM2DBL(m);
|
2523
|
-
}
|
2524
|
-
|
2525
|
-
|
2526
|
-
/*
|
2527
|
-
Static: StretchType_new
|
2528
|
-
Purpose: Construct a StretchType enum for a specified StretchType value
|
2529
|
-
*/
|
2530
|
-
static VALUE
|
2531
|
-
StretchType_new(StretchType stretch)
|
2532
|
-
{
|
2533
|
-
const char *name = StretchType_name(stretch);
|
2534
|
-
return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
|
2535
|
-
}
|
2536
|
-
|
2537
|
-
|
2538
|
-
/*
|
2539
|
-
Static: StyleType_new
|
2540
|
-
Purpose: Construct a StyleType enum for a specified StyleType value
|
2541
|
-
*/
|
2542
|
-
static VALUE
|
2543
|
-
StyleType_new(StyleType style)
|
2544
|
-
{
|
2545
|
-
const char *name = StyleType_name(style);
|
2546
|
-
return rm_enum_new(Class_StyleType, ID2SYM(rb_intern(name)), INT2FIX(style));
|
2547
|
-
}
|
2548
|
-
|
2549
|
-
|
2550
|
-
/*
|
2551
|
-
External: Font_from_TypeInfo
|
2552
|
-
Purpose: Convert a TypeInfo structure to a Magick::Font
|
2553
|
-
*/
|
2554
|
-
VALUE
|
2555
|
-
Font_from_TypeInfo(const TypeInfo *ti)
|
2556
|
-
{
|
2557
|
-
volatile VALUE name, description, family;
|
2558
|
-
volatile VALUE style, stretch, weight;
|
2559
|
-
volatile VALUE encoding, foundry, format;
|
2560
|
-
|
2561
|
-
name = rb_str_new2(ti->name);
|
2562
|
-
family = rb_str_new2(ti->family);
|
2563
|
-
style = StyleType_new(ti->style);
|
2564
|
-
stretch = StretchType_new(ti->stretch);
|
2565
|
-
weight = ULONG2NUM(ti->weight);
|
2566
|
-
description = ti->description ? rb_str_new2(ti->description) : Qnil;
|
2567
|
-
encoding = ti->encoding ? rb_str_new2(ti->encoding) : Qnil;
|
2568
|
-
foundry = ti->foundry ? rb_str_new2(ti->foundry) : Qnil;
|
2569
|
-
format = ti->format ? rb_str_new2(ti->format) : Qnil;
|
2570
|
-
|
2571
|
-
return rb_funcall(Class_Font, rm_ID_new, 9
|
2572
|
-
, name, description, family, style
|
2573
|
-
, stretch, weight, encoding, foundry, format);
|
2574
|
-
}
|
2575
|
-
|
2576
|
-
|
2577
|
-
/*
|
2578
|
-
External: Font_to_TypeInfo
|
2579
|
-
Purpose: Convert a Magick::Font to a TypeInfo structure
|
2580
|
-
*/
|
2581
|
-
void
|
2582
|
-
Font_to_TypeInfo(TypeInfo *ti, VALUE st)
|
2583
|
-
{
|
2584
|
-
volatile VALUE members, m;
|
2585
|
-
|
2586
|
-
if (CLASS_OF(st) != Class_Font)
|
2587
|
-
{
|
2588
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2589
|
-
rb_class2name(CLASS_OF(st)));
|
2590
|
-
}
|
2591
|
-
|
2592
|
-
memset(ti, '\0', sizeof(TypeInfo));
|
2593
|
-
|
2594
|
-
members = rb_funcall(st, rm_ID_values, 0);
|
2595
|
-
m = rb_ary_entry(members, 0);
|
2596
|
-
if (m != Qnil)
|
2597
|
-
{
|
2598
|
-
(void) CloneString((char **)&(ti->name), StringValuePtr(m));
|
2599
|
-
}
|
2600
|
-
m = rb_ary_entry(members, 1);
|
2601
|
-
if (m != Qnil)
|
2602
|
-
{
|
2603
|
-
(void) CloneString((char **)&(ti->description), StringValuePtr(m));
|
2604
|
-
}
|
2605
|
-
m = rb_ary_entry(members, 2);
|
2606
|
-
if (m != Qnil)
|
2607
|
-
{
|
2608
|
-
(void) CloneString((char **)&(ti->family), StringValuePtr(m));
|
2609
|
-
}
|
2610
|
-
m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(m);
|
2611
|
-
m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(m);
|
2612
|
-
m = rb_ary_entry(members, 5); ti->weight = m == Qnil ? 0 : FIX2INT(m);
|
2613
|
-
|
2614
|
-
m = rb_ary_entry(members, 6);
|
2615
|
-
if (m != Qnil)
|
2616
|
-
(void) CloneString((char **)&(ti->encoding), StringValuePtr(m));
|
2617
|
-
m = rb_ary_entry(members, 7);
|
2618
|
-
if (m != Qnil)
|
2619
|
-
(void) CloneString((char **)&(ti->foundry), StringValuePtr(m));
|
2620
|
-
m = rb_ary_entry(members, 8);
|
2621
|
-
if (m != Qnil)
|
2622
|
-
(void) CloneString((char **)&(ti->format), StringValuePtr(m));
|
2623
|
-
}
|
2624
|
-
|
2625
|
-
|
2626
|
-
/*
|
2627
|
-
Static: destroy_TypeInfo
|
2628
|
-
Purpose: free the storage allocated by Font_to_TypeInfo, above.
|
2629
|
-
*/
|
2630
|
-
static void
|
2631
|
-
destroy_TypeInfo(TypeInfo *ti)
|
2632
|
-
{
|
2633
|
-
magick_free((void*)ti->name);
|
2634
|
-
ti->name = NULL;
|
2635
|
-
magick_free((void*)ti->description);
|
2636
|
-
ti->description = NULL;
|
2637
|
-
magick_free((void*)ti->family);
|
2638
|
-
ti->family = NULL;
|
2639
|
-
magick_free((void*)ti->encoding);
|
2640
|
-
ti->encoding = NULL;
|
2641
|
-
magick_free((void*)ti->foundry);
|
2642
|
-
ti->foundry = NULL;
|
2643
|
-
magick_free((void*)ti->format);
|
2644
|
-
ti->format = NULL;
|
2645
|
-
}
|
2646
|
-
|
2647
|
-
|
2648
|
-
/*
|
2649
|
-
External: Font_to_s
|
2650
|
-
Purpose: implement the Font#to_s method
|
2651
|
-
*/
|
2652
|
-
VALUE
|
2653
|
-
Font_to_s(VALUE self)
|
2654
|
-
{
|
2655
|
-
TypeInfo ti;
|
2656
|
-
char weight[20];
|
2657
|
-
char buff[1024];
|
2658
|
-
|
2659
|
-
Font_to_TypeInfo(&ti, self);
|
2660
|
-
|
2661
|
-
switch (ti.weight)
|
2662
|
-
{
|
2663
|
-
case 400:
|
2664
|
-
strcpy(weight, "NormalWeight");
|
2665
|
-
break;
|
2666
|
-
case 700:
|
2667
|
-
strcpy(weight, "BoldWeight");
|
2668
|
-
break;
|
2669
|
-
default:
|
2670
|
-
sprintf(weight, "%lu", ti.weight);
|
2671
|
-
break;
|
2672
|
-
}
|
2673
|
-
|
2674
|
-
sprintf(buff, "name=%s, description=%s, "
|
2675
|
-
"family=%s, style=%s, stretch=%s, weight=%s, "
|
2676
|
-
"encoding=%s, foundry=%s, format=%s",
|
2677
|
-
ti.name,
|
2678
|
-
ti.description,
|
2679
|
-
ti.family,
|
2680
|
-
StyleType_name(ti.style),
|
2681
|
-
StretchType_name(ti.stretch),
|
2682
|
-
weight,
|
2683
|
-
ti.encoding ? ti.encoding : "",
|
2684
|
-
ti.foundry ? ti.foundry : "",
|
2685
|
-
ti.format ? ti.format : "");
|
2686
|
-
|
2687
|
-
destroy_TypeInfo(&ti);
|
2688
|
-
return rb_str_new2(buff);
|
2689
|
-
|
2690
|
-
}
|
2691
|
-
|
2692
|
-
|
2693
|
-
/*
|
2694
|
-
External: TypeMetric_from_TypeMetric
|
2695
|
-
Purpose: Convert a TypeMetric structure to a Magick::TypeMetric
|
2696
|
-
*/
|
2697
|
-
VALUE
|
2698
|
-
TypeMetric_from_TypeMetric(TypeMetric *tm)
|
2699
|
-
{
|
2700
|
-
volatile VALUE pixels_per_em;
|
2701
|
-
volatile VALUE ascent, descent;
|
2702
|
-
volatile VALUE width, height, max_advance;
|
2703
|
-
volatile VALUE bounds, underline_position, underline_thickness;
|
2704
|
-
|
2705
|
-
pixels_per_em = PointInfo_to_Point(&tm->pixels_per_em);
|
2706
|
-
ascent = rb_float_new(tm->ascent);
|
2707
|
-
descent = rb_float_new(tm->descent);
|
2708
|
-
width = rb_float_new(tm->width);
|
2709
|
-
height = rb_float_new(tm->height);
|
2710
|
-
max_advance = rb_float_new(tm->max_advance);
|
2711
|
-
bounds = Segment_from_SegmentInfo(&tm->bounds);
|
2712
|
-
underline_position = rb_float_new(tm->underline_position);
|
2713
|
-
underline_thickness = rb_float_new(tm->underline_position);
|
2714
|
-
|
2715
|
-
return rb_funcall(Class_TypeMetric, rm_ID_new, 9
|
2716
|
-
, pixels_per_em, ascent, descent, width
|
2717
|
-
, height, max_advance, bounds
|
2718
|
-
, underline_position, underline_thickness);
|
2719
|
-
}
|
2720
|
-
|
2721
|
-
|
2722
|
-
/*
|
2723
|
-
External: TypeMetric_to_TypeMetric
|
2724
|
-
Purpose: Convert a Magick::TypeMetric to a TypeMetric structure.
|
2725
|
-
*/
|
2726
|
-
void
|
2727
|
-
TypeMetric_to_TypeMetric(TypeMetric *tm, VALUE st)
|
2728
|
-
{
|
2729
|
-
volatile VALUE members, m;
|
2730
|
-
volatile VALUE pixels_per_em;
|
2731
|
-
|
2732
|
-
if (CLASS_OF(st) != Class_TypeMetric)
|
2733
|
-
{
|
2734
|
-
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
2735
|
-
rb_class2name(CLASS_OF(st)));
|
2736
|
-
}
|
2737
|
-
members = rb_funcall(st, rm_ID_values, 0);
|
2738
|
-
|
2739
|
-
pixels_per_em = rb_ary_entry(members, 0);
|
2740
|
-
Point_to_PointInfo(&tm->pixels_per_em, pixels_per_em);
|
2741
|
-
|
2742
|
-
m = rb_ary_entry(members, 1);
|
2743
|
-
tm->ascent = m == Qnil ? 0.0 : NUM2DBL(m);
|
2744
|
-
m = rb_ary_entry(members, 2);
|
2745
|
-
tm->descent = m == Qnil ? 0.0 : NUM2DBL(m);
|
2746
|
-
m = rb_ary_entry(members, 3);
|
2747
|
-
tm->width = m == Qnil ? 0.0 : NUM2DBL(m);
|
2748
|
-
m = rb_ary_entry(members, 4);
|
2749
|
-
tm->height = m == Qnil ? 0.0 : NUM2DBL(m);
|
2750
|
-
m = rb_ary_entry(members, 5);
|
2751
|
-
tm->max_advance = m == Qnil ? 0.0 : NUM2DBL(m);
|
2752
|
-
|
2753
|
-
m = rb_ary_entry(members, 6);
|
2754
|
-
Segment_to_SegmentInfo(&tm->bounds, m);
|
2755
|
-
|
2756
|
-
m = rb_ary_entry(members, 7);
|
2757
|
-
tm->underline_position = m == Qnil ? 0.0 : NUM2DBL(m);
|
2758
|
-
m = rb_ary_entry(members, 8);
|
2759
|
-
tm->underline_thickness = m == Qnil ? 0.0 : NUM2DBL(m);
|
2760
|
-
}
|
2761
|
-
|
2762
|
-
|
2763
|
-
/*
|
2764
|
-
Method: Magick::TypeMetric#to_s
|
2765
|
-
Purpose: Create a string representation of a Magick::TypeMetric
|
2766
|
-
*/
|
2767
|
-
VALUE
|
2768
|
-
TypeMetric_to_s(VALUE self)
|
2769
|
-
{
|
2770
|
-
TypeMetric tm;
|
2771
|
-
char buff[200];
|
2772
|
-
|
2773
|
-
TypeMetric_to_TypeMetric(&tm, self);
|
2774
|
-
sprintf(buff, "pixels_per_em=(x=%g,y=%g) "
|
2775
|
-
"ascent=%g descent=%g width=%g height=%g max_advance=%g "
|
2776
|
-
"bounds.x1=%g bounds.y1=%g bounds.x2=%g bounds.y2=%g "
|
2777
|
-
"underline_position=%g underline_thickness=%g",
|
2778
|
-
tm.pixels_per_em.x, tm.pixels_per_em.y,
|
2779
|
-
tm.ascent, tm.descent, tm.width, tm.height, tm.max_advance,
|
2780
|
-
tm.bounds.x1, tm.bounds.y1, tm.bounds.x2, tm.bounds.y2,
|
2781
|
-
tm.underline_position, tm.underline_thickness);
|
2782
|
-
return rb_str_new2(buff);
|
2783
|
-
}
|
2784
|
-
|
2785
|
-
|
2786
|
-
/*
|
2787
|
-
Static: VirtualPixelMethod_name
|
2788
|
-
Purpose: Return the string representation of a VirtualPixelMethod value
|
2789
|
-
*/
|
2790
|
-
static const char *
|
2791
|
-
VirtualPixelMethod_name(VirtualPixelMethod method)
|
2792
|
-
{
|
2793
|
-
switch (method)
|
2794
|
-
{
|
2795
|
-
ENUM_TO_NAME(UndefinedVirtualPixelMethod)
|
2796
|
-
ENUM_TO_NAME(EdgeVirtualPixelMethod)
|
2797
|
-
ENUM_TO_NAME(MirrorVirtualPixelMethod)
|
2798
|
-
ENUM_TO_NAME(TileVirtualPixelMethod)
|
2799
|
-
ENUM_TO_NAME(TransparentVirtualPixelMethod)
|
2800
|
-
ENUM_TO_NAME(BackgroundVirtualPixelMethod)
|
2801
|
-
ENUM_TO_NAME(DitherVirtualPixelMethod)
|
2802
|
-
ENUM_TO_NAME(RandomVirtualPixelMethod)
|
2803
|
-
ENUM_TO_NAME(ConstantVirtualPixelMethod)
|
2804
|
-
#if defined(HAVE_ENUM_MASKVIRTUALPIXELMETHOD)
|
2805
|
-
ENUM_TO_NAME(MaskVirtualPixelMethod)
|
2806
|
-
#endif
|
2807
|
-
#if defined(HAVE_ENUM_BLACKVIRTUALPIXELMETHOD)
|
2808
|
-
ENUM_TO_NAME(BlackVirtualPixelMethod)
|
2809
|
-
#endif
|
2810
|
-
#if defined(HAVE_ENUM_GRAYVIRTUALPIXELMETHOD)
|
2811
|
-
ENUM_TO_NAME(GrayVirtualPixelMethod)
|
2812
|
-
#endif
|
2813
|
-
#if defined(HAVE_ENUM_WHITEVIRTUALPIXELMETHOD)
|
2814
|
-
ENUM_TO_NAME(WhiteVirtualPixelMethod)
|
2815
|
-
#endif
|
2816
|
-
#if defined(HAVE_ENUM_HORIZONTALTILEVIRTUALPIXELMETHOD)
|
2817
|
-
ENUM_TO_NAME(HorizontalTileVirtualPixelMethod)
|
2818
|
-
#endif
|
2819
|
-
#if defined(HAVE_ENUM_VERTICALTILEVIRTUALPIXELMETHOD)
|
2820
|
-
ENUM_TO_NAME(VerticalTileVirtualPixelMethod)
|
2821
|
-
#endif
|
2822
|
-
}
|
2823
|
-
|
2824
|
-
return "UndefinedVirtualPixelMethod";
|
2825
|
-
}
|
2826
|
-
|
2827
|
-
|
2828
|
-
/*
|
2829
|
-
Static: VirtualPixelMethod_new
|
2830
|
-
Purpose: Construct a VirtualPixelMethod enum for a specified VirtualPixelMethod value
|
2831
|
-
*/
|
2832
|
-
VALUE
|
2833
|
-
VirtualPixelMethod_new(VirtualPixelMethod style)
|
2834
|
-
{
|
2835
|
-
const char *name = VirtualPixelMethod_name(style);
|
2836
|
-
return rm_enum_new(Class_VirtualPixelMethod, ID2SYM(rb_intern(name)), INT2FIX(style));
|
2837
|
-
}
|
2838
|
-
|
2839
|
-
|
2840
|
-
/*
|
2841
|
-
* Extern: rm_define_enum_type
|
2842
|
-
* Purpose: set up a subclass of Enum
|
2843
|
-
*/
|
2844
|
-
VALUE
|
2845
|
-
rm_define_enum_type(const char *tag)
|
2846
|
-
{
|
2847
|
-
VALUE class;
|
2848
|
-
|
2849
|
-
class = rb_define_class_under(Module_Magick, tag, Class_Enum);\
|
2850
|
-
|
2851
|
-
rb_define_singleton_method(class, "values", Enum_type_values, 0);
|
2852
|
-
rb_define_method(class, "initialize", Enum_type_initialize, 2);
|
2853
|
-
rb_define_method(class, "inspect", Enum_type_inspect, 0);
|
2854
|
-
return class;
|
2855
|
-
}
|
2856
|
-
|
2857
|
-
|
2858
|
-
/*
|
2859
|
-
Extern: rm_enum_new (1.8)
|
2860
|
-
Purpose: Construct a new Enum subclass instance
|
2861
|
-
*/
|
2862
|
-
VALUE
|
2863
|
-
rm_enum_new(VALUE class, VALUE sym, VALUE val)
|
2864
|
-
{
|
2865
|
-
VALUE argv[2];
|
2866
|
-
|
2867
|
-
argv[0] = sym;
|
2868
|
-
argv[1] = val;
|
2869
|
-
return rb_obj_freeze(rb_class_new_instance(2, argv, class));
|
2870
|
-
}
|
2871
|
-
|
2872
|
-
|
2873
|
-
/*
|
2874
|
-
Extern: Enum_alloc (1.8)
|
2875
|
-
Purpose: Enum class alloc function
|
2876
|
-
*/
|
2877
|
-
VALUE
|
2878
|
-
Enum_alloc(VALUE class)
|
2879
|
-
{
|
2880
|
-
MagickEnum *magick_enum;
|
2881
|
-
volatile VALUE enumr;
|
2882
|
-
|
2883
|
-
enumr = Data_Make_Struct(class, MagickEnum, NULL, NULL, magick_enum);
|
2884
|
-
rb_obj_freeze(enumr);
|
2885
|
-
return enumr;
|
2886
|
-
}
|
2887
|
-
|
2888
|
-
|
2889
|
-
/*
|
2890
|
-
Method: Enum#initialize
|
2891
|
-
Purpose: Initialize a new Enum instance
|
2892
|
-
*/
|
2893
|
-
VALUE
|
2894
|
-
Enum_initialize(VALUE self, VALUE sym, VALUE val)
|
2895
|
-
{
|
2896
|
-
MagickEnum *magick_enum;
|
2897
|
-
|
2898
|
-
Data_Get_Struct(self, MagickEnum, magick_enum);
|
2899
|
-
magick_enum->id = rb_to_id(sym); /* convert symbol to ID */
|
2900
|
-
magick_enum->val = NUM2INT(val);
|
2901
|
-
|
2902
|
-
return self;
|
2903
|
-
}
|
2904
|
-
|
2905
|
-
|
2906
|
-
/*
|
2907
|
-
Method: Enum#to_s
|
2908
|
-
Purpose: Return the name of an enum
|
2909
|
-
*/
|
2910
|
-
VALUE
|
2911
|
-
Enum_to_s(VALUE self)
|
2912
|
-
{
|
2913
|
-
MagickEnum *magick_enum;
|
2914
|
-
|
2915
|
-
Data_Get_Struct(self, MagickEnum, magick_enum);
|
2916
|
-
return rb_str_new2(rb_id2name(magick_enum->id));
|
2917
|
-
}
|
2918
|
-
|
2919
|
-
|
2920
|
-
/*
|
2921
|
-
Method: Enum#to_i
|
2922
|
-
Purpose: Return the value of an enum
|
2923
|
-
*/
|
2924
|
-
VALUE
|
2925
|
-
Enum_to_i(VALUE self)
|
2926
|
-
{
|
2927
|
-
MagickEnum *magick_enum;
|
2928
|
-
|
2929
|
-
Data_Get_Struct(self, MagickEnum, magick_enum);
|
2930
|
-
return INT2NUM(magick_enum->val);
|
2931
|
-
}
|
2932
|
-
|
2933
|
-
|
2934
|
-
/*
|
2935
|
-
Method: Enum#<=>
|
2936
|
-
Purpose: Support Comparable module in Enum
|
2937
|
-
Returns: -1, 0, 1, or nil
|
2938
|
-
Notes: Enums must be instances of the same class to be equal.
|
2939
|
-
*/
|
2940
|
-
VALUE
|
2941
|
-
Enum_spaceship(VALUE self, VALUE other)
|
2942
|
-
{
|
2943
|
-
MagickEnum *this, *that;
|
2944
|
-
|
2945
|
-
Data_Get_Struct(self, MagickEnum, this);
|
2946
|
-
Data_Get_Struct(other, MagickEnum, that);
|
2947
|
-
|
2948
|
-
if (this->val > that->val)
|
2949
|
-
{
|
2950
|
-
return INT2FIX(1);
|
2951
|
-
}
|
2952
|
-
else if (this->val < that->val)
|
2953
|
-
{
|
2954
|
-
return INT2FIX(-1);
|
2955
|
-
}
|
2956
|
-
|
2957
|
-
// Values are equal, check class.
|
2958
|
-
|
2959
|
-
return rb_funcall(CLASS_OF(self), rm_ID_spaceship, 1, CLASS_OF(other));
|
2960
|
-
}
|
2961
|
-
|
2962
|
-
|
2963
|
-
/*
|
2964
|
-
Method: Enum#===
|
2965
|
-
Purpose: "Case equal" operator for Enum
|
2966
|
-
Returns: true or false
|
2967
|
-
Notes: Yes, I know "case equal" is a misnomer.
|
2968
|
-
*/
|
2969
|
-
VALUE
|
2970
|
-
Enum_case_eq(VALUE self, VALUE other)
|
2971
|
-
{
|
2972
|
-
MagickEnum *this, *that;
|
2973
|
-
|
2974
|
-
if (CLASS_OF(self) == CLASS_OF(other))
|
2975
|
-
{
|
2976
|
-
Data_Get_Struct(self, MagickEnum, this);
|
2977
|
-
Data_Get_Struct(other, MagickEnum, that);
|
2978
|
-
return this->val == that->val ? Qtrue : Qfalse;
|
2979
|
-
}
|
2980
|
-
|
2981
|
-
return Qfalse;
|
2982
|
-
}
|
2983
|
-
|
2984
|
-
|
2985
|
-
/*
|
2986
|
-
* Method: xxx#initialize
|
2987
|
-
* Purpose: initialize method for all Enum subclasses
|
2988
|
-
*/
|
2989
|
-
VALUE
|
2990
|
-
Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
|
2991
|
-
{
|
2992
|
-
VALUE super_argv[2];
|
2993
|
-
volatile VALUE enumerators;
|
2994
|
-
|
2995
|
-
super_argv[0] = sym;
|
2996
|
-
super_argv[1] = val;
|
2997
|
-
(void) rb_call_super(2, (const VALUE *)super_argv);
|
2998
|
-
|
2999
|
-
if (rb_cvar_defined(CLASS_OF(self), rb_intern(ENUMERATORS_CLASS_VAR)) != Qtrue)
|
3000
|
-
{
|
3001
|
-
rb_cv_set(CLASS_OF(self), ENUMERATORS_CLASS_VAR, rb_ary_new());
|
3002
|
-
}
|
3003
|
-
|
3004
|
-
enumerators = rb_cv_get(CLASS_OF(self), ENUMERATORS_CLASS_VAR);
|
3005
|
-
(void) rb_ary_push(enumerators, self);
|
3006
|
-
|
3007
|
-
return self;
|
3008
|
-
}
|
3009
|
-
|
3010
|
-
|
3011
|
-
/*
|
3012
|
-
* Method: xxx#inspect
|
3013
|
-
* Purpose: Enum subclass #inspect
|
3014
|
-
*/
|
3015
|
-
static VALUE
|
3016
|
-
Enum_type_inspect(VALUE self)
|
3017
|
-
{
|
3018
|
-
char str[100];
|
3019
|
-
MagickEnum *magick_enum;
|
3020
|
-
|
3021
|
-
Data_Get_Struct(self, MagickEnum, magick_enum);
|
3022
|
-
sprintf(str, "%.32s=%d", rb_id2name(magick_enum->id), magick_enum->val);
|
3023
|
-
|
3024
|
-
return rb_str_new2(str);
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
|
3028
|
-
/*
|
3029
|
-
* Method: xxx.values
|
3030
|
-
* Purpose: Behaves like #each if a block is present, otherwise like #to_a.
|
3031
|
-
* Notes: defined for each Enum subclass
|
3032
|
-
*/
|
3033
|
-
static VALUE
|
3034
|
-
Enum_type_values(VALUE class)
|
3035
|
-
{
|
3036
|
-
volatile VALUE enumerators, copy;
|
3037
|
-
volatile VALUE rv;
|
3038
|
-
int x;
|
3039
|
-
|
3040
|
-
enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
|
3041
|
-
|
3042
|
-
if (rb_block_given_p())
|
3043
|
-
{
|
3044
|
-
for (x = 0; x < RARRAY_LEN(enumerators); x++)
|
3045
|
-
{
|
3046
|
-
(void) rb_yield(rb_ary_entry(enumerators, x));
|
3047
|
-
}
|
3048
|
-
rv = class;
|
3049
|
-
}
|
3050
|
-
else
|
3051
|
-
{
|
3052
|
-
copy = rb_ary_new2(RARRAY_LEN(enumerators));
|
3053
|
-
for (x = 0; x < RARRAY_LEN(enumerators); x++)
|
3054
|
-
{
|
3055
|
-
(void) rb_ary_push(copy, rb_ary_entry(enumerators, x));
|
3056
|
-
}
|
3057
|
-
rb_obj_freeze(copy);
|
3058
|
-
rv = copy;
|
3059
|
-
}
|
3060
|
-
|
3061
|
-
return rv;
|
3062
|
-
}
|
3063
|
-
|
3064
|
-
|
3065
|
-
/*
|
3066
|
-
Static: ComplianceType_name
|
3067
|
-
Purpose: Return the string representation of a ComplianceType value
|
3068
|
-
Notes: xMagick will OR multiple compliance types so we have to
|
3069
|
-
arbitrarily pick one name. Set the compliance argument
|
3070
|
-
to the selected value.
|
3071
|
-
*/
|
3072
|
-
static const char *
|
3073
|
-
ComplianceType_name(ComplianceType *c)
|
3074
|
-
{
|
3075
|
-
if ((*c & (SVGCompliance|X11Compliance|XPMCompliance))
|
3076
|
-
== (SVGCompliance|X11Compliance|XPMCompliance))
|
3077
|
-
{
|
3078
|
-
return "AllCompliance";
|
3079
|
-
}
|
3080
|
-
else if (*c & SVGCompliance)
|
3081
|
-
{
|
3082
|
-
*c = SVGCompliance;
|
3083
|
-
return "SVGCompliance";
|
3084
|
-
}
|
3085
|
-
else if (*c & X11Compliance)
|
3086
|
-
{
|
3087
|
-
*c = X11Compliance;
|
3088
|
-
return "X11Compliance";
|
3089
|
-
}
|
3090
|
-
else if (*c & XPMCompliance)
|
3091
|
-
{
|
3092
|
-
*c = XPMCompliance;
|
3093
|
-
return "XPMCompliance";
|
3094
|
-
}
|
3095
|
-
else if (*c == NoCompliance)
|
3096
|
-
{
|
3097
|
-
*c = NoCompliance;
|
3098
|
-
return "NoCompliance";
|
3099
|
-
}
|
3100
|
-
else
|
3101
|
-
{
|
3102
|
-
*c = UndefinedCompliance;
|
3103
|
-
return "UndefinedCompliance";
|
3104
|
-
}
|
3105
|
-
}
|
3106
|
-
|
3107
|
-
|
3108
|
-
/*
|
3109
|
-
Extern: StorageType_name
|
3110
|
-
Purpose: Return the string representation of a StorageType value
|
3111
|
-
*/
|
3112
|
-
const char *
|
3113
|
-
StorageType_name(StorageType type)
|
3114
|
-
{
|
3115
|
-
switch (type)
|
3116
|
-
{
|
3117
|
-
ENUM_TO_NAME(UndefinedPixel)
|
3118
|
-
ENUM_TO_NAME(CharPixel)
|
3119
|
-
ENUM_TO_NAME(DoublePixel)
|
3120
|
-
ENUM_TO_NAME(FloatPixel)
|
3121
|
-
ENUM_TO_NAME(IntegerPixel)
|
3122
|
-
ENUM_TO_NAME(LongPixel)
|
3123
|
-
ENUM_TO_NAME(QuantumPixel)
|
3124
|
-
ENUM_TO_NAME(ShortPixel)
|
3125
|
-
}
|
3126
|
-
|
3127
|
-
return "UndefinedPixel";
|
3128
|
-
}
|
3129
|
-
|
3130
|
-
|
3131
|
-
/*
|
3132
|
-
Static: StretchType_name
|
3133
|
-
Purpose: Return the string representation of a StretchType value
|
3134
|
-
*/
|
3135
|
-
static const char *
|
3136
|
-
StretchType_name(StretchType stretch)
|
3137
|
-
{
|
3138
|
-
switch (stretch)
|
3139
|
-
{
|
3140
|
-
ENUM_TO_NAME(UndefinedStretch)
|
3141
|
-
ENUM_TO_NAME(NormalStretch)
|
3142
|
-
ENUM_TO_NAME(UltraCondensedStretch)
|
3143
|
-
ENUM_TO_NAME(ExtraCondensedStretch)
|
3144
|
-
ENUM_TO_NAME(CondensedStretch)
|
3145
|
-
ENUM_TO_NAME(SemiCondensedStretch)
|
3146
|
-
ENUM_TO_NAME(SemiExpandedStretch)
|
3147
|
-
ENUM_TO_NAME(ExpandedStretch)
|
3148
|
-
ENUM_TO_NAME(ExtraExpandedStretch)
|
3149
|
-
ENUM_TO_NAME(UltraExpandedStretch)
|
3150
|
-
ENUM_TO_NAME(AnyStretch)
|
3151
|
-
}
|
3152
|
-
|
3153
|
-
return "UndefinedStretch";
|
3154
|
-
}
|
3155
|
-
|
3156
|
-
|
3157
|
-
/*
|
3158
|
-
Static: StyleType_name
|
3159
|
-
Purpose: Return the string representation of a StyleType value
|
3160
|
-
*/
|
3161
|
-
static const char *
|
3162
|
-
StyleType_name(StyleType style)
|
3163
|
-
{
|
3164
|
-
switch (style)
|
3165
|
-
{
|
3166
|
-
ENUM_TO_NAME(UndefinedStyle)
|
3167
|
-
ENUM_TO_NAME(NormalStyle)
|
3168
|
-
ENUM_TO_NAME(ItalicStyle)
|
3169
|
-
ENUM_TO_NAME(ObliqueStyle)
|
3170
|
-
ENUM_TO_NAME(AnyStyle)
|
3171
|
-
}
|
3172
|
-
|
3173
|
-
return "UndefinedStyle";
|
3174
|
-
}
|
3175
|
-
|
3176
|
-
|
3177
568
|
/*
|
3178
569
|
External: write_temp_image
|
3179
570
|
Purpose: Write a temporary copy of the image to the IM registry
|