rmagick 4.2.6 → 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/.devcontainer/ImageMagick6/devcontainer.json +1 -1
- data/.devcontainer/{ImageMagick7/devcontainer.json → devcontainer.json} +2 -2
- data/.devcontainer/setup-user.sh +1 -1
- data/.editorconfig +1 -1
- data/.github/workflows/ci.yml +87 -9
- data/.gitignore +4 -0
- data/.rubocop_todo.yml +16 -9
- data/.yardopts +1 -1
- data/CHANGELOG.md +130 -0
- data/Gemfile +20 -0
- data/README.md +10 -17
- data/Rakefile +63 -80
- data/before_install_linux.sh +3 -3
- data/before_install_osx.sh +6 -5
- data/ext/RMagick/extconf.rb +112 -52
- data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
- data/ext/RMagick/rmagick.h +88 -59
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +170 -159
- data/ext/RMagick/{rmenum.c → rmenum.cpp} +69 -50
- data/ext/RMagick/{rmfill.c → rmfill.cpp} +85 -24
- data/ext/RMagick/{rmilist.c → rmilist.cpp} +191 -93
- data/ext/RMagick/{rmimage.c → rmimage.cpp} +1543 -989
- data/ext/RMagick/{rminfo.c → rminfo.cpp} +140 -152
- data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +46 -34
- data/ext/RMagick/rmmain.cpp +1923 -0
- data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +50 -29
- data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +108 -83
- data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +6 -6
- data/ext/RMagick/{rmutil.c → rmutil.cpp} +62 -161
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +76 -110
- 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 +4 -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 +59 -129
- data/.codeclimate.yml +0 -63
- data/deprecated/RMagick.rb +0 -6
- data/ext/RMagick/rmmain.c +0 -1951
@@ -5,25 +5,51 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmdraw.
|
9
|
-
* @version $Id: rmdraw.
|
8
|
+
* @file rmdraw.cpp
|
9
|
+
* @version $Id: rmdraw.cpp,v 1.83 2009/12/20 02:33:33 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
#include "float.h"
|
15
15
|
|
16
|
-
|
17
|
-
static void
|
16
|
+
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
17
|
+
static void Draw_compact(void *drawptr);
|
18
|
+
#endif
|
19
|
+
static void Draw_mark(void *);
|
20
|
+
static void Draw_destroy(void *);
|
21
|
+
static size_t Draw_memsize(const void *);
|
18
22
|
static VALUE new_DrawOptions(void);
|
23
|
+
static VALUE get_type_metrics(int, VALUE *, VALUE, gvl_function_t);
|
24
|
+
|
25
|
+
const rb_data_type_t rm_draw_data_type = {
|
26
|
+
"Magick::Draw",
|
27
|
+
{
|
28
|
+
Draw_mark,
|
29
|
+
Draw_destroy,
|
30
|
+
Draw_memsize,
|
31
|
+
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
32
|
+
Draw_compact,
|
33
|
+
#endif
|
34
|
+
},
|
35
|
+
0, 0,
|
36
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
37
|
+
};
|
38
|
+
|
19
39
|
|
20
|
-
|
40
|
+
DEFINE_GVL_STUB4(BlobToImage, const ImageInfo *, const void *, const size_t, ExceptionInfo *);
|
41
|
+
DEFINE_GVL_STUB4(ImageToBlob, const ImageInfo *, Image *, size_t *, ExceptionInfo *);
|
21
42
|
#if defined(IMAGEMAGICK_7)
|
22
|
-
|
43
|
+
DEFINE_GVL_STUB3(AnnotateImage, Image *, const DrawInfo *, ExceptionInfo *);
|
44
|
+
DEFINE_GVL_STUB3(DrawImage, Image *, const DrawInfo *, ExceptionInfo *);
|
45
|
+
DEFINE_GVL_STUB4(GetMultilineTypeMetrics, Image *, const DrawInfo *, TypeMetric *, ExceptionInfo *);
|
46
|
+
DEFINE_GVL_STUB4(GetTypeMetrics, Image *, const DrawInfo *, TypeMetric *, ExceptionInfo *);
|
23
47
|
#else
|
24
|
-
|
48
|
+
DEFINE_GVL_STUB2(AnnotateImage, Image *, const DrawInfo *);
|
49
|
+
DEFINE_GVL_STUB2(DrawImage, Image *, const DrawInfo *);
|
50
|
+
DEFINE_GVL_STUB3(GetMultilineTypeMetrics, Image *, const DrawInfo *, TypeMetric *);
|
51
|
+
DEFINE_GVL_STUB3(GetTypeMetrics, Image *, const DrawInfo *, TypeMetric *);
|
25
52
|
#endif
|
26
|
-
static VALUE get_type_metrics(int, VALUE *, VALUE, get_type_metrics_func_t);
|
27
53
|
|
28
54
|
|
29
55
|
/**
|
@@ -38,7 +64,7 @@ Draw_affine_eq(VALUE self, VALUE matrix)
|
|
38
64
|
Draw *draw;
|
39
65
|
|
40
66
|
rb_check_frozen(self);
|
41
|
-
|
67
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
42
68
|
Export_AffineMatrix(&draw->info->affine, matrix);
|
43
69
|
return matrix;
|
44
70
|
}
|
@@ -56,7 +82,7 @@ Draw_align_eq(VALUE self, VALUE align)
|
|
56
82
|
Draw *draw;
|
57
83
|
|
58
84
|
rb_check_frozen(self);
|
59
|
-
|
85
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
60
86
|
VALUE_TO_ENUM(align, draw->info->align, AlignType);
|
61
87
|
return align;
|
62
88
|
}
|
@@ -74,7 +100,7 @@ Draw_decorate_eq(VALUE self, VALUE decorate)
|
|
74
100
|
Draw *draw;
|
75
101
|
|
76
102
|
rb_check_frozen(self);
|
77
|
-
|
103
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
78
104
|
VALUE_TO_ENUM(decorate, draw->info->decorate, DecorationType);
|
79
105
|
return decorate;
|
80
106
|
}
|
@@ -92,7 +118,7 @@ Draw_density_eq(VALUE self, VALUE density)
|
|
92
118
|
Draw *draw;
|
93
119
|
|
94
120
|
rb_check_frozen(self);
|
95
|
-
|
121
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
96
122
|
magick_clone_string(&draw->info->density, StringValueCStr(density));
|
97
123
|
|
98
124
|
return density;
|
@@ -111,7 +137,7 @@ Draw_encoding_eq(VALUE self, VALUE encoding)
|
|
111
137
|
Draw *draw;
|
112
138
|
|
113
139
|
rb_check_frozen(self);
|
114
|
-
|
140
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
115
141
|
magick_clone_string(&draw->info->encoding, StringValueCStr(encoding));
|
116
142
|
|
117
143
|
return encoding;
|
@@ -130,7 +156,7 @@ Draw_fill_eq(VALUE self, VALUE fill)
|
|
130
156
|
Draw *draw;
|
131
157
|
|
132
158
|
rb_check_frozen(self);
|
133
|
-
|
159
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
134
160
|
Color_to_PixelColor(&draw->info->fill, fill);
|
135
161
|
return fill;
|
136
162
|
}
|
@@ -151,7 +177,7 @@ Draw_fill_pattern_eq(VALUE self, VALUE pattern)
|
|
151
177
|
Draw *draw;
|
152
178
|
|
153
179
|
rb_check_frozen(self);
|
154
|
-
|
180
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
155
181
|
|
156
182
|
if (draw->info->fill_pattern != NULL)
|
157
183
|
{
|
@@ -186,7 +212,7 @@ Draw_font_eq(VALUE self, VALUE font)
|
|
186
212
|
Draw *draw;
|
187
213
|
|
188
214
|
rb_check_frozen(self);
|
189
|
-
|
215
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
190
216
|
magick_clone_string(&draw->info->font, StringValueCStr(font));
|
191
217
|
|
192
218
|
return font;
|
@@ -205,7 +231,7 @@ Draw_font_family_eq(VALUE self, VALUE family)
|
|
205
231
|
Draw *draw;
|
206
232
|
|
207
233
|
rb_check_frozen(self);
|
208
|
-
|
234
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
209
235
|
magick_clone_string(&draw->info->family, StringValueCStr(family));
|
210
236
|
|
211
237
|
return family;
|
@@ -224,7 +250,7 @@ Draw_font_stretch_eq(VALUE self, VALUE stretch)
|
|
224
250
|
Draw *draw;
|
225
251
|
|
226
252
|
rb_check_frozen(self);
|
227
|
-
|
253
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
228
254
|
VALUE_TO_ENUM(stretch, draw->info->stretch, StretchType);
|
229
255
|
return stretch;
|
230
256
|
}
|
@@ -242,7 +268,7 @@ Draw_font_style_eq(VALUE self, VALUE style)
|
|
242
268
|
Draw *draw;
|
243
269
|
|
244
270
|
rb_check_frozen(self);
|
245
|
-
|
271
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
246
272
|
VALUE_TO_ENUM(style, draw->info->style, StyleType);
|
247
273
|
return style;
|
248
274
|
}
|
@@ -262,14 +288,14 @@ Draw_font_weight_eq(VALUE self, VALUE weight)
|
|
262
288
|
size_t w;
|
263
289
|
|
264
290
|
rb_check_frozen(self);
|
265
|
-
|
291
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
266
292
|
|
267
293
|
if (FIXNUM_P(weight))
|
268
294
|
{
|
269
295
|
w = FIX2INT(weight);
|
270
296
|
if (w < 100 || w > 900)
|
271
297
|
{
|
272
|
-
rb_raise(rb_eArgError, "invalid font weight (%"RMIuSIZE" given)", w);
|
298
|
+
rb_raise(rb_eArgError, "invalid font weight (%" RMIuSIZE " given)", w);
|
273
299
|
}
|
274
300
|
draw->info->weight = w;
|
275
301
|
}
|
@@ -328,7 +354,7 @@ Draw_gravity_eq(VALUE self, VALUE grav)
|
|
328
354
|
Draw *draw;
|
329
355
|
|
330
356
|
rb_check_frozen(self);
|
331
|
-
|
357
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
332
358
|
VALUE_TO_ENUM(grav, draw->info->gravity, GravityType);
|
333
359
|
|
334
360
|
return grav;
|
@@ -347,7 +373,7 @@ Draw_kerning_eq(VALUE self, VALUE kerning)
|
|
347
373
|
Draw *draw;
|
348
374
|
|
349
375
|
rb_check_frozen(self);
|
350
|
-
|
376
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
351
377
|
draw->info->kerning = NUM2DBL(kerning);
|
352
378
|
return kerning;
|
353
379
|
}
|
@@ -365,7 +391,7 @@ Draw_interline_spacing_eq(VALUE self, VALUE spacing)
|
|
365
391
|
Draw *draw;
|
366
392
|
|
367
393
|
rb_check_frozen(self);
|
368
|
-
|
394
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
369
395
|
draw->info->interline_spacing = NUM2DBL(spacing);
|
370
396
|
return spacing;
|
371
397
|
}
|
@@ -383,7 +409,7 @@ Draw_interword_spacing_eq(VALUE self, VALUE spacing)
|
|
383
409
|
Draw *draw;
|
384
410
|
|
385
411
|
rb_check_frozen(self);
|
386
|
-
|
412
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
387
413
|
draw->info->interword_spacing = NUM2DBL(spacing);
|
388
414
|
return spacing;
|
389
415
|
}
|
@@ -415,7 +441,8 @@ image_to_str(Image *image)
|
|
415
441
|
|
416
442
|
info = CloneImageInfo(NULL);
|
417
443
|
exception = AcquireExceptionInfo();
|
418
|
-
|
444
|
+
GVL_STRUCT_TYPE(ImageToBlob) args = { info, image, &length, exception };
|
445
|
+
blob = (unsigned char *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImageToBlob), &args);
|
419
446
|
DestroyImageInfo(info);
|
420
447
|
CHECK_EXCEPTION();
|
421
448
|
DestroyExceptionInfo(exception);
|
@@ -453,7 +480,8 @@ Image *str_to_image(VALUE str)
|
|
453
480
|
|
454
481
|
info = CloneImageInfo(NULL);
|
455
482
|
exception = AcquireExceptionInfo();
|
456
|
-
|
483
|
+
GVL_STRUCT_TYPE(BlobToImage) args = { info, RSTRING_PTR(str), (size_t)RSTRING_LEN(str), exception };
|
484
|
+
image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
|
457
485
|
DestroyImageInfo(info);
|
458
486
|
CHECK_EXCEPTION();
|
459
487
|
DestroyExceptionInfo(exception);
|
@@ -482,7 +510,7 @@ Draw_marshal_dump(VALUE self)
|
|
482
510
|
Draw *draw;
|
483
511
|
VALUE ddraw;
|
484
512
|
|
485
|
-
|
513
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
486
514
|
|
487
515
|
// Raise an exception if the Draw has a non-NULL gradient or element_reference field
|
488
516
|
if (draw->info->element_reference.type != UndefinedReference
|
@@ -493,31 +521,17 @@ Draw_marshal_dump(VALUE self)
|
|
493
521
|
|
494
522
|
ddraw = rb_hash_new();
|
495
523
|
|
496
|
-
// rb_hash_aset(ddraw, CSTR2SYM("primitive"), MAGICK_STRING_TO_OBJ(draw->info->primitive)); internal
|
497
|
-
// rb_hash_aset(ddraw, CSTR2SYM("geometry"), MAGICK_STRING_TO_OBJ(draw->info->geometry)); set by "text" primitive
|
498
|
-
// rb_hash_aset(ddraw, CSTR2SYM("viewbox"), Import_RectangleInfo(&draw->info->viewbox)); internal
|
499
524
|
rb_hash_aset(ddraw, CSTR2SYM("affine"), Import_AffineMatrix(&draw->info->affine));
|
500
525
|
rb_hash_aset(ddraw, CSTR2SYM("gravity"), INT2FIX(draw->info->gravity));
|
501
526
|
rb_hash_aset(ddraw, CSTR2SYM("fill"), Pixel_from_PixelColor(&draw->info->fill));
|
502
527
|
rb_hash_aset(ddraw, CSTR2SYM("stroke"), Pixel_from_PixelColor(&draw->info->stroke));
|
503
528
|
rb_hash_aset(ddraw, CSTR2SYM("stroke_width"), rb_float_new(draw->info->stroke_width));
|
504
|
-
// rb_hash_aset(ddraw, CSTR2SYM("gradient"), Qnil); // not used yet
|
505
529
|
rb_hash_aset(ddraw, CSTR2SYM("fill_pattern"), image_to_str(draw->info->fill_pattern));
|
506
|
-
rb_hash_aset(ddraw, CSTR2SYM("tile"), Qnil); // deprecated
|
507
530
|
rb_hash_aset(ddraw, CSTR2SYM("stroke_pattern"), image_to_str(draw->info->stroke_pattern));
|
508
531
|
rb_hash_aset(ddraw, CSTR2SYM("stroke_antialias"), draw->info->stroke_antialias ? Qtrue : Qfalse);
|
509
532
|
rb_hash_aset(ddraw, CSTR2SYM("text_antialias"), draw->info->text_antialias ? Qtrue : Qfalse);
|
510
|
-
// rb_hash_aset(ddraw, CSTR2SYM("fill_rule"), INT2FIX(draw->info->fill_rule)); internal
|
511
|
-
// rb_hash_aset(ddraw, CSTR2SYM("linecap"), INT2FIX(draw->info->linecap));
|
512
|
-
// rb_hash_aset(ddraw, CSTR2SYM("linejoin"), INT2FIX(draw->info->linejoin));
|
513
|
-
// rb_hash_aset(ddraw, CSTR2SYM("miterlimit"), ULONG2NUM(draw->info->miterlimit));
|
514
|
-
// rb_hash_aset(ddraw, CSTR2SYM("dash_offset"), rb_float_new(draw->info->dash_offset));
|
515
533
|
rb_hash_aset(ddraw, CSTR2SYM("decorate"), INT2FIX(draw->info->decorate));
|
516
|
-
// rb_hash_aset(ddraw, CSTR2SYM("compose"), INT2FIX(draw->info->compose)); set via "image" primitive
|
517
|
-
// rb_hash_aset(ddraw, CSTR2SYM("text"), MAGICK_STRING_TO_OBJ(draw->info->text)); set via "text" primitive
|
518
|
-
// rb_hash_aset(ddraw, CSTR2SYM("face"), Qnil); internal
|
519
534
|
rb_hash_aset(ddraw, CSTR2SYM("font"), MAGICK_STRING_TO_OBJ(draw->info->font));
|
520
|
-
// rb_hash_aset(ddraw, CSTR2SYM("metrics"), Qnil); internal
|
521
535
|
rb_hash_aset(ddraw, CSTR2SYM("family"), MAGICK_STRING_TO_OBJ(draw->info->family));
|
522
536
|
rb_hash_aset(ddraw, CSTR2SYM("style"), INT2FIX(draw->info->style));
|
523
537
|
rb_hash_aset(ddraw, CSTR2SYM("stretch"), INT2FIX(draw->info->stretch));
|
@@ -527,26 +541,17 @@ Draw_marshal_dump(VALUE self)
|
|
527
541
|
rb_hash_aset(ddraw, CSTR2SYM("density"), MAGICK_STRING_TO_OBJ(draw->info->density));
|
528
542
|
rb_hash_aset(ddraw, CSTR2SYM("align"), INT2FIX(draw->info->align));
|
529
543
|
rb_hash_aset(ddraw, CSTR2SYM("undercolor"), Pixel_from_PixelColor(&draw->info->undercolor));
|
530
|
-
// rb_hash_aset(ddraw, CSTR2SYM("border_color"), Pixel_from_PixelColor(&draw->info->border_color)); Montage and Polaroid
|
531
|
-
// rb_hash_aset(ddraw, CSTR2SYM("server_name"), MAGICK_STRING_TO_OBJ(draw->info->server_name));
|
532
|
-
// rb_hash_aset(ddraw, CSTR2SYM("dash_pattern"), dash_pattern_to_array(draw->info->dash_pattern)); internal
|
533
|
-
// rb_hash_aset(ddraw, CSTR2SYM("clip_mask"), MAGICK_STRING_TO_OBJ(draw->info->clip_mask)); internal
|
534
|
-
// rb_hash_aset(ddraw, CSTR2SYM("bounds"), Import_SegmentInfo(&draw->info->bounds)); internal
|
535
544
|
rb_hash_aset(ddraw, CSTR2SYM("clip_units"), INT2FIX(draw->info->clip_units));
|
536
545
|
#if defined(IMAGEMAGICK_7)
|
537
546
|
rb_hash_aset(ddraw, CSTR2SYM("alpha"), QUANTUM2NUM(draw->info->alpha));
|
538
547
|
#else
|
539
548
|
rb_hash_aset(ddraw, CSTR2SYM("opacity"), QUANTUM2NUM(draw->info->opacity));
|
540
549
|
#endif
|
541
|
-
// rb_hash_aset(ddraw, CSTR2SYM("render"), draw->info->render ? Qtrue : Qfalse); internal
|
542
|
-
// rb_hash_aset(ddraw, CSTR2SYM("element_reference"), Qnil); // not used yet
|
543
|
-
// rb_hash_aset(ddraw, CSTR2SYM("debug"), draw->info->debug ? Qtrue : Qfalse);
|
544
550
|
rb_hash_aset(ddraw, CSTR2SYM("kerning"), rb_float_new(draw->info->kerning));
|
545
551
|
rb_hash_aset(ddraw, CSTR2SYM("interword_spacing"), rb_float_new(draw->info->interword_spacing));
|
546
552
|
|
547
553
|
// Non-DrawInfo fields
|
548
554
|
rb_hash_aset(ddraw, CSTR2SYM("primitives"), draw->primitives);
|
549
|
-
// rb_hash_aset(ddraw, CSTR2SYM("shadow_color"), Pixel_from_PixelColor(&draw->shadow_color)); Polaroid-only
|
550
555
|
|
551
556
|
return ddraw;
|
552
557
|
}
|
@@ -564,21 +569,18 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
564
569
|
Draw *draw;
|
565
570
|
VALUE val;
|
566
571
|
|
567
|
-
|
568
|
-
|
572
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
573
|
+
|
569
574
|
if (draw->info == NULL)
|
570
575
|
{
|
571
576
|
ImageInfo *image_info;
|
572
577
|
|
573
578
|
image_info = CloneImageInfo(NULL);
|
574
579
|
draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
|
575
|
-
DestroyImageInfo(image_info);
|
580
|
+
DestroyImageInfo(image_info);
|
576
581
|
}
|
577
582
|
OBJ_TO_MAGICK_STRING(draw->info->geometry, rb_hash_aref(ddraw, CSTR2SYM("geometry")));
|
578
583
|
|
579
|
-
//val = rb_hash_aref(ddraw, CSTR2SYM("viewbox"));
|
580
|
-
//Export_RectangleInfo(&draw->info->viewbox, val);
|
581
|
-
|
582
584
|
val = rb_hash_aref(ddraw, CSTR2SYM("affine"));
|
583
585
|
Export_AffineMatrix(&draw->info->affine, val);
|
584
586
|
|
@@ -593,8 +595,8 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
593
595
|
draw->info->stroke_width = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("stroke_width")));
|
594
596
|
draw->info->fill_pattern = str_to_image(rb_hash_aref(ddraw, CSTR2SYM("fill_pattern")));
|
595
597
|
draw->info->stroke_pattern = str_to_image(rb_hash_aref(ddraw, CSTR2SYM("stroke_pattern")));
|
596
|
-
draw->info->stroke_antialias = RTEST(rb_hash_aref(ddraw, CSTR2SYM("stroke_antialias")));
|
597
|
-
draw->info->text_antialias = RTEST(rb_hash_aref(ddraw, CSTR2SYM("text_antialias")));
|
598
|
+
draw->info->stroke_antialias = (MagickBooleanType)RTEST(rb_hash_aref(ddraw, CSTR2SYM("stroke_antialias")));
|
599
|
+
draw->info->text_antialias = (MagickBooleanType)RTEST(rb_hash_aref(ddraw, CSTR2SYM("text_antialias")));
|
598
600
|
draw->info->decorate = (DecorationType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("decorate")));
|
599
601
|
OBJ_TO_MAGICK_STRING(draw->info->font, rb_hash_aref(ddraw, CSTR2SYM("font")));
|
600
602
|
OBJ_TO_MAGICK_STRING(draw->info->family, rb_hash_aref(ddraw, CSTR2SYM("family")));
|
@@ -610,7 +612,7 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
610
612
|
val = rb_hash_aref(ddraw, CSTR2SYM("undercolor"));
|
611
613
|
Color_to_PixelColor(&draw->info->undercolor, val);
|
612
614
|
|
613
|
-
draw->info->clip_units = FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units")));
|
615
|
+
draw->info->clip_units = (ClipPathUnits)FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units")));
|
614
616
|
#if defined(IMAGEMAGICK_7)
|
615
617
|
draw->info->alpha = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("alpha")));
|
616
618
|
#else
|
@@ -639,7 +641,7 @@ Draw_pointsize_eq(VALUE self, VALUE pointsize)
|
|
639
641
|
Draw *draw;
|
640
642
|
|
641
643
|
rb_check_frozen(self);
|
642
|
-
|
644
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
643
645
|
draw->info->pointsize = NUM2DBL(pointsize);
|
644
646
|
return pointsize;
|
645
647
|
}
|
@@ -659,7 +661,7 @@ Draw_rotation_eq(VALUE self, VALUE deg)
|
|
659
661
|
AffineMatrix affine, current;
|
660
662
|
|
661
663
|
rb_check_frozen(self);
|
662
|
-
|
664
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
663
665
|
|
664
666
|
degrees = NUM2DBL(deg);
|
665
667
|
if (fabs(degrees) > DBL_EPSILON)
|
@@ -695,7 +697,7 @@ Draw_stroke_eq(VALUE self, VALUE stroke)
|
|
695
697
|
Draw *draw;
|
696
698
|
|
697
699
|
rb_check_frozen(self);
|
698
|
-
|
700
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
699
701
|
Color_to_PixelColor(&draw->info->stroke, stroke);
|
700
702
|
return stroke;
|
701
703
|
}
|
@@ -715,7 +717,7 @@ Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
|
|
715
717
|
Draw *draw;
|
716
718
|
|
717
719
|
rb_check_frozen(self);
|
718
|
-
|
720
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
719
721
|
|
720
722
|
if (draw->info->stroke_pattern != NULL)
|
721
723
|
{
|
@@ -751,7 +753,7 @@ Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
|
|
751
753
|
Draw *draw;
|
752
754
|
|
753
755
|
rb_check_frozen(self);
|
754
|
-
|
756
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
755
757
|
draw->info->stroke_width = NUM2DBL(stroke_width);
|
756
758
|
return stroke_width;
|
757
759
|
}
|
@@ -769,7 +771,7 @@ Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
|
|
769
771
|
Draw *draw;
|
770
772
|
|
771
773
|
rb_check_frozen(self);
|
772
|
-
|
774
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
773
775
|
draw->info->text_antialias = (MagickBooleanType) RTEST(text_antialias);
|
774
776
|
return text_antialias;
|
775
777
|
}
|
@@ -800,7 +802,7 @@ Draw_undercolor_eq(VALUE self, VALUE undercolor)
|
|
800
802
|
Draw *draw;
|
801
803
|
|
802
804
|
rb_check_frozen(self);
|
803
|
-
|
805
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
804
806
|
Color_to_PixelColor(&draw->info->undercolor, undercolor);
|
805
807
|
return undercolor;
|
806
808
|
}
|
@@ -843,7 +845,7 @@ VALUE Draw_annotate(
|
|
843
845
|
|
844
846
|
// Save the affine matrix in case it is modified by
|
845
847
|
// Draw#rotation=
|
846
|
-
|
848
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
847
849
|
keep = draw->info->affine;
|
848
850
|
|
849
851
|
image_arg = rm_cur_image(image_arg);
|
@@ -853,16 +855,7 @@ VALUE Draw_annotate(
|
|
853
855
|
// allowing the app a chance to modify the object's attributes
|
854
856
|
if (rb_block_given_p())
|
855
857
|
{
|
856
|
-
|
857
|
-
{
|
858
|
-
// Run the block in self's context
|
859
|
-
rb_warn("passing a block without an image argument is deprecated");
|
860
|
-
rb_obj_instance_eval(0, NULL, self);
|
861
|
-
}
|
862
|
-
else
|
863
|
-
{
|
864
|
-
rb_yield(self);
|
865
|
-
}
|
858
|
+
rb_yield(self);
|
866
859
|
}
|
867
860
|
|
868
861
|
// Translate & store in Draw structure
|
@@ -910,10 +903,11 @@ VALUE Draw_annotate(
|
|
910
903
|
magick_clone_string(&draw->info->geometry, geometry_str);
|
911
904
|
|
912
905
|
#if defined(IMAGEMAGICK_7)
|
913
|
-
AnnotateImage
|
906
|
+
GVL_STRUCT_TYPE(AnnotateImage) args = { image, draw->info, exception };
|
914
907
|
#else
|
915
|
-
AnnotateImage
|
908
|
+
GVL_STRUCT_TYPE(AnnotateImage) args = { image, draw->info };
|
916
909
|
#endif
|
910
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AnnotateImage), &args);
|
917
911
|
|
918
912
|
magick_free(draw->info->text);
|
919
913
|
draw->info->text = NULL;
|
@@ -956,24 +950,24 @@ Draw_clone(VALUE self)
|
|
956
950
|
* Draw the image.
|
957
951
|
*
|
958
952
|
* @overload composite(x, y, width, height, image)
|
959
|
-
* @param x [
|
960
|
-
* @param y [
|
961
|
-
* @param width [
|
962
|
-
* @param height [
|
953
|
+
* @param x [Numeric] x position
|
954
|
+
* @param y [Numeric] y position
|
955
|
+
* @param width [Numeric] the width
|
956
|
+
* @param height [Numeric] the height
|
963
957
|
* @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
|
964
958
|
* imagelist, uses the current image.
|
965
959
|
*
|
966
|
-
* @overload composite(x, y, width, height, image,
|
960
|
+
* @overload composite(x, y, width, height, image, composite_op = Magick::OverCompositeOp)
|
967
961
|
* - The "image" argument can be either an ImageList object or an Image
|
968
962
|
* argument.
|
969
|
-
* @param x [
|
970
|
-
* @param y [
|
971
|
-
* @param width [
|
972
|
-
* @param height [
|
963
|
+
* @param x [Numeric] x position
|
964
|
+
* @param y [Numeric] y position
|
965
|
+
* @param width [Numeric] the width
|
966
|
+
* @param height [Numeric] the height
|
973
967
|
* @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
|
974
968
|
* imagelist, uses the current image.
|
975
|
-
* @param
|
976
|
-
*
|
969
|
+
* @param composite_op [Magick::CompositeOperator] the operator
|
970
|
+
*
|
977
971
|
* @return [Magick::Draw] self
|
978
972
|
*/
|
979
973
|
VALUE
|
@@ -982,7 +976,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
982
976
|
Draw *draw;
|
983
977
|
const char *op;
|
984
978
|
double x, y, width, height;
|
985
|
-
CompositeOperator
|
979
|
+
CompositeOperator composite_op;
|
986
980
|
VALUE image;
|
987
981
|
Image *comp_img;
|
988
982
|
struct TmpFile_Name *tmpfile_name;
|
@@ -1004,19 +998,19 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1004
998
|
width = NUM2DBL(argv[2]);
|
1005
999
|
height = NUM2DBL(argv[3]);
|
1006
1000
|
|
1007
|
-
|
1001
|
+
composite_op = OverCompositeOp;
|
1008
1002
|
if (argc == 6)
|
1009
1003
|
{
|
1010
|
-
VALUE_TO_ENUM(argv[5],
|
1004
|
+
VALUE_TO_ENUM(argv[5], composite_op, CompositeOperator);
|
1011
1005
|
}
|
1012
1006
|
|
1013
|
-
op = CommandOptionToMnemonic(MagickComposeOptions,
|
1007
|
+
op = CommandOptionToMnemonic(MagickComposeOptions, composite_op);
|
1014
1008
|
if (rm_strcasecmp("Unrecognized", op) == 0)
|
1015
1009
|
{
|
1016
|
-
rb_raise(rb_eArgError, "unknown composite operator (%d)",
|
1010
|
+
rb_raise(rb_eArgError, "unknown composite operator (%d)", composite_op);
|
1017
1011
|
}
|
1018
1012
|
|
1019
|
-
|
1013
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1020
1014
|
|
1021
1015
|
// Create a temp copy of the composite image
|
1022
1016
|
rm_write_temp_image(comp_img, name, sizeof(name));
|
@@ -1024,7 +1018,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1024
1018
|
// Add the temp filename to the filename array.
|
1025
1019
|
// Use Magick storage since we need to keep the list around
|
1026
1020
|
// until destroy_Draw is called.
|
1027
|
-
tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name) + rm_strnlen_s(name, sizeof(name)));
|
1021
|
+
tmpfile_name = (struct TmpFile_Name *)magick_malloc(sizeof(struct TmpFile_Name) + rm_strnlen_s(name, sizeof(name)));
|
1028
1022
|
strcpy(tmpfile_name->name, name);
|
1029
1023
|
tmpfile_name->next = draw->tmpfile_ary;
|
1030
1024
|
draw->tmpfile_ary = tmpfile_name;
|
@@ -1061,7 +1055,7 @@ Draw_draw(VALUE self, VALUE image_arg)
|
|
1061
1055
|
image_arg = rm_cur_image(image_arg);
|
1062
1056
|
image = rm_check_frozen(image_arg);
|
1063
1057
|
|
1064
|
-
|
1058
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1065
1059
|
if (draw->primitives == 0)
|
1066
1060
|
{
|
1067
1061
|
rb_raise(rb_eArgError, "nothing to draw");
|
@@ -1072,10 +1066,11 @@ Draw_draw(VALUE self, VALUE image_arg)
|
|
1072
1066
|
|
1073
1067
|
#if defined(IMAGEMAGICK_7)
|
1074
1068
|
exception = AcquireExceptionInfo();
|
1075
|
-
DrawImage
|
1069
|
+
GVL_STRUCT_TYPE(DrawImage) args = { image, draw->info, exception };
|
1076
1070
|
#else
|
1077
|
-
DrawImage
|
1071
|
+
GVL_STRUCT_TYPE(DrawImage) args = { image, draw->info };
|
1078
1072
|
#endif
|
1073
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DrawImage), &args);
|
1079
1074
|
|
1080
1075
|
magick_free(draw->info->primitive);
|
1081
1076
|
draw->info->primitive = NULL;
|
@@ -1106,7 +1101,7 @@ Draw_dup(VALUE self)
|
|
1106
1101
|
|
1107
1102
|
draw = ALLOC(Draw);
|
1108
1103
|
memset(draw, 0, sizeof(Draw));
|
1109
|
-
dup =
|
1104
|
+
dup = TypedData_Wrap_Struct(CLASS_OF(self), &rm_draw_data_type, draw);
|
1110
1105
|
RB_GC_GUARD(dup);
|
1111
1106
|
|
1112
1107
|
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
@@ -1136,7 +1131,7 @@ Draw_get_type_metrics(
|
|
1136
1131
|
VALUE *argv,
|
1137
1132
|
VALUE self)
|
1138
1133
|
{
|
1139
|
-
return get_type_metrics(argc, argv, self, GetTypeMetrics);
|
1134
|
+
return get_type_metrics(argc, argv, self, GVL_FUNC(GetTypeMetrics));
|
1140
1135
|
}
|
1141
1136
|
|
1142
1137
|
|
@@ -1163,7 +1158,7 @@ Draw_get_multiline_type_metrics(
|
|
1163
1158
|
VALUE *argv,
|
1164
1159
|
VALUE self)
|
1165
1160
|
{
|
1166
|
-
return get_type_metrics(argc, argv, self, GetMultilineTypeMetrics);
|
1161
|
+
return get_type_metrics(argc, argv, self, GVL_FUNC(GetMultilineTypeMetrics));
|
1167
1162
|
}
|
1168
1163
|
|
1169
1164
|
|
@@ -1177,8 +1172,8 @@ VALUE Draw_init_copy(VALUE self, VALUE orig)
|
|
1177
1172
|
{
|
1178
1173
|
Draw *copy, *original;
|
1179
1174
|
|
1180
|
-
|
1181
|
-
|
1175
|
+
TypedData_Get_Struct(orig, Draw, &rm_draw_data_type, original);
|
1176
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, copy);
|
1182
1177
|
|
1183
1178
|
copy->info = CloneDrawInfo(NULL, original->info);
|
1184
1179
|
if (!copy->info)
|
@@ -1206,10 +1201,10 @@ Draw_initialize(VALUE self)
|
|
1206
1201
|
Draw *draw, *draw_options;
|
1207
1202
|
VALUE options;
|
1208
1203
|
|
1209
|
-
|
1204
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1210
1205
|
|
1211
1206
|
options = new_DrawOptions();
|
1212
|
-
|
1207
|
+
TypedData_Get_Struct(options, Draw, &rm_draw_data_type, draw_options);
|
1213
1208
|
draw->info = draw_options->info;
|
1214
1209
|
draw_options->info = NULL;
|
1215
1210
|
|
@@ -1230,7 +1225,7 @@ Draw_inspect(VALUE self)
|
|
1230
1225
|
{
|
1231
1226
|
Draw *draw;
|
1232
1227
|
|
1233
|
-
|
1228
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1234
1229
|
return draw->primitives ? draw->primitives : rb_str_new2("(no primitives defined)");
|
1235
1230
|
}
|
1236
1231
|
|
@@ -1240,14 +1235,14 @@ Draw_inspect(VALUE self)
|
|
1240
1235
|
*
|
1241
1236
|
* @return [Magick::Draw] a new Draw object
|
1242
1237
|
*/
|
1243
|
-
VALUE Draw_alloc(VALUE
|
1238
|
+
VALUE Draw_alloc(VALUE klass)
|
1244
1239
|
{
|
1245
1240
|
Draw *draw;
|
1246
1241
|
VALUE draw_obj;
|
1247
1242
|
|
1248
1243
|
draw = ALLOC(Draw);
|
1249
1244
|
memset(draw, 0, sizeof(Draw));
|
1250
|
-
draw_obj =
|
1245
|
+
draw_obj = TypedData_Wrap_Struct(klass, &rm_draw_data_type, draw);
|
1251
1246
|
|
1252
1247
|
RB_GC_GUARD(draw_obj);
|
1253
1248
|
|
@@ -1267,7 +1262,7 @@ Draw_primitive(VALUE self, VALUE primitive)
|
|
1267
1262
|
Draw *draw;
|
1268
1263
|
|
1269
1264
|
rb_check_frozen(self);
|
1270
|
-
|
1265
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1271
1266
|
|
1272
1267
|
if (draw->primitives == (VALUE)0)
|
1273
1268
|
{
|
@@ -1275,13 +1270,32 @@ Draw_primitive(VALUE self, VALUE primitive)
|
|
1275
1270
|
}
|
1276
1271
|
else
|
1277
1272
|
{
|
1278
|
-
draw->primitives =
|
1273
|
+
draw->primitives = rb_str_plus(draw->primitives, rb_str_new2("\n"));
|
1279
1274
|
draw->primitives = rb_str_concat(draw->primitives, primitive);
|
1280
1275
|
}
|
1281
1276
|
|
1282
1277
|
return self;
|
1283
1278
|
}
|
1284
1279
|
|
1280
|
+
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
1281
|
+
/**
|
1282
|
+
* Compact the objects.
|
1283
|
+
*
|
1284
|
+
* No Ruby usage (internal function)
|
1285
|
+
*
|
1286
|
+
* @param drawptr pointer to a Draw object
|
1287
|
+
*/
|
1288
|
+
static void
|
1289
|
+
Draw_compact(void *drawptr)
|
1290
|
+
{
|
1291
|
+
Draw *draw = (Draw *)drawptr;
|
1292
|
+
|
1293
|
+
if (draw->primitives != (VALUE)0)
|
1294
|
+
{
|
1295
|
+
draw->primitives = rb_gc_location(draw->primitives);
|
1296
|
+
}
|
1297
|
+
}
|
1298
|
+
#endif
|
1285
1299
|
|
1286
1300
|
/**
|
1287
1301
|
* Mark referenced objects.
|
@@ -1291,13 +1305,17 @@ Draw_primitive(VALUE self, VALUE primitive)
|
|
1291
1305
|
* @param drawptr pointer to a Draw object
|
1292
1306
|
*/
|
1293
1307
|
static void
|
1294
|
-
|
1308
|
+
Draw_mark(void *drawptr)
|
1295
1309
|
{
|
1296
1310
|
Draw *draw = (Draw *)drawptr;
|
1297
1311
|
|
1298
1312
|
if (draw->primitives != (VALUE)0)
|
1299
1313
|
{
|
1314
|
+
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
1315
|
+
rb_gc_mark_movable(draw->primitives);
|
1316
|
+
#else
|
1300
1317
|
rb_gc_mark(draw->primitives);
|
1318
|
+
#endif
|
1301
1319
|
}
|
1302
1320
|
}
|
1303
1321
|
|
@@ -1310,7 +1328,7 @@ mark_Draw(void *drawptr)
|
|
1310
1328
|
* @param drawptr pointer to a Draw object
|
1311
1329
|
*/
|
1312
1330
|
static void
|
1313
|
-
|
1331
|
+
Draw_destroy(void *drawptr)
|
1314
1332
|
{
|
1315
1333
|
Draw *draw = (Draw *)drawptr;
|
1316
1334
|
|
@@ -1334,6 +1352,18 @@ destroy_Draw(void *drawptr)
|
|
1334
1352
|
xfree(drawptr);
|
1335
1353
|
}
|
1336
1354
|
|
1355
|
+
/**
|
1356
|
+
* Get Draw object size.
|
1357
|
+
*
|
1358
|
+
* No Ruby usage (internal function)
|
1359
|
+
*
|
1360
|
+
* @param infoptr pointer to the Draw object
|
1361
|
+
*/
|
1362
|
+
static size_t
|
1363
|
+
Draw_memsize(const void *drawptr)
|
1364
|
+
{
|
1365
|
+
return sizeof(Draw);
|
1366
|
+
}
|
1337
1367
|
|
1338
1368
|
/**
|
1339
1369
|
* Allocate & initialize a DrawOptions object.
|
@@ -1358,14 +1388,14 @@ new_DrawOptions(void)
|
|
1358
1388
|
* @return [Magick::Image::DrawOptions] a new DrawOptions object
|
1359
1389
|
*/
|
1360
1390
|
VALUE
|
1361
|
-
DrawOptions_alloc(VALUE
|
1391
|
+
DrawOptions_alloc(VALUE klass)
|
1362
1392
|
{
|
1363
1393
|
Draw *draw_options;
|
1364
1394
|
VALUE draw_options_obj;
|
1365
1395
|
|
1366
1396
|
draw_options = ALLOC(Draw);
|
1367
1397
|
memset(draw_options, 0, sizeof(Draw));
|
1368
|
-
draw_options_obj =
|
1398
|
+
draw_options_obj = TypedData_Wrap_Struct(klass, &rm_draw_data_type, draw_options);
|
1369
1399
|
|
1370
1400
|
RB_GC_GUARD(draw_options_obj);
|
1371
1401
|
|
@@ -1383,27 +1413,16 @@ DrawOptions_initialize(VALUE self)
|
|
1383
1413
|
{
|
1384
1414
|
Draw *draw_options;
|
1385
1415
|
|
1386
|
-
|
1416
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw_options);
|
1387
1417
|
draw_options->info = AcquireDrawInfo();
|
1388
1418
|
if (!draw_options->info)
|
1389
1419
|
{
|
1390
1420
|
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
1391
1421
|
}
|
1392
1422
|
|
1393
|
-
GetDrawInfo(NULL, draw_options->info);
|
1394
|
-
|
1395
1423
|
if (rb_block_given_p())
|
1396
1424
|
{
|
1397
|
-
|
1398
|
-
{
|
1399
|
-
// Run the block in self's context
|
1400
|
-
rb_warn("passing a block without an image argument is deprecated");
|
1401
|
-
rb_obj_instance_eval(0, NULL, self);
|
1402
|
-
}
|
1403
|
-
else
|
1404
|
-
{
|
1405
|
-
rb_yield(self);
|
1406
|
-
}
|
1425
|
+
rb_yield(self);
|
1407
1426
|
}
|
1408
1427
|
|
1409
1428
|
return self;
|
@@ -1414,12 +1433,12 @@ DrawOptions_initialize(VALUE self)
|
|
1414
1433
|
* Allocate a new Magick::Image::PolaroidOptions object.
|
1415
1434
|
*
|
1416
1435
|
* - Internally a PolaroidOptions object is the same as a Draw object. The
|
1417
|
-
* methods are implemented by Draw methods in rmdraw.
|
1436
|
+
* methods are implemented by Draw methods in rmdraw.cpp.
|
1418
1437
|
*
|
1419
1438
|
* @return [Magick::Image::PolaroidOptions] a new PolaroidOptions object
|
1420
1439
|
*/
|
1421
1440
|
VALUE
|
1422
|
-
PolaroidOptions_alloc(VALUE
|
1441
|
+
PolaroidOptions_alloc(VALUE klass)
|
1423
1442
|
{
|
1424
1443
|
VALUE polaroid_obj;
|
1425
1444
|
ImageInfo *image_info;
|
@@ -1433,7 +1452,7 @@ PolaroidOptions_alloc(VALUE class)
|
|
1433
1452
|
draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
|
1434
1453
|
(void) DestroyImageInfo(image_info);
|
1435
1454
|
|
1436
|
-
polaroid_obj =
|
1455
|
+
polaroid_obj = TypedData_Wrap_Struct(klass, &rm_draw_data_type, draw);
|
1437
1456
|
|
1438
1457
|
RB_GC_GUARD(polaroid_obj);
|
1439
1458
|
|
@@ -1444,8 +1463,8 @@ PolaroidOptions_alloc(VALUE class)
|
|
1444
1463
|
/**
|
1445
1464
|
* Initialize a PolaroidOptions object.
|
1446
1465
|
*
|
1447
|
-
* @yield [
|
1448
|
-
* @yieldparam
|
1466
|
+
* @yield [opt]
|
1467
|
+
* @yieldparam opt [Magick::Image::PolaroidOptions] self
|
1449
1468
|
* @return [Magick::Image::PolaroidOptions] self
|
1450
1469
|
*/
|
1451
1470
|
VALUE
|
@@ -1455,7 +1474,7 @@ PolaroidOptions_initialize(VALUE self)
|
|
1455
1474
|
ExceptionInfo *exception;
|
1456
1475
|
|
1457
1476
|
// Default shadow color
|
1458
|
-
|
1477
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1459
1478
|
|
1460
1479
|
exception = AcquireExceptionInfo();
|
1461
1480
|
QueryColorCompliance("gray75", AllCompliance, &draw->shadow_color, exception);
|
@@ -1466,16 +1485,7 @@ PolaroidOptions_initialize(VALUE self)
|
|
1466
1485
|
|
1467
1486
|
if (rb_block_given_p())
|
1468
1487
|
{
|
1469
|
-
|
1470
|
-
{
|
1471
|
-
// Run the block in self's context
|
1472
|
-
rb_warn("passing a block without an image argument is deprecated");
|
1473
|
-
rb_obj_instance_eval(0, NULL, self);
|
1474
|
-
}
|
1475
|
-
else
|
1476
|
-
{
|
1477
|
-
rb_yield(self);
|
1478
|
-
}
|
1488
|
+
rb_yield(self);
|
1479
1489
|
}
|
1480
1490
|
|
1481
1491
|
return self;
|
@@ -1508,7 +1518,7 @@ PolaroidOptions_shadow_color_eq(VALUE self, VALUE shadow)
|
|
1508
1518
|
Draw *draw;
|
1509
1519
|
|
1510
1520
|
rb_check_frozen(self);
|
1511
|
-
|
1521
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1512
1522
|
Color_to_PixelColor(&draw->shadow_color, shadow);
|
1513
1523
|
return shadow;
|
1514
1524
|
}
|
@@ -1526,7 +1536,7 @@ PolaroidOptions_border_color_eq(VALUE self, VALUE border)
|
|
1526
1536
|
Draw *draw;
|
1527
1537
|
|
1528
1538
|
rb_check_frozen(self);
|
1529
|
-
|
1539
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1530
1540
|
Color_to_PixelColor(&draw->info->border_color, border);
|
1531
1541
|
return border;
|
1532
1542
|
}
|
@@ -1575,6 +1585,9 @@ get_dummy_tm_img(VALUE klass)
|
|
1575
1585
|
}
|
1576
1586
|
|
1577
1587
|
|
1588
|
+
// aliases for common use of structure types; GetMultilineTypeMetrics, GetTypeMetrics
|
1589
|
+
typedef GVL_STRUCT_TYPE(GetTypeMetrics) GVL_STRUCT_TYPE(get_type_metrics);
|
1590
|
+
|
1578
1591
|
/**
|
1579
1592
|
* Call a get-type-metrics function.
|
1580
1593
|
*
|
@@ -1592,19 +1605,15 @@ get_dummy_tm_img(VALUE klass)
|
|
1592
1605
|
* @see Draw_get_multiline_type_metrics
|
1593
1606
|
*/
|
1594
1607
|
static VALUE
|
1595
|
-
get_type_metrics(
|
1596
|
-
int argc,
|
1597
|
-
VALUE *argv,
|
1598
|
-
VALUE self,
|
1599
|
-
get_type_metrics_func_t getter)
|
1608
|
+
get_type_metrics(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
|
1600
1609
|
{
|
1601
1610
|
Image *image;
|
1602
1611
|
Draw *draw;
|
1603
1612
|
VALUE t;
|
1604
1613
|
TypeMetric metrics;
|
1605
1614
|
char *text = NULL;
|
1606
|
-
|
1607
|
-
|
1615
|
+
size_t text_l;
|
1616
|
+
MagickBooleanType okay;
|
1608
1617
|
#if defined(IMAGEMAGICK_7)
|
1609
1618
|
ExceptionInfo *exception;
|
1610
1619
|
#endif
|
@@ -1613,7 +1622,7 @@ get_type_metrics(
|
|
1613
1622
|
{
|
1614
1623
|
case 1: // use default image
|
1615
1624
|
text = rm_str2cstr(argv[0], &text_l);
|
1616
|
-
|
1625
|
+
TypedData_Get_Struct(get_dummy_tm_img(CLASS_OF(self)), Image, &rm_image_data_type, image);
|
1617
1626
|
break;
|
1618
1627
|
case 2:
|
1619
1628
|
t = rm_cur_image(argv[0]);
|
@@ -1630,7 +1639,7 @@ get_type_metrics(
|
|
1630
1639
|
rb_raise(rb_eArgError, "no text to measure");
|
1631
1640
|
}
|
1632
1641
|
|
1633
|
-
|
1642
|
+
TypedData_Get_Struct(self, Draw, &rm_draw_data_type, draw);
|
1634
1643
|
#if defined(IMAGEMAGICK_7)
|
1635
1644
|
exception = AcquireExceptionInfo();
|
1636
1645
|
draw->info->text = InterpretImageProperties(NULL, image, text, exception);
|
@@ -1654,10 +1663,12 @@ get_type_metrics(
|
|
1654
1663
|
}
|
1655
1664
|
|
1656
1665
|
#if defined(IMAGEMAGICK_7)
|
1657
|
-
|
1666
|
+
GVL_STRUCT_TYPE(get_type_metrics) args = { image, draw->info, &metrics, exception };
|
1658
1667
|
#else
|
1659
|
-
|
1668
|
+
GVL_STRUCT_TYPE(get_type_metrics) args = { image, draw->info, &metrics };
|
1660
1669
|
#endif
|
1670
|
+
void *ret = CALL_FUNC_WITHOUT_GVL(fp, &args);
|
1671
|
+
okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
|
1661
1672
|
|
1662
1673
|
magick_free(draw->info->text);
|
1663
1674
|
draw->info->text = NULL;
|