rmagick 5.4.4 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +15 -0
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +16 -8
- data/CHANGELOG.md +43 -0
- data/Gemfile +20 -0
- data/Rakefile +11 -0
- data/before_install_osx.sh +1 -1
- data/ext/RMagick/extconf.rb +24 -6
- data/ext/RMagick/rmagick.h +3 -1
- data/ext/RMagick/rmdraw.cpp +10 -10
- data/ext/RMagick/rmfill.cpp +4 -4
- data/ext/RMagick/rmilist.cpp +10 -2
- data/ext/RMagick/rmimage.cpp +321 -294
- data/ext/RMagick/rminfo.cpp +22 -21
- data/ext/RMagick/rmkinfo.cpp +5 -18
- data/ext/RMagick/rmmain.cpp +30 -64
- data/ext/RMagick/rmmontage.cpp +5 -5
- data/ext/RMagick/rmpixel.cpp +1 -1
- data/ext/RMagick/rmutil.cpp +31 -71
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +67 -65
- data/lib/rvg/embellishable.rb +6 -2
- data/lib/rvg/misc.rb +7 -7
- data/lib/rvg/rvg.rb +2 -0
- data/lib/rvg/stretchable.rb +2 -2
- data/lib/rvg/transformable.rb +1 -1
- data/rmagick.gemspec +1 -13
- data/sig/rmagick/_draw_common_methods.rbs +64 -0
- data/sig/rmagick/_image_common_methods.rbs +389 -0
- data/sig/rmagick/draw.rbs +38 -0
- data/sig/rmagick/draw_attribute.rbs +28 -0
- data/sig/rmagick/enum.rbs +814 -0
- data/sig/rmagick/error.rbs +11 -0
- data/sig/rmagick/fill.rbs +21 -0
- data/sig/rmagick/geometry.rbs +14 -0
- data/sig/rmagick/image.rbs +194 -0
- data/sig/rmagick/image_list.rbs +181 -0
- data/sig/rmagick/iptc.rbs +101 -0
- data/sig/rmagick/kernel_info.rbs +12 -0
- data/sig/rmagick/optional_method_arguments.rbs +10 -0
- data/sig/rmagick/pixel.rbs +46 -0
- data/sig/rmagick/struct.rbs +90 -0
- data/sig/rmagick.rbs +43 -0
- data/sig/rvg/clippath.rbs +34 -0
- data/sig/rvg/container.rbs +78 -0
- data/sig/rvg/deep_equal.rbs +48 -0
- data/sig/rvg/describable.rbs +30 -0
- data/sig/rvg/embellishable.rbs +226 -0
- data/sig/rvg/misc.rbs +145 -0
- data/sig/rvg/paint.rbs +55 -0
- data/sig/rvg/pathdata.rbs +77 -0
- data/sig/rvg/rvg.rbs +125 -0
- data/sig/rvg/stretchable.rbs +56 -0
- data/sig/rvg/stylable.rbs +66 -0
- data/sig/rvg/text.rbs +118 -0
- data/sig/rvg/transformable.rbs +59 -0
- data/sig/rvg/units.rbs +33 -0
- metadata +32 -128
data/ext/RMagick/rminfo.cpp
CHANGED
@@ -819,8 +819,8 @@ Info_density(VALUE self)
|
|
819
819
|
/**
|
820
820
|
* Set the text rendering density geometry
|
821
821
|
*
|
822
|
-
* @param density_arg [String] the density
|
823
|
-
* @return [String] the given value
|
822
|
+
* @param density_arg [Magick::Geometry, String] the density
|
823
|
+
* @return [Magick::Geometry, String] the given value
|
824
824
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
825
825
|
*/
|
826
826
|
VALUE
|
@@ -836,7 +836,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
|
|
836
836
|
{
|
837
837
|
magick_free(info->density);
|
838
838
|
info->density = NULL;
|
839
|
-
return
|
839
|
+
return density_arg;
|
840
840
|
}
|
841
841
|
|
842
842
|
density = rb_String(density_arg);
|
@@ -1000,7 +1000,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
|
|
1000
1000
|
if (NIL_P(disp))
|
1001
1001
|
{
|
1002
1002
|
DeleteImageOption(info, "dispose");
|
1003
|
-
return
|
1003
|
+
return disp;
|
1004
1004
|
}
|
1005
1005
|
|
1006
1006
|
VALUE_TO_ENUM(disp, dispose, DisposeType);
|
@@ -1096,8 +1096,8 @@ Info_extract(VALUE self)
|
|
1096
1096
|
/**
|
1097
1097
|
* Set the extract geometry.
|
1098
1098
|
*
|
1099
|
-
* @param extract_arg [String] the extract string
|
1100
|
-
* @return [String] the given value
|
1099
|
+
* @param extract_arg [Magick::Geometry, String] the extract string
|
1100
|
+
* @return [Magick::Geometry, String] the given value
|
1101
1101
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
1102
1102
|
*/
|
1103
1103
|
VALUE
|
@@ -1113,7 +1113,7 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
|
|
1113
1113
|
{
|
1114
1114
|
magick_free(info->extract);
|
1115
1115
|
info->extract = NULL;
|
1116
|
-
return
|
1116
|
+
return extract_arg;
|
1117
1117
|
}
|
1118
1118
|
|
1119
1119
|
extract = rb_String(extract_arg);
|
@@ -1431,7 +1431,7 @@ Info_gravity_eq(VALUE self, VALUE grav)
|
|
1431
1431
|
if (NIL_P(grav))
|
1432
1432
|
{
|
1433
1433
|
DeleteImageOption(info, "gravity");
|
1434
|
-
return
|
1434
|
+
return grav;
|
1435
1435
|
}
|
1436
1436
|
|
1437
1437
|
VALUE_TO_ENUM(grav, gravity, GravityType);
|
@@ -1668,8 +1668,8 @@ Info_origin(VALUE self)
|
|
1668
1668
|
* The geometry format is
|
1669
1669
|
* +-x+-y
|
1670
1670
|
*
|
1671
|
-
* @param origin_arg [String] the origin geometry
|
1672
|
-
* @return [String] the given value
|
1671
|
+
* @param origin_arg [Magick::Geometry, String] the origin geometry
|
1672
|
+
* @return [Magick::Geometry, String] the given value
|
1673
1673
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
1674
1674
|
*/
|
1675
1675
|
VALUE
|
@@ -1684,7 +1684,7 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
|
|
1684
1684
|
if (NIL_P(origin_arg))
|
1685
1685
|
{
|
1686
1686
|
DeleteImageOption(info, "origin");
|
1687
|
-
return
|
1687
|
+
return origin_arg;
|
1688
1688
|
}
|
1689
1689
|
|
1690
1690
|
origin_str = rb_String(origin_arg);
|
@@ -1724,8 +1724,8 @@ Info_page(VALUE self)
|
|
1724
1724
|
* Store the Postscript page geometry. Argument may be a Geometry object as well
|
1725
1725
|
* as a geometry string.
|
1726
1726
|
*
|
1727
|
-
* @param page_arg [String] the geometry
|
1728
|
-
* @return [String] the given value
|
1727
|
+
* @param page_arg [Magick::Geometry, String] the geometry
|
1728
|
+
* @return [Magick::Geometry, String] the given value
|
1729
1729
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
1730
1730
|
*/
|
1731
1731
|
VALUE
|
@@ -1740,7 +1740,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
|
|
1740
1740
|
{
|
1741
1741
|
magick_free(info->page);
|
1742
1742
|
info->page = NULL;
|
1743
|
-
return
|
1743
|
+
return page_arg;
|
1744
1744
|
}
|
1745
1745
|
geom_str = rb_String(page_arg);
|
1746
1746
|
geometry = GetPageGeometry(StringValueCStr(geom_str));
|
@@ -1748,7 +1748,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
|
|
1748
1748
|
{
|
1749
1749
|
magick_free(info->page);
|
1750
1750
|
info->page = NULL;
|
1751
|
-
return
|
1751
|
+
return page_arg;
|
1752
1752
|
}
|
1753
1753
|
info->page = geometry;
|
1754
1754
|
|
@@ -1949,8 +1949,8 @@ Info_size(VALUE self)
|
|
1949
1949
|
/**
|
1950
1950
|
* Set the size (either as a Geometry object or a Geometry string
|
1951
1951
|
*
|
1952
|
-
* @param size_arg [String] the size
|
1953
|
-
* @return [String] the given value
|
1952
|
+
* @param size_arg [Magick::Geometry, String] the size
|
1953
|
+
* @return [Magick::Geometry, String] the given value
|
1954
1954
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
1955
1955
|
*/
|
1956
1956
|
VALUE
|
@@ -1966,7 +1966,7 @@ Info_size_eq(VALUE self, VALUE size_arg)
|
|
1966
1966
|
{
|
1967
1967
|
magick_free(info->size);
|
1968
1968
|
info->size = NULL;
|
1969
|
-
return
|
1969
|
+
return size_arg;
|
1970
1970
|
}
|
1971
1971
|
|
1972
1972
|
size = rb_String(size_arg);
|
@@ -2100,8 +2100,8 @@ Info_tile_offset(VALUE self)
|
|
2100
2100
|
/**
|
2101
2101
|
* Set tile offset geometry.
|
2102
2102
|
*
|
2103
|
-
* @param offset [String] the offset geometry
|
2104
|
-
* @return [String] the given value
|
2103
|
+
* @param offset [Magick::Geometry, String] the offset geometry
|
2104
|
+
* @return [Magick::Geometry, String] the given value
|
2105
2105
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
2106
2106
|
*/
|
2107
2107
|
VALUE
|
@@ -2401,7 +2401,8 @@ rm_info_new(void)
|
|
2401
2401
|
* @overload initialize
|
2402
2402
|
*
|
2403
2403
|
* @overload initialize
|
2404
|
-
* @yield [
|
2404
|
+
* @yield [info]
|
2405
|
+
* @yieldparam info [Magick::Image::Info]
|
2405
2406
|
*
|
2406
2407
|
* @return self
|
2407
2408
|
*/
|
data/ext/RMagick/rmkinfo.cpp
CHANGED
@@ -74,15 +74,13 @@ VALUE
|
|
74
74
|
KernelInfo_initialize(VALUE self, VALUE kernel_string)
|
75
75
|
{
|
76
76
|
KernelInfo *kernel;
|
77
|
+
char *string = StringValueCStr(kernel_string);
|
78
|
+
|
77
79
|
#if defined(IMAGEMAGICK_7)
|
78
80
|
ExceptionInfo *exception;
|
79
|
-
#endif
|
80
|
-
|
81
|
-
Check_Type(kernel_string, T_STRING);
|
82
81
|
|
83
|
-
#if defined(IMAGEMAGICK_7)
|
84
82
|
exception = AcquireExceptionInfo();
|
85
|
-
kernel = AcquireKernelInfo(
|
83
|
+
kernel = AcquireKernelInfo(string, exception);
|
86
84
|
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
|
87
85
|
{
|
88
86
|
if (kernel != (KernelInfo *) NULL)
|
@@ -92,7 +90,7 @@ KernelInfo_initialize(VALUE self, VALUE kernel_string)
|
|
92
90
|
rm_raise_exception(exception);
|
93
91
|
}
|
94
92
|
#else
|
95
|
-
kernel = AcquireKernelInfo(
|
93
|
+
kernel = AcquireKernelInfo(string);
|
96
94
|
#endif
|
97
95
|
|
98
96
|
if (!kernel)
|
@@ -114,9 +112,6 @@ KernelInfo_initialize(VALUE self, VALUE kernel_string)
|
|
114
112
|
VALUE
|
115
113
|
KernelInfo_unity_add(VALUE self, VALUE scale)
|
116
114
|
{
|
117
|
-
if (!FIXNUM_P(scale))
|
118
|
-
Check_Type(scale, T_FLOAT);
|
119
|
-
|
120
115
|
GVL_STRUCT_TYPE(UnityAddKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale) };
|
121
116
|
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnityAddKernelInfo), &args);
|
122
117
|
return Qnil;
|
@@ -136,13 +131,7 @@ KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
|
|
136
131
|
{
|
137
132
|
GeometryFlags geoflags;
|
138
133
|
|
139
|
-
|
140
|
-
Check_Type(scale, T_FLOAT);
|
141
|
-
|
142
|
-
if (rb_obj_is_instance_of(flags, Class_GeometryFlags))
|
143
|
-
VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
|
144
|
-
else
|
145
|
-
rb_raise(rb_eArgError, "expected Integer or Magick::GeometryFlags to specify flags");
|
134
|
+
VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
|
146
135
|
|
147
136
|
GVL_STRUCT_TYPE(ScaleKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags };
|
148
137
|
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleKernelInfo), &args);
|
@@ -158,7 +147,6 @@ KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
|
|
158
147
|
VALUE
|
159
148
|
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
|
160
149
|
{
|
161
|
-
Check_Type(geometry, T_STRING);
|
162
150
|
GVL_STRUCT_TYPE(ScaleGeometryKernelInfo) args = { (KernelInfo*)DATA_PTR(self), StringValueCStr(geometry) };
|
163
151
|
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleGeometryKernelInfo), &args);
|
164
152
|
return Qnil;
|
@@ -195,7 +183,6 @@ KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
|
|
195
183
|
ExceptionInfo *exception;
|
196
184
|
#endif
|
197
185
|
|
198
|
-
Check_Type(geometry, T_STRING);
|
199
186
|
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
|
200
187
|
ParseGeometry(StringValueCStr(geometry), &info);
|
201
188
|
|
data/ext/RMagick/rmmain.cpp
CHANGED
@@ -653,30 +653,33 @@ Init_RMagick2(void)
|
|
653
653
|
rb_define_alloc_func(Class_Draw, Draw_alloc);
|
654
654
|
|
655
655
|
// Define the attributes
|
656
|
-
|
657
|
-
rb_define_method(
|
658
|
-
rb_define_method(
|
659
|
-
rb_define_method(
|
660
|
-
rb_define_method(
|
661
|
-
rb_define_method(
|
662
|
-
rb_define_method(
|
663
|
-
rb_define_method(
|
664
|
-
rb_define_method(
|
665
|
-
rb_define_method(
|
666
|
-
rb_define_method(
|
667
|
-
rb_define_method(
|
668
|
-
rb_define_method(
|
669
|
-
rb_define_method(
|
670
|
-
rb_define_method(
|
671
|
-
rb_define_method(
|
672
|
-
rb_define_method(
|
673
|
-
rb_define_method(
|
674
|
-
rb_define_method(
|
675
|
-
rb_define_method(
|
676
|
-
rb_define_method(
|
677
|
-
rb_define_method(
|
678
|
-
rb_define_method(
|
679
|
-
rb_define_method(
|
656
|
+
Module_DrawAttribute = rb_define_module_under(Module_Magick, "DrawAttribute");
|
657
|
+
rb_define_method(Module_DrawAttribute, "affine=", RUBY_METHOD_FUNC(Draw_affine_eq), 1);
|
658
|
+
rb_define_method(Module_DrawAttribute, "align=", RUBY_METHOD_FUNC(Draw_align_eq), 1);
|
659
|
+
rb_define_method(Module_DrawAttribute, "decorate=", RUBY_METHOD_FUNC(Draw_decorate_eq), 1);
|
660
|
+
rb_define_method(Module_DrawAttribute, "density=", RUBY_METHOD_FUNC(Draw_density_eq), 1);
|
661
|
+
rb_define_method(Module_DrawAttribute, "encoding=", RUBY_METHOD_FUNC(Draw_encoding_eq), 1);
|
662
|
+
rb_define_method(Module_DrawAttribute, "fill=", RUBY_METHOD_FUNC(Draw_fill_eq), 1);
|
663
|
+
rb_define_method(Module_DrawAttribute, "fill_pattern=", RUBY_METHOD_FUNC(Draw_fill_pattern_eq), 1);
|
664
|
+
rb_define_method(Module_DrawAttribute, "font=", RUBY_METHOD_FUNC(Draw_font_eq), 1);
|
665
|
+
rb_define_method(Module_DrawAttribute, "font_family=", RUBY_METHOD_FUNC(Draw_font_family_eq), 1);
|
666
|
+
rb_define_method(Module_DrawAttribute, "font_stretch=", RUBY_METHOD_FUNC(Draw_font_stretch_eq), 1);
|
667
|
+
rb_define_method(Module_DrawAttribute, "font_style=", RUBY_METHOD_FUNC(Draw_font_style_eq), 1);
|
668
|
+
rb_define_method(Module_DrawAttribute, "font_weight=", RUBY_METHOD_FUNC(Draw_font_weight_eq), 1);
|
669
|
+
rb_define_method(Module_DrawAttribute, "gravity=", RUBY_METHOD_FUNC(Draw_gravity_eq), 1);
|
670
|
+
rb_define_method(Module_DrawAttribute, "interline_spacing=", RUBY_METHOD_FUNC(Draw_interline_spacing_eq), 1);
|
671
|
+
rb_define_method(Module_DrawAttribute, "interword_spacing=", RUBY_METHOD_FUNC(Draw_interword_spacing_eq), 1);
|
672
|
+
rb_define_method(Module_DrawAttribute, "kerning=", RUBY_METHOD_FUNC(Draw_kerning_eq), 1);
|
673
|
+
rb_define_method(Module_DrawAttribute, "pointsize=", RUBY_METHOD_FUNC(Draw_pointsize_eq), 1);
|
674
|
+
rb_define_method(Module_DrawAttribute, "rotation=", RUBY_METHOD_FUNC(Draw_rotation_eq), 1);
|
675
|
+
rb_define_method(Module_DrawAttribute, "stroke=", RUBY_METHOD_FUNC(Draw_stroke_eq), 1);
|
676
|
+
rb_define_method(Module_DrawAttribute, "stroke_pattern=", RUBY_METHOD_FUNC(Draw_stroke_pattern_eq), 1);
|
677
|
+
rb_define_method(Module_DrawAttribute, "stroke_width=", RUBY_METHOD_FUNC(Draw_stroke_width_eq), 1);
|
678
|
+
rb_define_method(Module_DrawAttribute, "text_antialias=", RUBY_METHOD_FUNC(Draw_text_antialias_eq), 1);
|
679
|
+
rb_define_method(Module_DrawAttribute, "tile=", RUBY_METHOD_FUNC(Draw_tile_eq), 1);
|
680
|
+
rb_define_method(Module_DrawAttribute, "undercolor=", RUBY_METHOD_FUNC(Draw_undercolor_eq), 1);
|
681
|
+
|
682
|
+
rb_include_module(Class_Draw, Module_DrawAttribute);
|
680
683
|
|
681
684
|
rb_define_method(Class_Draw, "annotate", RUBY_METHOD_FUNC(Draw_annotate), 6);
|
682
685
|
rb_define_method(Class_Draw, "clone", RUBY_METHOD_FUNC(Draw_clone), 0);
|
@@ -704,27 +707,8 @@ Init_RMagick2(void)
|
|
704
707
|
|
705
708
|
rb_define_method(Class_DrawOptions, "initialize", RUBY_METHOD_FUNC(DrawOptions_initialize), 0);
|
706
709
|
|
707
|
-
|
708
|
-
|
709
|
-
rb_define_method(Class_DrawOptions, "decorate=", RUBY_METHOD_FUNC(Draw_decorate_eq), 1);
|
710
|
-
rb_define_method(Class_DrawOptions, "density=", RUBY_METHOD_FUNC(Draw_density_eq), 1);
|
711
|
-
rb_define_method(Class_DrawOptions, "encoding=", RUBY_METHOD_FUNC(Draw_encoding_eq), 1);
|
712
|
-
rb_define_method(Class_DrawOptions, "fill=", RUBY_METHOD_FUNC(Draw_fill_eq), 1);
|
713
|
-
rb_define_method(Class_DrawOptions, "fill_pattern=", RUBY_METHOD_FUNC(Draw_fill_pattern_eq), 1);
|
714
|
-
rb_define_method(Class_DrawOptions, "font=", RUBY_METHOD_FUNC(Draw_font_eq), 1);
|
715
|
-
rb_define_method(Class_DrawOptions, "font_family=", RUBY_METHOD_FUNC(Draw_font_family_eq), 1);
|
716
|
-
rb_define_method(Class_DrawOptions, "font_stretch=", RUBY_METHOD_FUNC(Draw_font_stretch_eq), 1);
|
717
|
-
rb_define_method(Class_DrawOptions, "font_style=", RUBY_METHOD_FUNC(Draw_font_style_eq), 1);
|
718
|
-
rb_define_method(Class_DrawOptions, "font_weight=", RUBY_METHOD_FUNC(Draw_font_weight_eq), 1);
|
719
|
-
rb_define_method(Class_DrawOptions, "gravity=", RUBY_METHOD_FUNC(Draw_gravity_eq), 1);
|
720
|
-
rb_define_method(Class_DrawOptions, "pointsize=", RUBY_METHOD_FUNC(Draw_pointsize_eq), 1);
|
721
|
-
rb_define_method(Class_DrawOptions, "rotation=", RUBY_METHOD_FUNC(Draw_rotation_eq), 1);
|
722
|
-
rb_define_method(Class_DrawOptions, "stroke=", RUBY_METHOD_FUNC(Draw_stroke_eq), 1);
|
723
|
-
rb_define_method(Class_DrawOptions, "stroke_pattern=", RUBY_METHOD_FUNC(Draw_stroke_pattern_eq), 1);
|
724
|
-
rb_define_method(Class_DrawOptions, "stroke_width=", RUBY_METHOD_FUNC(Draw_stroke_width_eq), 1);
|
725
|
-
rb_define_method(Class_DrawOptions, "text_antialias=", RUBY_METHOD_FUNC(Draw_text_antialias_eq), 1);
|
726
|
-
rb_define_method(Class_DrawOptions, "tile=", RUBY_METHOD_FUNC(Draw_tile_eq), 1);
|
727
|
-
rb_define_method(Class_DrawOptions, "undercolor=", RUBY_METHOD_FUNC(Draw_undercolor_eq), 1);
|
710
|
+
rb_include_module(Class_DrawOptions, Module_DrawAttribute);
|
711
|
+
|
728
712
|
|
729
713
|
/*-----------------------------------------------------------------------*/
|
730
714
|
/* Class Magick::Pixel */
|
@@ -948,25 +932,7 @@ Init_RMagick2(void)
|
|
948
932
|
rb_define_method(Class_PolaroidOptions, "border_color=", RUBY_METHOD_FUNC(PolaroidOptions_border_color_eq), 1);
|
949
933
|
|
950
934
|
// The other attribute writer methods are implemented by Draw's functions
|
951
|
-
|
952
|
-
rb_define_method(Class_PolaroidOptions, "decorate=", RUBY_METHOD_FUNC(Draw_decorate_eq), 1);
|
953
|
-
rb_define_method(Class_PolaroidOptions, "density=", RUBY_METHOD_FUNC(Draw_density_eq), 1);
|
954
|
-
rb_define_method(Class_PolaroidOptions, "encoding=", RUBY_METHOD_FUNC(Draw_encoding_eq), 1);
|
955
|
-
rb_define_method(Class_PolaroidOptions, "fill=", RUBY_METHOD_FUNC(Draw_fill_eq), 1);
|
956
|
-
rb_define_method(Class_PolaroidOptions, "fill_pattern=", RUBY_METHOD_FUNC(Draw_fill_pattern_eq), 1);
|
957
|
-
rb_define_method(Class_PolaroidOptions, "font=", RUBY_METHOD_FUNC(Draw_font_eq), 1);
|
958
|
-
rb_define_method(Class_PolaroidOptions, "font_family=", RUBY_METHOD_FUNC(Draw_font_family_eq), 1);
|
959
|
-
rb_define_method(Class_PolaroidOptions, "font_stretch=", RUBY_METHOD_FUNC(Draw_font_stretch_eq), 1);
|
960
|
-
rb_define_method(Class_PolaroidOptions, "font_style=", RUBY_METHOD_FUNC(Draw_font_style_eq), 1);
|
961
|
-
rb_define_method(Class_PolaroidOptions, "font_weight=", RUBY_METHOD_FUNC(Draw_font_weight_eq), 1);
|
962
|
-
rb_define_method(Class_PolaroidOptions, "gravity=", RUBY_METHOD_FUNC(Draw_gravity_eq), 1);
|
963
|
-
rb_define_method(Class_PolaroidOptions, "pointsize=", RUBY_METHOD_FUNC(Draw_pointsize_eq), 1);
|
964
|
-
rb_define_method(Class_PolaroidOptions, "stroke=", RUBY_METHOD_FUNC(Draw_stroke_eq), 1);
|
965
|
-
rb_define_method(Class_PolaroidOptions, "stroke_pattern=", RUBY_METHOD_FUNC(Draw_stroke_pattern_eq), 1);
|
966
|
-
rb_define_method(Class_PolaroidOptions, "stroke_width=", RUBY_METHOD_FUNC(Draw_stroke_width_eq), 1);
|
967
|
-
rb_define_method(Class_PolaroidOptions, "text_antialias=", RUBY_METHOD_FUNC(Draw_text_antialias_eq), 1);
|
968
|
-
rb_define_method(Class_PolaroidOptions, "undercolor=", RUBY_METHOD_FUNC(Draw_undercolor_eq), 1);
|
969
|
-
|
935
|
+
rb_include_module(Class_PolaroidOptions, Module_DrawAttribute);
|
970
936
|
|
971
937
|
/*-----------------------------------------------------------------------*/
|
972
938
|
/* Magick::******Fill classes and methods */
|
data/ext/RMagick/rmmontage.cpp
CHANGED
@@ -235,7 +235,7 @@ Montage_font_eq(VALUE self, VALUE font)
|
|
235
235
|
* <width>x<height>+<outer-bevel-width>+<inner-bevel-width>
|
236
236
|
* or a Geometry object
|
237
237
|
*
|
238
|
-
* @param frame_arg [String] the frame geometry
|
238
|
+
* @param frame_arg [Magick::Geometry, String] the frame geometry
|
239
239
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
240
240
|
*/
|
241
241
|
VALUE
|
@@ -261,8 +261,8 @@ Montage_frame_eq(VALUE self, VALUE frame_arg)
|
|
261
261
|
* <width>x<height>+<outer-bevel-width>+<inner-bevel-width>
|
262
262
|
* or a Geometry object
|
263
263
|
*
|
264
|
-
* @param geometry_arg [String] the geometry
|
265
|
-
* @return [String] the given geometry
|
264
|
+
* @param geometry_arg [Magick::Geometry, String] the geometry
|
265
|
+
* @return [Magick::Geometry, String] the given geometry
|
266
266
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
267
267
|
*/
|
268
268
|
VALUE
|
@@ -422,8 +422,8 @@ Montage_texture_eq(VALUE self, VALUE texture)
|
|
422
422
|
* <width>x<height>+<outer-bevel-width>+<inner-bevel-width>
|
423
423
|
* or a Geometry object
|
424
424
|
*
|
425
|
-
* @param tile_arg [String] the tile geometry
|
426
|
-
* @return [String] the given tile geometry
|
425
|
+
* @param tile_arg [Magick::Geometry, String] the tile geometry
|
426
|
+
* @return [Magick::Geometry, String] the given tile geometry
|
427
427
|
* @see https://www.imagemagick.org/Magick++/Geometry.html
|
428
428
|
*/
|
429
429
|
VALUE
|
data/ext/RMagick/rmpixel.cpp
CHANGED
@@ -595,7 +595,7 @@ Pixel_eql_q(VALUE self, VALUE other)
|
|
595
595
|
* Compare pixel values for equality.
|
596
596
|
*
|
597
597
|
* @overload fcmp(other, fuzz = 0.0, colorspace = Magick::RGBColorspace)
|
598
|
-
* @param other [Magick::Pixel] The pixel to which the receiver is compared
|
598
|
+
* @param other [Magick::Pixel, String] The pixel to which the receiver is compared
|
599
599
|
* @param fuzz [Numeric] The amount of fuzz to allow before the colors are considered to be different
|
600
600
|
* @param colorspace [Magick::ColorspaceType] The colorspace
|
601
601
|
* @return [Boolean] true if equal, otherwise false
|
data/ext/RMagick/rmutil.cpp
CHANGED
@@ -360,49 +360,23 @@ rescue_not_str(VALUE arg, VALUE raised_exc ATTRIBUTE_UNUSED)
|
|
360
360
|
*
|
361
361
|
* @param arg the argument
|
362
362
|
* @param max the maximum allowed value
|
363
|
+
* @param only_positive Accept whether only positive numbers?
|
363
364
|
* @return a double
|
364
365
|
*/
|
365
366
|
double
|
366
|
-
|
367
|
+
rm_percentage2(VALUE arg, double max, bool only_positive)
|
367
368
|
{
|
368
369
|
double pct;
|
369
370
|
char *end;
|
370
371
|
|
371
372
|
if (!rm_check_num2dbl(arg))
|
372
373
|
{
|
373
|
-
|
374
|
-
long pct_long;
|
375
|
-
|
376
|
-
arg = rb_rescue(RESCUE_FUNC(rb_str_to_str), arg, RESCUE_EXCEPTION_HANDLER_FUNC(rescue_not_str), arg);
|
377
|
-
pct_str = StringValueCStr(arg);
|
378
|
-
errno = 0;
|
379
|
-
pct_long = strtol(pct_str, &end, 10);
|
380
|
-
if (errno == ERANGE)
|
381
|
-
{
|
382
|
-
rb_raise(rb_eRangeError, "`%s' out of range", pct_str);
|
383
|
-
}
|
384
|
-
if (*end != '\0' && *end != '%')
|
385
|
-
{
|
386
|
-
rb_raise(rb_eArgError, "expected percentage, got `%s'", pct_str);
|
387
|
-
}
|
388
|
-
|
389
|
-
if (*end == '%' && pct_long != 0)
|
390
|
-
{
|
391
|
-
pct = (((double)pct_long) / 100.0) * max;
|
392
|
-
}
|
393
|
-
else
|
394
|
-
{
|
395
|
-
pct = (double) pct_long;
|
396
|
-
}
|
397
|
-
if (pct < 0.0)
|
398
|
-
{
|
399
|
-
rb_raise(rb_eArgError, "percentages may not be negative (got `%s')", pct_str);
|
400
|
-
}
|
374
|
+
pct = rm_str_to_pct(arg, only_positive) * max;
|
401
375
|
}
|
402
376
|
else
|
403
377
|
{
|
404
378
|
pct = NUM2DBL(arg);
|
405
|
-
if (pct < 0.0)
|
379
|
+
if (pct < 0.0 && only_positive)
|
406
380
|
{
|
407
381
|
rb_raise(rb_eArgError, "percentages may not be negative (got `%g')", pct);
|
408
382
|
}
|
@@ -412,6 +386,24 @@ rm_percentage(VALUE arg, double max)
|
|
412
386
|
}
|
413
387
|
|
414
388
|
|
389
|
+
/**
|
390
|
+
* Return a double between 0.0 and max (the second argument), inclusive. If the
|
391
|
+
* argument is a number convert to a Float object, otherwise it's supposed to be
|
392
|
+
* a string in the form * "NN%". Convert to a number and then to a Float.
|
393
|
+
*
|
394
|
+
* No Ruby usage (internal function)
|
395
|
+
*
|
396
|
+
* @param arg the argument
|
397
|
+
* @param max the maximum allowed value
|
398
|
+
* @return a double
|
399
|
+
*/
|
400
|
+
double
|
401
|
+
rm_percentage(VALUE arg, double max)
|
402
|
+
{
|
403
|
+
return rm_percentage2(arg, max, true);
|
404
|
+
}
|
405
|
+
|
406
|
+
|
415
407
|
/**
|
416
408
|
* Return 0 if rb_num2dbl doesn't raise an exception.
|
417
409
|
*
|
@@ -464,10 +456,11 @@ rm_check_num2dbl(VALUE obj)
|
|
464
456
|
* No Ruby usage (internal function)
|
465
457
|
*
|
466
458
|
* @param str the string
|
459
|
+
* @param only_positive Accept whether only positive numbers?
|
467
460
|
* @return a double
|
468
461
|
*/
|
469
462
|
double
|
470
|
-
rm_str_to_pct(VALUE str)
|
463
|
+
rm_str_to_pct(VALUE str, bool only_positive)
|
471
464
|
{
|
472
465
|
long pct;
|
473
466
|
char *pct_str, *end;
|
@@ -485,7 +478,7 @@ rm_str_to_pct(VALUE str)
|
|
485
478
|
{
|
486
479
|
rb_raise(rb_eArgError, "expected percentage, got `%s'", pct_str);
|
487
480
|
}
|
488
|
-
if (pct < 0L)
|
481
|
+
if (pct < 0L && only_positive)
|
489
482
|
{
|
490
483
|
rb_raise(rb_eArgError, "percentages may not be negative (got `%s')", pct_str);
|
491
484
|
}
|
@@ -508,45 +501,7 @@ rm_str_to_pct(VALUE str)
|
|
508
501
|
double
|
509
502
|
rm_fuzz_to_dbl(VALUE fuzz_arg)
|
510
503
|
{
|
511
|
-
|
512
|
-
char *end;
|
513
|
-
|
514
|
-
if (!rm_check_num2dbl(fuzz_arg))
|
515
|
-
{
|
516
|
-
char *fuzz_str;
|
517
|
-
|
518
|
-
// Convert to string, issue error message if failure.
|
519
|
-
fuzz_arg = rb_rescue(RESCUE_FUNC(rb_str_to_str), fuzz_arg, RESCUE_EXCEPTION_HANDLER_FUNC(rescue_not_str), fuzz_arg);
|
520
|
-
fuzz_str = StringValueCStr(fuzz_arg);
|
521
|
-
errno = 0;
|
522
|
-
fuzz = strtod(fuzz_str, &end);
|
523
|
-
if (errno == ERANGE)
|
524
|
-
{
|
525
|
-
rb_raise(rb_eRangeError, "`%s' out of range", fuzz_str);
|
526
|
-
}
|
527
|
-
if(*end == '%')
|
528
|
-
{
|
529
|
-
if (fuzz < 0.0)
|
530
|
-
{
|
531
|
-
rb_raise(rb_eArgError, "percentages may not be negative (got `%s')", fuzz_str);
|
532
|
-
}
|
533
|
-
fuzz = (fuzz * QuantumRange) / 100.0;
|
534
|
-
}
|
535
|
-
else if(*end != '\0')
|
536
|
-
{
|
537
|
-
rb_raise(rb_eArgError, "expected percentage, got `%s'", fuzz_str);
|
538
|
-
}
|
539
|
-
}
|
540
|
-
else
|
541
|
-
{
|
542
|
-
fuzz = NUM2DBL(fuzz_arg);
|
543
|
-
if (fuzz < 0.0)
|
544
|
-
{
|
545
|
-
rb_raise(rb_eArgError, "fuzz may not be negative (got `%g')", fuzz);
|
546
|
-
}
|
547
|
-
}
|
548
|
-
|
549
|
-
return fuzz;
|
504
|
+
return rm_percentage(fuzz_arg, QuantumRange);
|
550
505
|
}
|
551
506
|
|
552
507
|
|
@@ -1262,6 +1217,11 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1262
1217
|
}
|
1263
1218
|
|
1264
1219
|
copy_options(image, info);
|
1220
|
+
|
1221
|
+
#if defined(IMAGEMAGICK_7)
|
1222
|
+
// The value of info->compression is referenced when saving the image in ImageMagick 7.
|
1223
|
+
info->compression = image->compression;
|
1224
|
+
#endif
|
1265
1225
|
}
|
1266
1226
|
|
1267
1227
|
|