rmagick 1.15.17 → 2.0.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 +78 -25
- data/README.html +117 -188
- data/README.txt +116 -181
- data/build_tarball.rake +205 -0
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +118 -44
- data/doc/draw.html +57 -99
- data/doc/ex/adaptive_threshold.rb +1 -10
- data/doc/ex/add_noise.rb +4 -5
- data/doc/ex/axes.rb +1 -1
- data/doc/ex/bilevel_channel.rb +2 -13
- data/doc/ex/bounding_box.rb +3 -4
- data/doc/ex/channel.rb +6 -7
- data/doc/ex/clip_path.rb +11 -5
- data/doc/ex/color_histogram.rb +8 -20
- data/doc/ex/composite_layers.rb +53 -0
- data/doc/ex/fill_pattern.rb +26 -0
- data/doc/ex/get_multiline_type_metrics.rb +26 -37
- data/doc/ex/get_type_metrics.rb +25 -25
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/level.rb +1 -1
- data/doc/ex/matte_floodfill.rb +5 -6
- data/doc/ex/matte_replace.rb +5 -6
- data/doc/ex/negate_channel.rb +0 -10
- data/doc/ex/opacity.rb +3 -5
- data/doc/ex/polaroid.rb +4 -1
- data/doc/ex/posterize.rb +1 -12
- data/doc/ex/preview.rb +1 -8
- data/doc/ex/radial_blur.rb +1 -11
- data/doc/ex/raise.rb +1 -4
- data/doc/ex/random_threshold_channel.rb +4 -9
- data/doc/ex/sepiatone.rb +2 -9
- data/doc/ex/shadow.rb +12 -18
- data/doc/ex/sketch.rb +2 -9
- data/doc/ex/smile.rb +7 -7
- data/doc/ex/splice.rb +3 -10
- data/doc/ex/stegano.rb +5 -0
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/transpose.rb +1 -8
- data/doc/ex/transverse.rb +1 -8
- data/doc/ex/trim.rb +1 -2
- data/doc/ex/viewex.rb +4 -5
- data/doc/ex/vignette.rb +1 -8
- data/doc/ex/watermark.rb +1 -0
- data/doc/ex/wet_floor.rb +8 -14
- data/doc/ilist.html +301 -110
- data/doc/image1.html +362 -258
- data/doc/image2.html +429 -286
- data/doc/image3.html +418 -192
- data/doc/imageattrs.html +100 -39
- data/doc/imusage.html +26 -21
- data/doc/index.html +52 -93
- data/doc/info.html +160 -64
- data/doc/magick.html +37 -71
- data/doc/optequiv.html +155 -61
- data/doc/rvg.html +3 -3
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +3 -3
- data/doc/rvgpattern.html +3 -3
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +4 -4
- data/doc/rvgtut.html +4 -4
- data/doc/rvguse.html +3 -3
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +26 -29
- data/doc/usage.html +99 -48
- data/examples/crop_with_gravity.rb +46 -0
- data/examples/demo.rb +2 -2
- data/examples/histogram.rb +11 -11
- data/examples/identify.rb +45 -45
- data/examples/spinner.rb +3 -2
- data/ext/RMagick/MANIFEST +7 -8
- data/ext/RMagick/extconf.rb +242 -0
- data/ext/RMagick/rmagick.h +136 -222
- data/ext/RMagick/rmdraw.c +226 -229
- data/ext/RMagick/rmfill.c +69 -118
- data/ext/RMagick/rmilist.c +234 -94
- data/ext/RMagick/rmimage.c +1719 -2564
- data/ext/RMagick/rminfo.c +433 -619
- data/ext/RMagick/rmmain.c +249 -487
- data/ext/RMagick/rmutil.c +344 -563
- data/lib/RMagick.rb +414 -358
- data/lib/rvg/clippath.rb +2 -2
- data/lib/rvg/container.rb +2 -2
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +2 -2
- data/lib/rvg/misc.rb +3 -3
- data/lib/rvg/paint.rb +2 -7
- data/lib/rvg/pathdata.rb +2 -2
- data/lib/rvg/rvg.rb +2 -2
- data/lib/rvg/stretchable.rb +2 -14
- data/lib/rvg/stylable.rb +2 -2
- data/lib/rvg/text.rb +2 -2
- data/lib/rvg/transformable.rb +2 -2
- data/lib/rvg/units.rb +2 -2
- data/{metaconfig.in → metaconfig} +0 -1
- data/post-setup.rb +1 -1
- data/rmagick.gemspec +6 -9
- metadata +41 -49
- data/Makefile.in +0 -42
- data/configure +0 -12358
- data/configure.ac +0 -791
- data/ext/RMagick/extconf.rb.in +0 -25
- data/ext/RMagick/rmagick_config.h.in +0 -285
- data/gem_extconf.rb +0 -42
data/ext/RMagick/rmdraw.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
/* $Id: rmdraw.c,v 1.
|
1
|
+
/* $Id: rmdraw.c,v 1.59 2007/11/25 21:32:41 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
|
-
| Copyright (C)
|
3
|
+
| Copyright (C) 2007 by Timothy P. Hunter
|
4
4
|
| Name: rmdraw.c
|
5
5
|
| Author: Tim Hunter
|
6
6
|
| Purpose: Contains Draw class methods.
|
@@ -28,7 +28,7 @@ Draw_affine_eq(VALUE self, VALUE matrix)
|
|
28
28
|
{
|
29
29
|
Draw *draw;
|
30
30
|
|
31
|
-
|
31
|
+
rb_check_frozen(self);
|
32
32
|
Data_Get_Struct(self, Draw, draw);
|
33
33
|
AffineMatrix_to_AffineMatrix(&draw->info->affine, matrix);
|
34
34
|
return self;
|
@@ -43,7 +43,7 @@ Draw_align_eq(VALUE self, VALUE align)
|
|
43
43
|
{
|
44
44
|
Draw *draw;
|
45
45
|
|
46
|
-
|
46
|
+
rb_check_frozen(self);
|
47
47
|
Data_Get_Struct(self, Draw, draw);
|
48
48
|
VALUE_TO_ENUM(align, draw->info->align, AlignType);
|
49
49
|
return self;
|
@@ -58,7 +58,7 @@ Draw_decorate_eq(VALUE self, VALUE decorate)
|
|
58
58
|
{
|
59
59
|
Draw *draw;
|
60
60
|
|
61
|
-
|
61
|
+
rb_check_frozen(self);
|
62
62
|
Data_Get_Struct(self, Draw, draw);
|
63
63
|
VALUE_TO_ENUM(decorate, draw->info->decorate, DecorationType);
|
64
64
|
return self;
|
@@ -73,9 +73,9 @@ Draw_density_eq(VALUE self, VALUE density)
|
|
73
73
|
{
|
74
74
|
Draw *draw;
|
75
75
|
|
76
|
-
|
76
|
+
rb_check_frozen(self);
|
77
77
|
Data_Get_Struct(self, Draw, draw);
|
78
|
-
magick_clone_string(&draw->info->density,
|
78
|
+
magick_clone_string(&draw->info->density, StringValuePtr(density));
|
79
79
|
|
80
80
|
return self;
|
81
81
|
}
|
@@ -89,9 +89,9 @@ Draw_encoding_eq(VALUE self, VALUE encoding)
|
|
89
89
|
{
|
90
90
|
Draw *draw;
|
91
91
|
|
92
|
-
|
92
|
+
rb_check_frozen(self);
|
93
93
|
Data_Get_Struct(self, Draw, draw);
|
94
|
-
magick_clone_string(&draw->info->encoding,
|
94
|
+
magick_clone_string(&draw->info->encoding, StringValuePtr(encoding));
|
95
95
|
|
96
96
|
return self;
|
97
97
|
}
|
@@ -105,12 +105,44 @@ Draw_fill_eq(VALUE self, VALUE fill)
|
|
105
105
|
{
|
106
106
|
Draw *draw;
|
107
107
|
|
108
|
-
|
108
|
+
rb_check_frozen(self);
|
109
109
|
Data_Get_Struct(self, Draw, draw);
|
110
110
|
Color_to_PixelPacket(&draw->info->fill, fill);
|
111
111
|
return self;
|
112
112
|
}
|
113
113
|
|
114
|
+
/*
|
115
|
+
Method: Draw#fill_pattern=
|
116
|
+
Purpose: Accept an image as a fill pattern
|
117
|
+
Notes: See also stroke_pattern=, tile=
|
118
|
+
*/
|
119
|
+
VALUE
|
120
|
+
Draw_fill_pattern_eq(VALUE self, VALUE pattern)
|
121
|
+
{
|
122
|
+
Draw *draw;
|
123
|
+
Image *image;
|
124
|
+
|
125
|
+
rb_check_frozen(self);
|
126
|
+
Data_Get_Struct(self, Draw, draw);
|
127
|
+
|
128
|
+
if (draw->info->fill_pattern != NULL)
|
129
|
+
{
|
130
|
+
// Do not trace destruction
|
131
|
+
DestroyImage(draw->info->fill_pattern);
|
132
|
+
draw->info->fill_pattern = NULL;
|
133
|
+
}
|
134
|
+
|
135
|
+
if (!NIL_P(pattern))
|
136
|
+
{
|
137
|
+
pattern = ImageList_cur_image(pattern);
|
138
|
+
image = rm_check_destroyed(pattern);
|
139
|
+
// Do not trace creation
|
140
|
+
draw->info->fill_pattern = rm_clone_image(image);
|
141
|
+
}
|
142
|
+
|
143
|
+
return self;
|
144
|
+
}
|
145
|
+
|
114
146
|
/*
|
115
147
|
Method: Draw#font=
|
116
148
|
Purpose: font attribute writer
|
@@ -120,9 +152,9 @@ Draw_font_eq(VALUE self, VALUE font)
|
|
120
152
|
{
|
121
153
|
Draw *draw;
|
122
154
|
|
123
|
-
|
155
|
+
rb_check_frozen(self);
|
124
156
|
Data_Get_Struct(self, Draw, draw);
|
125
|
-
magick_clone_string(&draw->info->font,
|
157
|
+
magick_clone_string(&draw->info->font, StringValuePtr(font));
|
126
158
|
|
127
159
|
return self;
|
128
160
|
}
|
@@ -136,9 +168,9 @@ Draw_font_family_eq(VALUE self, VALUE family)
|
|
136
168
|
{
|
137
169
|
Draw *draw;
|
138
170
|
|
139
|
-
|
171
|
+
rb_check_frozen(self);
|
140
172
|
Data_Get_Struct(self, Draw, draw);
|
141
|
-
magick_clone_string(&draw->info->family,
|
173
|
+
magick_clone_string(&draw->info->family, StringValuePtr(family));
|
142
174
|
|
143
175
|
return self;
|
144
176
|
}
|
@@ -152,7 +184,7 @@ Draw_font_stretch_eq(VALUE self, VALUE stretch)
|
|
152
184
|
{
|
153
185
|
Draw *draw;
|
154
186
|
|
155
|
-
|
187
|
+
rb_check_frozen(self);
|
156
188
|
Data_Get_Struct(self, Draw, draw);
|
157
189
|
VALUE_TO_ENUM(stretch, draw->info->stretch, StretchType);
|
158
190
|
return self;
|
@@ -167,7 +199,7 @@ Draw_font_style_eq(VALUE self, VALUE style)
|
|
167
199
|
{
|
168
200
|
Draw *draw;
|
169
201
|
|
170
|
-
|
202
|
+
rb_check_frozen(self);
|
171
203
|
Data_Get_Struct(self, Draw, draw);
|
172
204
|
VALUE_TO_ENUM(style, draw->info->style, StyleType);
|
173
205
|
return self;
|
@@ -187,7 +219,7 @@ Draw_font_weight_eq(VALUE self, VALUE weight)
|
|
187
219
|
Draw *draw;
|
188
220
|
WeightType w;
|
189
221
|
|
190
|
-
|
222
|
+
rb_check_frozen(self);
|
191
223
|
Data_Get_Struct(self, Draw, draw);
|
192
224
|
|
193
225
|
if (FIXNUM_P(weight))
|
@@ -250,7 +282,7 @@ Draw_gravity_eq(VALUE self, VALUE grav)
|
|
250
282
|
{
|
251
283
|
Draw *draw;
|
252
284
|
|
253
|
-
|
285
|
+
rb_check_frozen(self);
|
254
286
|
Data_Get_Struct(self, Draw, draw);
|
255
287
|
VALUE_TO_ENUM(grav, draw->info->gravity, GravityType);
|
256
288
|
|
@@ -266,7 +298,7 @@ Draw_pointsize_eq(VALUE self, VALUE pointsize)
|
|
266
298
|
{
|
267
299
|
Draw *draw;
|
268
300
|
|
269
|
-
|
301
|
+
rb_check_frozen(self);
|
270
302
|
Data_Get_Struct(self, Draw, draw);
|
271
303
|
draw->info->pointsize = NUM2DBL(pointsize);
|
272
304
|
return self;
|
@@ -285,7 +317,7 @@ Draw_rotation_eq(VALUE self, VALUE deg)
|
|
285
317
|
double degrees;
|
286
318
|
AffineMatrix affine, current;
|
287
319
|
|
288
|
-
|
320
|
+
rb_check_frozen(self);
|
289
321
|
Data_Get_Struct(self, Draw, draw);
|
290
322
|
|
291
323
|
degrees = NUM2DBL(deg);
|
@@ -323,12 +355,45 @@ Draw_stroke_eq(VALUE self, VALUE stroke)
|
|
323
355
|
{
|
324
356
|
Draw *draw;
|
325
357
|
|
326
|
-
|
358
|
+
rb_check_frozen(self);
|
327
359
|
Data_Get_Struct(self, Draw, draw);
|
328
360
|
Color_to_PixelPacket(&draw->info->stroke, stroke);
|
329
361
|
return self;
|
330
362
|
}
|
331
363
|
|
364
|
+
/*
|
365
|
+
Method: Draw#stroke_pattern=
|
366
|
+
Purpose: Accept an image as a stroke pattern
|
367
|
+
Notes: See also fill_pattern=
|
368
|
+
*/
|
369
|
+
VALUE
|
370
|
+
Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
|
371
|
+
{
|
372
|
+
Draw *draw;
|
373
|
+
Image *image;
|
374
|
+
|
375
|
+
rb_check_frozen(self);
|
376
|
+
Data_Get_Struct(self, Draw, draw);
|
377
|
+
|
378
|
+
if (draw->info->stroke_pattern != NULL)
|
379
|
+
{
|
380
|
+
// Do not trace destruction
|
381
|
+
DestroyImage(draw->info->stroke_pattern);
|
382
|
+
draw->info->stroke_pattern = NULL;
|
383
|
+
}
|
384
|
+
|
385
|
+
if (!NIL_P(pattern))
|
386
|
+
{
|
387
|
+
// DestroyDrawInfo destroys the clone
|
388
|
+
pattern = ImageList_cur_image(pattern);
|
389
|
+
image = rm_check_destroyed(pattern);
|
390
|
+
// Do not trace creation
|
391
|
+
draw->info->stroke_pattern = rm_clone_image(image);
|
392
|
+
}
|
393
|
+
|
394
|
+
return self;
|
395
|
+
}
|
396
|
+
|
332
397
|
/*
|
333
398
|
Method: Draw#stroke_width=
|
334
399
|
Purpose: stroke_width attribute writer
|
@@ -336,12 +401,12 @@ Draw_stroke_eq(VALUE self, VALUE stroke)
|
|
336
401
|
VALUE
|
337
402
|
Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
|
338
403
|
{
|
339
|
-
|
404
|
+
Draw *draw;
|
340
405
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
406
|
+
rb_check_frozen(self);
|
407
|
+
Data_Get_Struct(self, Draw, draw);
|
408
|
+
draw->info->stroke_width = NUM2DBL(stroke_width);
|
409
|
+
return self;
|
345
410
|
}
|
346
411
|
|
347
412
|
/*
|
@@ -353,7 +418,7 @@ Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
|
|
353
418
|
{
|
354
419
|
Draw *draw;
|
355
420
|
|
356
|
-
|
421
|
+
rb_check_frozen(self);
|
357
422
|
Data_Get_Struct(self, Draw, draw);
|
358
423
|
draw->info->text_antialias = (MagickBooleanType) RTEST(text_antialias);
|
359
424
|
return self;
|
@@ -366,27 +431,7 @@ Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
|
|
366
431
|
VALUE
|
367
432
|
Draw_tile_eq(VALUE self, VALUE image)
|
368
433
|
{
|
369
|
-
|
370
|
-
Image *tile;
|
371
|
-
|
372
|
-
rm_check_frozen(self);
|
373
|
-
Data_Get_Struct(self, Draw, draw);
|
374
|
-
|
375
|
-
if (draw->info->fill_pattern)
|
376
|
-
{
|
377
|
-
(void) DestroyImage(draw->info->fill_pattern);
|
378
|
-
draw->info->fill_pattern = NULL;
|
379
|
-
}
|
380
|
-
|
381
|
-
if (image == Qnil)
|
382
|
-
{
|
383
|
-
return self;
|
384
|
-
}
|
385
|
-
|
386
|
-
Data_Get_Struct(ImageList_cur_image(image), Image, tile);
|
387
|
-
draw->info->fill_pattern = rm_clone_image(tile);
|
388
|
-
|
389
|
-
return self;
|
434
|
+
return Draw_fill_pattern_eq(self, image);
|
390
435
|
}
|
391
436
|
|
392
437
|
/*
|
@@ -398,7 +443,7 @@ Draw_undercolor_eq(VALUE self, VALUE undercolor)
|
|
398
443
|
{
|
399
444
|
Draw *draw;
|
400
445
|
|
401
|
-
|
446
|
+
rb_check_frozen(self);
|
402
447
|
Data_Get_Struct(self, Draw, draw);
|
403
448
|
Color_to_PixelPacket(&draw->info->undercolor, undercolor);
|
404
449
|
return self;
|
@@ -413,13 +458,13 @@ Draw_undercolor_eq(VALUE self, VALUE undercolor)
|
|
413
458
|
Draw object.
|
414
459
|
*/
|
415
460
|
VALUE Draw_annotate(
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
461
|
+
VALUE self,
|
462
|
+
VALUE image_arg,
|
463
|
+
VALUE width_arg,
|
464
|
+
VALUE height_arg,
|
465
|
+
VALUE x_arg,
|
466
|
+
VALUE y_arg,
|
467
|
+
VALUE text)
|
423
468
|
{
|
424
469
|
Draw *draw;
|
425
470
|
Image *image;
|
@@ -433,6 +478,9 @@ VALUE Draw_annotate(
|
|
433
478
|
Data_Get_Struct(self, Draw, draw);
|
434
479
|
keep = draw->info->affine;
|
435
480
|
|
481
|
+
image_arg = ImageList_cur_image(image_arg);
|
482
|
+
image = rm_check_frozen_image(image_arg);
|
483
|
+
|
436
484
|
// If we have an optional parm block, run it in self's context,
|
437
485
|
// allowing the app a chance to modify the object's attributes
|
438
486
|
if (rb_block_given_p())
|
@@ -440,18 +488,11 @@ VALUE Draw_annotate(
|
|
440
488
|
(void)rb_obj_instance_eval(0, NULL, self);
|
441
489
|
}
|
442
490
|
|
443
|
-
rm_check_frozen(ImageList_cur_image(image_arg));
|
444
|
-
Data_Get_Struct(ImageList_cur_image(image_arg), Image, image);
|
445
|
-
|
446
491
|
// Translate & store in Draw structure
|
447
|
-
|
448
|
-
draw->info->text = InterpretImageAttributes(NULL, image, STRING_PTR(text));
|
449
|
-
#else
|
450
|
-
draw->info->text = TranslateText(NULL, image, STRING_PTR(text));
|
451
|
-
#endif
|
492
|
+
draw->info->text = InterpretImageAttributes(NULL, image, StringValuePtr(text));
|
452
493
|
if (!draw->info->text)
|
453
494
|
{
|
454
|
-
|
495
|
+
rb_raise(rb_eArgError, "no text");
|
455
496
|
}
|
456
497
|
|
457
498
|
// Create geometry string, copy to Draw structure, overriding
|
@@ -498,7 +539,7 @@ Draw_clone(VALUE self)
|
|
498
539
|
clone = Draw_dup(self);
|
499
540
|
if (OBJ_FROZEN(self))
|
500
541
|
{
|
501
|
-
(
|
542
|
+
OBJ_FREEZE(clone);
|
502
543
|
}
|
503
544
|
|
504
545
|
return clone;
|
@@ -522,7 +563,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
522
563
|
Image *comp_img;
|
523
564
|
struct TmpFile_Name *tmpfile;
|
524
565
|
char name[MaxTextExtent];
|
525
|
-
|
566
|
+
// Buffer for "image" primitive
|
526
567
|
char primitive[MaxTextExtent];
|
527
568
|
|
528
569
|
if (argc < 5 || argc > 6)
|
@@ -530,6 +571,10 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
530
571
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 5 or 6)", argc);
|
531
572
|
}
|
532
573
|
|
574
|
+
// Retrieve the image to composite
|
575
|
+
image = ImageList_cur_image(argv[4]);
|
576
|
+
(void) rm_check_destroyed(image);
|
577
|
+
|
533
578
|
x = NUM2DBL(argv[0]);
|
534
579
|
y = NUM2DBL(argv[1]);
|
535
580
|
width = NUM2DBL(argv[2]);
|
@@ -540,7 +585,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
540
585
|
{
|
541
586
|
VALUE_TO_ENUM(argv[5], cop, CompositeOperator);
|
542
587
|
|
543
|
-
switch(cop)
|
588
|
+
switch (cop)
|
544
589
|
{
|
545
590
|
case AddCompositeOp:
|
546
591
|
op = "Add";
|
@@ -604,9 +649,6 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
604
649
|
|
605
650
|
Data_Get_Struct(self, Draw, draw);
|
606
651
|
|
607
|
-
// Retrieve the image to composite
|
608
|
-
image = ImageList_cur_image(argv[4]);
|
609
|
-
|
610
652
|
// Create a temp copy of the composite image
|
611
653
|
Data_Get_Struct(image, Image, comp_img);
|
612
654
|
rm_write_temp_image(comp_img, name);
|
@@ -640,17 +682,17 @@ Draw_draw(VALUE self, VALUE image_arg)
|
|
640
682
|
Draw *draw;
|
641
683
|
Image *image;
|
642
684
|
|
685
|
+
image_arg = ImageList_cur_image(image_arg);
|
686
|
+
image = rm_check_frozen_image(image_arg);
|
687
|
+
|
643
688
|
Data_Get_Struct(self, Draw, draw);
|
644
689
|
if (draw->primitives == 0)
|
645
690
|
{
|
646
691
|
rb_raise(rb_eArgError, "nothing to draw");
|
647
692
|
}
|
648
693
|
|
649
|
-
rm_check_frozen(ImageList_cur_image(image_arg));
|
650
|
-
Data_Get_Struct(ImageList_cur_image(image_arg), Image, image);
|
651
|
-
|
652
694
|
// Point the DrawInfo structure at the current set of primitives.
|
653
|
-
magick_clone_string(&(draw->info->primitive),
|
695
|
+
magick_clone_string(&(draw->info->primitive), StringValuePtr(draw->primitives));
|
654
696
|
|
655
697
|
(void) DrawImage(image, draw->info);
|
656
698
|
rm_check_image_exception(image, RetainOnError);
|
@@ -694,9 +736,9 @@ Draw_dup(VALUE self)
|
|
694
736
|
*/
|
695
737
|
VALUE
|
696
738
|
Draw_get_type_metrics(
|
697
|
-
|
698
|
-
|
699
|
-
|
739
|
+
int argc,
|
740
|
+
VALUE *argv,
|
741
|
+
VALUE self)
|
700
742
|
{
|
701
743
|
return get_type_metrics(argc, argv, self, GetTypeMetrics);
|
702
744
|
}
|
@@ -704,16 +746,11 @@ Draw_get_type_metrics(
|
|
704
746
|
|
705
747
|
VALUE
|
706
748
|
Draw_get_multiline_type_metrics(
|
707
|
-
|
708
|
-
|
709
|
-
|
749
|
+
int argc,
|
750
|
+
VALUE *argv,
|
751
|
+
VALUE self)
|
710
752
|
{
|
711
|
-
|
712
|
-
return get_type_metrics(argc, argv, self, GetMultilineTypeMetrics);
|
713
|
-
#else
|
714
|
-
rm_not_implemented();
|
715
|
-
return (VALUE)0;
|
716
|
-
#endif
|
753
|
+
return get_type_metrics(argc, argv, self, GetMultilineTypeMetrics);
|
717
754
|
}
|
718
755
|
|
719
756
|
/*
|
@@ -781,11 +818,7 @@ Draw_inspect(VALUE self)
|
|
781
818
|
Raises: ImageMagickError if no memory
|
782
819
|
*/
|
783
820
|
|
784
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
785
821
|
VALUE Draw_alloc(VALUE class)
|
786
|
-
#else
|
787
|
-
VALUE Draw_new(VALUE class)
|
788
|
-
#endif
|
789
822
|
{
|
790
823
|
Draw *draw;
|
791
824
|
volatile VALUE draw_obj;
|
@@ -794,10 +827,6 @@ VALUE Draw_new(VALUE class)
|
|
794
827
|
memset(draw, 0, sizeof(Draw));
|
795
828
|
draw_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw);
|
796
829
|
|
797
|
-
#if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
798
|
-
rb_obj_call_init(draw_obj, 0, NULL);
|
799
|
-
#endif
|
800
|
-
|
801
830
|
return draw_obj;
|
802
831
|
}
|
803
832
|
|
@@ -811,7 +840,7 @@ Draw_primitive(VALUE self, VALUE primitive)
|
|
811
840
|
{
|
812
841
|
Draw *draw;
|
813
842
|
|
814
|
-
|
843
|
+
rb_check_frozen(self);
|
815
844
|
Data_Get_Struct(self, Draw, draw);
|
816
845
|
|
817
846
|
if (draw->primitives == (VALUE)0)
|
@@ -877,11 +906,7 @@ destroy_Draw(void *drawptr)
|
|
877
906
|
*/
|
878
907
|
static VALUE new_DrawOptions(void)
|
879
908
|
{
|
880
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
881
909
|
return DrawOptions_initialize(Draw_alloc(Class_DrawOptions));
|
882
|
-
#else
|
883
|
-
return DrawOptions_new(Class_DrawOptions);
|
884
|
-
#endif
|
885
910
|
}
|
886
911
|
|
887
912
|
|
@@ -892,11 +917,7 @@ static VALUE new_DrawOptions(void)
|
|
892
917
|
Notes: The DrawOptions class is the same as the Draw class except
|
893
918
|
is has only the attribute writer functions.
|
894
919
|
*/
|
895
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
896
920
|
VALUE DrawOptions_alloc(VALUE class)
|
897
|
-
#else
|
898
|
-
VALUE DrawOptions_new(VALUE class)
|
899
|
-
#endif
|
900
921
|
{
|
901
922
|
Draw *draw_options;
|
902
923
|
volatile VALUE draw_options_obj;
|
@@ -905,10 +926,6 @@ VALUE DrawOptions_new(VALUE class)
|
|
905
926
|
memset(draw_options, 0, sizeof(Draw));
|
906
927
|
draw_options_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw_options);
|
907
928
|
|
908
|
-
#if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
909
|
-
rb_obj_call_init(draw_options_obj, 0, NULL);
|
910
|
-
#endif
|
911
|
-
|
912
929
|
return draw_options_obj;
|
913
930
|
}
|
914
931
|
|
@@ -1006,7 +1023,7 @@ Montage_filename_eq(VALUE self, VALUE filename)
|
|
1006
1023
|
Montage *montage;
|
1007
1024
|
|
1008
1025
|
Data_Get_Struct(self, Montage, montage);
|
1009
|
-
strncpy(montage->info->filename,
|
1026
|
+
strncpy(montage->info->filename, StringValuePtr(filename), MaxTextExtent-1);
|
1010
1027
|
return self;
|
1011
1028
|
}
|
1012
1029
|
|
@@ -1034,7 +1051,7 @@ Montage_font_eq(VALUE self, VALUE font)
|
|
1034
1051
|
Montage *montage;
|
1035
1052
|
|
1036
1053
|
Data_Get_Struct(self, Montage, montage);
|
1037
|
-
magick_clone_string(&montage->info->font,
|
1054
|
+
magick_clone_string(&montage->info->font, StringValuePtr(font));
|
1038
1055
|
|
1039
1056
|
return self;
|
1040
1057
|
}
|
@@ -1054,7 +1071,7 @@ Montage_frame_eq(VALUE self, VALUE frame_arg)
|
|
1054
1071
|
|
1055
1072
|
Data_Get_Struct(self, Montage, montage);
|
1056
1073
|
frame = rb_funcall(frame_arg, rm_ID_to_s, 0);
|
1057
|
-
magick_clone_string(&montage->info->frame,
|
1074
|
+
magick_clone_string(&montage->info->frame, StringValuePtr(frame));
|
1058
1075
|
|
1059
1076
|
return self;
|
1060
1077
|
}
|
@@ -1071,7 +1088,7 @@ Montage_geometry_eq(VALUE self, VALUE geometry_arg)
|
|
1071
1088
|
|
1072
1089
|
Data_Get_Struct(self, Montage, montage);
|
1073
1090
|
geometry = rb_funcall(geometry_arg, rm_ID_to_s, 0);
|
1074
|
-
magick_clone_string(&montage->info->geometry,
|
1091
|
+
magick_clone_string(&montage->info->geometry, StringValuePtr(geometry));
|
1075
1092
|
|
1076
1093
|
return self;
|
1077
1094
|
}
|
@@ -1120,11 +1137,7 @@ Montage_matte_color_eq(VALUE self, VALUE color)
|
|
1120
1137
|
Purpose: Create a new Montage object
|
1121
1138
|
*/
|
1122
1139
|
VALUE
|
1123
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
1124
1140
|
Montage_alloc(VALUE class)
|
1125
|
-
#else
|
1126
|
-
Montage_new(VALUE class)
|
1127
|
-
#endif
|
1128
1141
|
{
|
1129
1142
|
MontageInfo *montage_info;
|
1130
1143
|
Montage *montage;
|
@@ -1151,10 +1164,6 @@ Montage_new(VALUE class)
|
|
1151
1164
|
montage->compose = OverCompositeOp;
|
1152
1165
|
montage_obj = Data_Wrap_Struct(class, NULL, destroy_Montage, montage);
|
1153
1166
|
|
1154
|
-
#if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
1155
|
-
(void) rb_obj_call_init(montage_obj, 0, NULL);
|
1156
|
-
#endif
|
1157
|
-
|
1158
1167
|
return montage_obj;
|
1159
1168
|
}
|
1160
1169
|
|
@@ -1165,11 +1174,7 @@ Montage_new(VALUE class)
|
|
1165
1174
|
|
1166
1175
|
VALUE rm_montage_new(void)
|
1167
1176
|
{
|
1168
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
1169
1177
|
return Montage_initialize(Montage_alloc(Class_Montage));
|
1170
|
-
#else
|
1171
|
-
return Montage_new(Class_Montage);
|
1172
|
-
#endif
|
1173
1178
|
}
|
1174
1179
|
|
1175
1180
|
/*
|
@@ -1260,7 +1265,8 @@ Montage_texture_eq(VALUE self, VALUE texture)
|
|
1260
1265
|
montage->info->texture = NULL;
|
1261
1266
|
}
|
1262
1267
|
|
1263
|
-
|
1268
|
+
texture = ImageList_cur_image(texture);
|
1269
|
+
texture_image = rm_check_destroyed(texture);
|
1264
1270
|
|
1265
1271
|
// Write a temp copy of the image & save its name.
|
1266
1272
|
rm_write_temp_image(texture_image, tmpnam);
|
@@ -1281,7 +1287,7 @@ Montage_tile_eq(VALUE self, VALUE tile_arg)
|
|
1281
1287
|
|
1282
1288
|
Data_Get_Struct(self, Montage, montage);
|
1283
1289
|
tile = rb_funcall(tile_arg, rm_ID_to_s, 0);
|
1284
|
-
magick_clone_string(&montage->info->tile,
|
1290
|
+
magick_clone_string(&montage->info->tile, StringValuePtr(tile));
|
1285
1291
|
|
1286
1292
|
return self;
|
1287
1293
|
}
|
@@ -1296,7 +1302,7 @@ Montage_title_eq(VALUE self, VALUE title)
|
|
1296
1302
|
Montage *montage;
|
1297
1303
|
|
1298
1304
|
Data_Get_Struct(self, Montage, montage);
|
1299
|
-
magick_clone_string(&montage->info->title,
|
1305
|
+
magick_clone_string(&montage->info->title, StringValuePtr(title));
|
1300
1306
|
return self;
|
1301
1307
|
}
|
1302
1308
|
|
@@ -1329,24 +1335,6 @@ PolaroidOptions_alloc(VALUE class)
|
|
1329
1335
|
}
|
1330
1336
|
|
1331
1337
|
|
1332
|
-
/*
|
1333
|
-
Method: PolaroidOptions.new
|
1334
|
-
Purpose: Ruby 1.6 singleton function to allocate and init a PolaroidOptions
|
1335
|
-
object
|
1336
|
-
*/
|
1337
|
-
#if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
1338
|
-
VALUE PolaroidOptions_new(VALUE class)
|
1339
|
-
{
|
1340
|
-
volatile VALUE polaroid_obj;
|
1341
|
-
|
1342
|
-
polaroid_obj = PolaroidOptions_alloc(class);
|
1343
|
-
rb_obj_call_init(polaroid_obj, 0, NULL);
|
1344
|
-
|
1345
|
-
return polaroid_obj;
|
1346
|
-
}
|
1347
|
-
#endif
|
1348
|
-
|
1349
|
-
|
1350
1338
|
/*
|
1351
1339
|
Method: Magick::PolaroidOptions#initialize
|
1352
1340
|
Purpose: Yield to an optional block
|
@@ -1363,6 +1351,7 @@ PolaroidOptions_initialize(VALUE self)
|
|
1363
1351
|
GetExceptionInfo(&exception);
|
1364
1352
|
(void) QueryColorDatabase("gray75", &draw->shadow_color, &exception);
|
1365
1353
|
CHECK_EXCEPTION()
|
1354
|
+
(void) QueryColorDatabase("#dfdfdf", &draw->info->border_color, &exception);
|
1366
1355
|
|
1367
1356
|
if (rb_block_given_p())
|
1368
1357
|
{
|
@@ -1380,11 +1369,7 @@ PolaroidOptions_initialize(VALUE self)
|
|
1380
1369
|
*/
|
1381
1370
|
VALUE rm_polaroid_new(void)
|
1382
1371
|
{
|
1383
|
-
#if defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
1384
1372
|
return PolaroidOptions_initialize(PolaroidOptions_alloc(Class_PolaroidOptions));
|
1385
|
-
#else
|
1386
|
-
return PolaroidOptions_new(Class_PolaroidOptions);
|
1387
|
-
#endif
|
1388
1373
|
}
|
1389
1374
|
|
1390
1375
|
|
@@ -1402,6 +1387,20 @@ VALUE PolaroidOptions_shadow_color_eq(VALUE self, VALUE shadow)
|
|
1402
1387
|
}
|
1403
1388
|
|
1404
1389
|
|
1390
|
+
/*
|
1391
|
+
Method: PolaroidOptions#border_color=
|
1392
|
+
Purpose: Set the border color attribute
|
1393
|
+
*/
|
1394
|
+
VALUE PolaroidOptions_border_color_eq(VALUE self, VALUE border)
|
1395
|
+
{
|
1396
|
+
Draw *draw;
|
1397
|
+
|
1398
|
+
Data_Get_Struct(self, Draw, draw);
|
1399
|
+
Color_to_PixelPacket(&draw->info->border_color, border);
|
1400
|
+
return self;
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
|
1405
1404
|
static VALUE get_dummy_tm_img(VALUE klass)
|
1406
1405
|
{
|
1407
1406
|
volatile VALUE dummy_img = 0;
|
@@ -1424,8 +1423,11 @@ static VALUE get_dummy_tm_img(VALUE klass)
|
|
1424
1423
|
(void) DestroyImageInfo(info);
|
1425
1424
|
dummy_img = rm_image_new(image);
|
1426
1425
|
|
1427
|
-
|
1428
|
-
|
1426
|
+
#if defined(HAVE_NEW_RB_CVAR_SET)
|
1427
|
+
rb_cvar_set(klass, rm_ID__dummy_img_, dummy_img);
|
1428
|
+
#else
|
1429
|
+
rb_cvar_set(klass, rm_ID__dummy_img_, dummy_img, 0);
|
1430
|
+
#endif
|
1429
1431
|
}
|
1430
1432
|
dummy_img = rb_cvar_get(klass, rm_ID__dummy_img_);
|
1431
1433
|
|
@@ -1440,88 +1442,83 @@ static VALUE get_dummy_tm_img(VALUE klass)
|
|
1440
1442
|
*/
|
1441
1443
|
static VALUE
|
1442
1444
|
get_type_metrics(
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1445
|
+
int argc,
|
1446
|
+
VALUE *argv,
|
1447
|
+
VALUE self,
|
1448
|
+
get_type_metrics_func_t getter)
|
1447
1449
|
{
|
1448
|
-
|
1450
|
+
static char attrs[] = "OPbcdefghiklmnopqrstuwxyz[@#%";
|
1449
1451
|
#define ATTRS_L ((int)(sizeof(attrs)-1))
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
}
|
1496
|
-
|
1497
|
-
if (text_l == 0)
|
1498
|
-
{
|
1499
|
-
rb_raise(rb_eArgError, "no text to measure");
|
1500
|
-
}
|
1501
|
-
|
1502
|
-
Data_Get_Struct(self, Draw, draw);
|
1503
|
-
#if defined(HAVE_INTERPRETIMAGEATTRIBUTES)
|
1504
|
-
draw->info->text = InterpretImageAttributes(NULL, image, text);
|
1505
|
-
#else
|
1506
|
-
draw->info->text = TranslateText(NULL, image, text);
|
1507
|
-
#endif
|
1508
|
-
if (!draw->info->text)
|
1509
|
-
{
|
1510
|
-
rb_raise(rb_eArgError, "no text to measure");
|
1511
|
-
}
|
1452
|
+
Image *image;
|
1453
|
+
Draw *draw;
|
1454
|
+
volatile VALUE t;
|
1455
|
+
TypeMetric metrics;
|
1456
|
+
char *text = NULL;
|
1457
|
+
long text_l;
|
1458
|
+
long x;
|
1459
|
+
unsigned int okay;
|
1460
|
+
|
1461
|
+
switch (argc)
|
1462
|
+
{
|
1463
|
+
case 1: // use default image
|
1464
|
+
text = rb_str2cstr(argv[0], &text_l);
|
1465
|
+
|
1466
|
+
for (x = 0; x < text_l; x++)
|
1467
|
+
{
|
1468
|
+
// Ensure text string doesn't refer to image attributes.
|
1469
|
+
if (text[x] == '%' && x < text_l-1)
|
1470
|
+
{
|
1471
|
+
int y;
|
1472
|
+
char spec = text[x+1];
|
1473
|
+
|
1474
|
+
for (y = 0; y < ATTRS_L; y++)
|
1475
|
+
{
|
1476
|
+
if (spec == attrs[y])
|
1477
|
+
{
|
1478
|
+
rb_raise(rb_eArgError,
|
1479
|
+
"text string contains image attribute reference `%%%c'",
|
1480
|
+
spec);
|
1481
|
+
}
|
1482
|
+
}
|
1483
|
+
}
|
1484
|
+
}
|
1485
|
+
|
1486
|
+
Data_Get_Struct(get_dummy_tm_img(CLASS_OF(self)), Image, image);
|
1487
|
+
break;
|
1488
|
+
case 2:
|
1489
|
+
t = ImageList_cur_image(argv[0]);
|
1490
|
+
image = rm_check_destroyed(t);
|
1491
|
+
text = rb_str2cstr(argv[1], &text_l);
|
1492
|
+
break; // okay
|
1493
|
+
default:
|
1494
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
|
1495
|
+
break;
|
1496
|
+
}
|
1512
1497
|
|
1513
|
-
|
1498
|
+
if (text_l == 0)
|
1499
|
+
{
|
1500
|
+
rb_raise(rb_eArgError, "no text to measure");
|
1501
|
+
}
|
1514
1502
|
|
1515
|
-
|
1516
|
-
|
1503
|
+
Data_Get_Struct(self, Draw, draw);
|
1504
|
+
draw->info->text = InterpretImageAttributes(NULL, image, text);
|
1505
|
+
if (!draw->info->text)
|
1506
|
+
{
|
1507
|
+
rb_raise(rb_eArgError, "no text to measure");
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
okay = (*getter)(image, draw->info, &metrics);
|
1517
1511
|
|
1518
|
-
|
1519
|
-
|
1520
|
-
rm_check_image_exception(image, RetainOnError);
|
1512
|
+
magick_free(draw->info->text);
|
1513
|
+
draw->info->text = NULL;
|
1521
1514
|
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1515
|
+
if (!okay)
|
1516
|
+
{
|
1517
|
+
rm_check_image_exception(image, RetainOnError);
|
1518
|
+
|
1519
|
+
// Shouldn't get here...
|
1520
|
+
rb_raise(rb_eRuntimeError, "Can't measure text. Are the fonts installed? "
|
1521
|
+
"Is the FreeType library installed?");
|
1522
|
+
}
|
1523
|
+
return TypeMetric_from_TypeMetric(&metrics);
|
1527
1524
|
}
|