rmagick 7.1.7 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +164 -0
- data/README.md +12 -0
- data/Rakefile +1 -0
- data/ext/RMagick/extconf.rb +6 -2
- data/ext/RMagick/rmagick.cpp +55 -58
- data/ext/RMagick/rmagick.h +103 -56
- data/ext/RMagick/rmagick_gvl.cpp +1394 -0
- data/ext/RMagick/rmagick_gvl.h +4 -2
- data/ext/RMagick/rmagick_gvl.hpp +105 -0
- data/ext/RMagick/rmdraw.cpp +702 -294
- data/ext/RMagick/rmenum.cpp +59 -19
- data/ext/RMagick/rmfill.cpp +138 -47
- data/ext/RMagick/rmilist.cpp +387 -183
- data/ext/RMagick/rmimage.cpp +3554 -1711
- data/ext/RMagick/rminfo.cpp +305 -143
- data/ext/RMagick/rmkinfo.cpp +106 -29
- data/ext/RMagick/rmmain.cpp +744 -571
- data/ext/RMagick/rmmontage.cpp +151 -56
- data/ext/RMagick/rmpixel.cpp +115 -112
- data/ext/RMagick/rmstruct.cpp +147 -98
- data/ext/RMagick/rmutil.cpp +432 -93
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +82 -21
- data/lib/rvg/rvg.rb +1 -1
- data/sig/rmagick/_image_common_methods.rbs +1 -1
- data/sig/rmagick/enum.rbs +2 -0
- data/sig/rmagick/image.rbs +1 -0
- data/sig/rmagick/image_list.rbs +1 -0
- data/sig/rmagick/optional_method_arguments.rbs +1 -1
- metadata +4 -2
data/ext/RMagick/rminfo.cpp
CHANGED
|
@@ -18,10 +18,50 @@ const rb_data_type_t rm_info_data_type = {
|
|
|
18
18
|
"Magick::Image::Info",
|
|
19
19
|
{ NULL, Info_free, Info_memsize, },
|
|
20
20
|
0, 0,
|
|
21
|
-
RUBY_TYPED_FROZEN_SHAREABLE,
|
|
21
|
+
RUBY_TYPED_FROZEN_SHAREABLE | RM_TYPED_FREE_IMMEDIATELY,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Return the Info struct of an object that is about to be changed.
|
|
27
|
+
*
|
|
28
|
+
* No Ruby usage (internal function)
|
|
29
|
+
*
|
|
30
|
+
* @param self the Info object
|
|
31
|
+
* @return the Info struct
|
|
32
|
+
* @throw FrozenError if the Info is frozen
|
|
33
|
+
* @throw RuntimeError if a call in flight is using the Info
|
|
34
|
+
*/
|
|
35
|
+
static Info *
|
|
36
|
+
get_writable_info(VALUE self)
|
|
37
|
+
{
|
|
38
|
+
Info *info;
|
|
39
|
+
|
|
40
|
+
// An Info cannot be frozen through #freeze, but check anyway in case it
|
|
41
|
+
// was frozen another way.
|
|
42
|
+
rb_check_frozen(self);
|
|
43
|
+
info = rm_info_get(self);
|
|
44
|
+
rm_gvl_check_writable(self);
|
|
45
|
+
return info;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//! define attribute reader of Info
|
|
49
|
+
#define IMPLEMENT_INFO_ATTR_READER(attr, type) \
|
|
50
|
+
{\
|
|
51
|
+
Info *info = rm_info_get(self);\
|
|
52
|
+
return C_##type##_to_R_##type(info->attr);\
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//! define attribute writer of Info
|
|
56
|
+
#define IMPLEMENT_INFO_ATTR_WRITER(attr, type) \
|
|
57
|
+
{\
|
|
58
|
+
Info *info;\
|
|
59
|
+
rb_check_frozen(self);\
|
|
60
|
+
info = get_writable_info(self);\
|
|
61
|
+
info->attr = R_##type##_to_C_##type(val);\
|
|
62
|
+
return val;\
|
|
63
|
+
}
|
|
64
|
+
|
|
25
65
|
/**
|
|
26
66
|
* Return the value of the specified option.
|
|
27
67
|
*
|
|
@@ -37,7 +77,7 @@ get_option(VALUE self, const char *key)
|
|
|
37
77
|
Info *info;
|
|
38
78
|
const char *value;
|
|
39
79
|
|
|
40
|
-
|
|
80
|
+
info = rm_info_get(self);
|
|
41
81
|
|
|
42
82
|
value = GetImageOption(info, key);
|
|
43
83
|
if (value)
|
|
@@ -82,7 +122,7 @@ set_option(VALUE self, const char *key, VALUE string)
|
|
|
82
122
|
{
|
|
83
123
|
Info *info;
|
|
84
124
|
|
|
85
|
-
|
|
125
|
+
info = get_writable_info(self);
|
|
86
126
|
|
|
87
127
|
if (NIL_P(string))
|
|
88
128
|
{
|
|
@@ -119,7 +159,7 @@ static VALUE set_color_option(VALUE self, const char *option, VALUE color)
|
|
|
119
159
|
PixelColor pp;
|
|
120
160
|
MagickBooleanType okay;
|
|
121
161
|
|
|
122
|
-
|
|
162
|
+
info = get_writable_info(self);
|
|
123
163
|
|
|
124
164
|
if (NIL_P(color))
|
|
125
165
|
{
|
|
@@ -165,7 +205,7 @@ static VALUE get_dbl_option(VALUE self, const char *option)
|
|
|
165
205
|
double d;
|
|
166
206
|
long n;
|
|
167
207
|
|
|
168
|
-
|
|
208
|
+
info = rm_info_get(self);
|
|
169
209
|
|
|
170
210
|
value = GetImageOption(info, option);
|
|
171
211
|
if (!value)
|
|
@@ -196,7 +236,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
|
|
|
196
236
|
{
|
|
197
237
|
Info *info;
|
|
198
238
|
|
|
199
|
-
|
|
239
|
+
info = get_writable_info(self);
|
|
200
240
|
|
|
201
241
|
if (NIL_P(value))
|
|
202
242
|
{
|
|
@@ -243,7 +283,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
|
|
|
243
283
|
VALUE
|
|
244
284
|
Info_antialias(VALUE self)
|
|
245
285
|
{
|
|
246
|
-
|
|
286
|
+
IMPLEMENT_INFO_ATTR_READER(antialias, boolean);
|
|
247
287
|
}
|
|
248
288
|
|
|
249
289
|
/**
|
|
@@ -255,12 +295,40 @@ Info_antialias(VALUE self)
|
|
|
255
295
|
VALUE
|
|
256
296
|
Info_antialias_eq(VALUE self, VALUE val)
|
|
257
297
|
{
|
|
258
|
-
|
|
298
|
+
IMPLEMENT_INFO_ATTR_WRITER(antialias, boolean);
|
|
259
299
|
}
|
|
260
300
|
|
|
261
301
|
/** Maximum length of a format (@see Info_aref) */
|
|
262
302
|
#define MAX_FORMAT_LEN 60
|
|
263
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Build the "format:key" option name shared by Info#[], #[]=, #define and
|
|
306
|
+
* #undefine, applying the same length limit to all four. The caller converts
|
|
307
|
+
* format and key with StringValueCStr first, which rejects a NUL byte so the
|
|
308
|
+
* name cannot be cut short and address a different option, and passes the
|
|
309
|
+
* resulting C strings and their lengths here.
|
|
310
|
+
*
|
|
311
|
+
* No Ruby usage (internal function)
|
|
312
|
+
*
|
|
313
|
+
* @param format_p the format
|
|
314
|
+
* @param format_l the length of the format
|
|
315
|
+
* @param key_p the key
|
|
316
|
+
* @param key_l the length of the key
|
|
317
|
+
* @param buffer the buffer that receives "format:key"
|
|
318
|
+
* @param buffer_l the size of the buffer
|
|
319
|
+
* @throw ArgumentError if the format or the "format:key" name is too long
|
|
320
|
+
*/
|
|
321
|
+
static void
|
|
322
|
+
build_option_key(const char *format_p, size_t format_l, const char *key_p, size_t key_l, char *buffer, size_t buffer_l)
|
|
323
|
+
{
|
|
324
|
+
if (format_l > MAX_FORMAT_LEN || format_l + key_l + 2 > buffer_l)
|
|
325
|
+
{
|
|
326
|
+
rb_raise(rb_eArgError, "can't use %.60s:%.1024s - format or key too long", format_p, key_p);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
snprintf(buffer, buffer_l, "%s:%s", format_p, key_p);
|
|
330
|
+
}
|
|
331
|
+
|
|
264
332
|
/**
|
|
265
333
|
* Get the value of the specified option for the specified format.
|
|
266
334
|
*
|
|
@@ -281,6 +349,7 @@ VALUE
|
|
|
281
349
|
Info_aref(int argc, VALUE *argv, VALUE self)
|
|
282
350
|
{
|
|
283
351
|
Info *info;
|
|
352
|
+
VALUE format = Qnil, key = Qnil;
|
|
284
353
|
char *format_p, *key_p;
|
|
285
354
|
size_t format_l, key_l;
|
|
286
355
|
const char *value;
|
|
@@ -289,14 +358,13 @@ Info_aref(int argc, VALUE *argv, VALUE self)
|
|
|
289
358
|
switch (argc)
|
|
290
359
|
{
|
|
291
360
|
case 2:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
|
|
361
|
+
format = rb_str_new_frozen(StringValue(argv[0]));
|
|
362
|
+
key = argv[1];
|
|
363
|
+
format_p = StringValueCStr(format);
|
|
364
|
+
format_l = (size_t)RSTRING_LEN(format);
|
|
365
|
+
key_p = StringValueCStr(key);
|
|
366
|
+
key_l = (size_t)RSTRING_LEN(key);
|
|
367
|
+
build_option_key(format_p, format_l, key_p, key_l, fkey, sizeof(fkey));
|
|
300
368
|
break;
|
|
301
369
|
|
|
302
370
|
case 1:
|
|
@@ -309,7 +377,10 @@ Info_aref(int argc, VALUE *argv, VALUE self)
|
|
|
309
377
|
|
|
310
378
|
}
|
|
311
379
|
|
|
312
|
-
|
|
380
|
+
RB_GC_GUARD(format);
|
|
381
|
+
RB_GC_GUARD(key);
|
|
382
|
+
|
|
383
|
+
info = rm_info_get(self);
|
|
313
384
|
value = GetImageOption(info, fkey);
|
|
314
385
|
if (!value)
|
|
315
386
|
{
|
|
@@ -348,24 +419,25 @@ Info_aset(int argc, VALUE *argv, VALUE self)
|
|
|
348
419
|
{
|
|
349
420
|
Info *info;
|
|
350
421
|
VALUE value;
|
|
422
|
+
VALUE format = Qnil, key = Qnil;
|
|
351
423
|
char *format_p, *key_p, *value_p = NULL;
|
|
352
424
|
size_t format_l, key_l;
|
|
353
425
|
char ckey[MaxTextExtent];
|
|
354
426
|
|
|
355
|
-
|
|
427
|
+
info = get_writable_info(self);
|
|
356
428
|
|
|
357
429
|
switch (argc)
|
|
358
430
|
{
|
|
359
431
|
case 3:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
432
|
+
format = rb_str_new_frozen(StringValue(argv[0]));
|
|
433
|
+
key = argv[1];
|
|
434
|
+
format_p = StringValueCStr(format);
|
|
435
|
+
format_l = (size_t)RSTRING_LEN(format);
|
|
436
|
+
key_p = StringValueCStr(key);
|
|
437
|
+
key_l = (size_t)RSTRING_LEN(key);
|
|
438
|
+
build_option_key(format_p, format_l, key_p, key_l, ckey, sizeof(ckey));
|
|
439
|
+
RB_GC_GUARD(format);
|
|
440
|
+
RB_GC_GUARD(key);
|
|
369
441
|
|
|
370
442
|
value = argv[2];
|
|
371
443
|
break;
|
|
@@ -443,7 +515,7 @@ Info_authenticate(VALUE self)
|
|
|
443
515
|
{
|
|
444
516
|
Info *info;
|
|
445
517
|
|
|
446
|
-
|
|
518
|
+
info = rm_info_get(self);
|
|
447
519
|
#if defined(IMAGEMAGICK_7)
|
|
448
520
|
return C_str_to_R_str(GetImageOption(info, "authenticate"));
|
|
449
521
|
#else
|
|
@@ -464,7 +536,7 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
|
|
|
464
536
|
Info *info;
|
|
465
537
|
char *passwd = NULL;
|
|
466
538
|
|
|
467
|
-
|
|
539
|
+
info = get_writable_info(self);
|
|
468
540
|
|
|
469
541
|
if (!NIL_P(passwd_arg))
|
|
470
542
|
{
|
|
@@ -497,7 +569,8 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
|
|
|
497
569
|
|
|
498
570
|
|
|
499
571
|
/**
|
|
500
|
-
* Return the name of the background color as a String
|
|
572
|
+
* Return the name of the background color as a String. A CMYK color is named in
|
|
573
|
+
* sRGB.
|
|
501
574
|
*
|
|
502
575
|
* @return [String] the name of the background color
|
|
503
576
|
* @see Image#background_color
|
|
@@ -507,7 +580,7 @@ Info_background_color(VALUE self)
|
|
|
507
580
|
{
|
|
508
581
|
Info *info;
|
|
509
582
|
|
|
510
|
-
|
|
583
|
+
info = rm_info_get(self);
|
|
511
584
|
return rm_pixelcolor_to_color_name_info(info, &info->background_color);
|
|
512
585
|
}
|
|
513
586
|
|
|
@@ -523,14 +596,14 @@ Info_background_color_eq(VALUE self, VALUE bc_arg)
|
|
|
523
596
|
{
|
|
524
597
|
Info *info;
|
|
525
598
|
|
|
526
|
-
|
|
599
|
+
info = get_writable_info(self);
|
|
527
600
|
Color_to_PixelColor(&info->background_color, bc_arg);
|
|
528
601
|
|
|
529
602
|
return bc_arg;
|
|
530
603
|
}
|
|
531
604
|
|
|
532
605
|
/**
|
|
533
|
-
* Return the name of the border color as a String.
|
|
606
|
+
* Return the name of the border color as a String. A CMYK color is named in sRGB.
|
|
534
607
|
*
|
|
535
608
|
* @return [String] the border color name
|
|
536
609
|
* @see Image#border_color
|
|
@@ -540,7 +613,7 @@ Info_border_color(VALUE self)
|
|
|
540
613
|
{
|
|
541
614
|
Info *info;
|
|
542
615
|
|
|
543
|
-
|
|
616
|
+
info = rm_info_get(self);
|
|
544
617
|
return rm_pixelcolor_to_color_name_info(info, &info->border_color);
|
|
545
618
|
}
|
|
546
619
|
|
|
@@ -555,7 +628,7 @@ Info_border_color_eq(VALUE self, VALUE bc_arg)
|
|
|
555
628
|
{
|
|
556
629
|
Info *info;
|
|
557
630
|
|
|
558
|
-
|
|
631
|
+
info = get_writable_info(self);
|
|
559
632
|
Color_to_PixelColor(&info->border_color, bc_arg);
|
|
560
633
|
|
|
561
634
|
return bc_arg;
|
|
@@ -617,7 +690,7 @@ Info_channel(int argc, VALUE *argv, VALUE self)
|
|
|
617
690
|
raise_ChannelType_error(argv[argc-1]);
|
|
618
691
|
}
|
|
619
692
|
|
|
620
|
-
|
|
693
|
+
info = get_writable_info(self);
|
|
621
694
|
|
|
622
695
|
info->channel = channels;
|
|
623
696
|
return self;
|
|
@@ -634,7 +707,7 @@ Info_colorspace(VALUE self)
|
|
|
634
707
|
{
|
|
635
708
|
Info *info;
|
|
636
709
|
|
|
637
|
-
|
|
710
|
+
info = rm_info_get(self);
|
|
638
711
|
return ColorspaceType_find(info->colorspace);
|
|
639
712
|
}
|
|
640
713
|
|
|
@@ -649,7 +722,7 @@ Info_colorspace_eq(VALUE self, VALUE colorspace)
|
|
|
649
722
|
{
|
|
650
723
|
Info *info;
|
|
651
724
|
|
|
652
|
-
|
|
725
|
+
info = get_writable_info(self);
|
|
653
726
|
VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
|
|
654
727
|
return colorspace;
|
|
655
728
|
}
|
|
@@ -688,7 +761,7 @@ Info_compression(VALUE self)
|
|
|
688
761
|
{
|
|
689
762
|
Info *info;
|
|
690
763
|
|
|
691
|
-
|
|
764
|
+
info = rm_info_get(self);
|
|
692
765
|
return CompressionType_find(info->compression);
|
|
693
766
|
}
|
|
694
767
|
|
|
@@ -703,7 +776,7 @@ Info_compression_eq(VALUE self, VALUE type)
|
|
|
703
776
|
{
|
|
704
777
|
Info *info;
|
|
705
778
|
|
|
706
|
-
|
|
779
|
+
info = get_writable_info(self);
|
|
707
780
|
VALUE_TO_ENUM(type, info->compression, CompressionType);
|
|
708
781
|
return type;
|
|
709
782
|
}
|
|
@@ -725,41 +798,46 @@ Info_define(int argc, VALUE *argv, VALUE self)
|
|
|
725
798
|
char *format, *key;
|
|
726
799
|
const char *value = "";
|
|
727
800
|
size_t format_l, key_l;
|
|
728
|
-
char ckey[
|
|
801
|
+
char ckey[MaxTextExtent];
|
|
729
802
|
unsigned int okay;
|
|
730
|
-
VALUE
|
|
803
|
+
VALUE value_arg = Qnil;
|
|
804
|
+
VALUE format_arg = Qnil, key_arg = Qnil;
|
|
731
805
|
|
|
732
|
-
|
|
806
|
+
info = get_writable_info(self);
|
|
733
807
|
|
|
734
808
|
switch (argc)
|
|
735
809
|
{
|
|
736
810
|
case 3:
|
|
737
811
|
/* Allow any argument that supports to_s */
|
|
738
|
-
|
|
739
|
-
value = (const char *)StringValueCStr(
|
|
812
|
+
value_arg = rb_str_new_frozen(rb_String(argv[2]));
|
|
813
|
+
value = (const char *)StringValueCStr(value_arg);
|
|
814
|
+
/* fall through */
|
|
740
815
|
case 2:
|
|
741
|
-
|
|
742
|
-
|
|
816
|
+
key_arg = rb_str_new_frozen(StringValue(argv[1]));
|
|
817
|
+
format_arg = argv[0];
|
|
818
|
+
key = StringValueCStr(key_arg);
|
|
819
|
+
key_l = (size_t)RSTRING_LEN(key_arg);
|
|
820
|
+
format = StringValueCStr(format_arg);
|
|
821
|
+
format_l = (size_t)RSTRING_LEN(format_arg);
|
|
743
822
|
break;
|
|
744
823
|
default:
|
|
745
824
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
|
|
746
825
|
}
|
|
747
826
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
snprintf(ckey, sizeof(ckey), "%s:%s", format, key);
|
|
827
|
+
build_option_key(format, format_l, key, key_l, ckey, sizeof(ckey));
|
|
828
|
+
RB_GC_GUARD(format_arg);
|
|
829
|
+
RB_GC_GUARD(key_arg);
|
|
753
830
|
|
|
754
831
|
DeleteImageOption(info, ckey);
|
|
755
832
|
okay = SetImageOption(info, ckey, value);
|
|
756
833
|
if (!okay)
|
|
757
834
|
{
|
|
758
835
|
rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value);
|
|
836
|
+
RB_GC_GUARD(value_arg);
|
|
759
837
|
return Qnil;
|
|
760
838
|
}
|
|
761
839
|
|
|
762
|
-
RB_GC_GUARD(
|
|
840
|
+
RB_GC_GUARD(value_arg);
|
|
763
841
|
|
|
764
842
|
return self;
|
|
765
843
|
}
|
|
@@ -776,7 +854,7 @@ Info_delay(VALUE self)
|
|
|
776
854
|
const char *delay;
|
|
777
855
|
char *p;
|
|
778
856
|
|
|
779
|
-
|
|
857
|
+
info = rm_info_get(self);
|
|
780
858
|
|
|
781
859
|
delay = GetImageOption(info, "delay");
|
|
782
860
|
if (delay)
|
|
@@ -819,7 +897,7 @@ Info_delay_eq(VALUE self, VALUE string)
|
|
|
819
897
|
Info *info;
|
|
820
898
|
int not_num;
|
|
821
899
|
|
|
822
|
-
|
|
900
|
+
info = get_writable_info(self);
|
|
823
901
|
|
|
824
902
|
if (NIL_P(string))
|
|
825
903
|
{
|
|
@@ -851,7 +929,7 @@ Info_delay_eq(VALUE self, VALUE string)
|
|
|
851
929
|
VALUE
|
|
852
930
|
Info_density(VALUE self)
|
|
853
931
|
{
|
|
854
|
-
|
|
932
|
+
IMPLEMENT_INFO_ATTR_READER(density, str);
|
|
855
933
|
}
|
|
856
934
|
|
|
857
935
|
/**
|
|
@@ -868,7 +946,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
|
|
|
868
946
|
VALUE density;
|
|
869
947
|
char *dens;
|
|
870
948
|
|
|
871
|
-
|
|
949
|
+
info = get_writable_info(self);
|
|
872
950
|
|
|
873
951
|
if (NIL_P(density_arg))
|
|
874
952
|
{
|
|
@@ -899,7 +977,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
|
|
|
899
977
|
VALUE
|
|
900
978
|
Info_depth(VALUE self)
|
|
901
979
|
{
|
|
902
|
-
|
|
980
|
+
IMPLEMENT_INFO_ATTR_READER(depth, int);
|
|
903
981
|
}
|
|
904
982
|
|
|
905
983
|
/**
|
|
@@ -914,7 +992,7 @@ Info_depth_eq(VALUE self, VALUE depth)
|
|
|
914
992
|
Info *info;
|
|
915
993
|
unsigned long d;
|
|
916
994
|
|
|
917
|
-
|
|
995
|
+
info = get_writable_info(self);
|
|
918
996
|
d = NUM2ULONG(depth);
|
|
919
997
|
switch (d)
|
|
920
998
|
{
|
|
@@ -998,7 +1076,7 @@ Info_dispose(VALUE self)
|
|
|
998
1076
|
ID dispose_id;
|
|
999
1077
|
const char *dispose;
|
|
1000
1078
|
|
|
1001
|
-
|
|
1079
|
+
info = rm_info_get(self);
|
|
1002
1080
|
|
|
1003
1081
|
dispose_id = rb_intern("UndefinedDispose");
|
|
1004
1082
|
|
|
@@ -1033,7 +1111,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
|
|
|
1033
1111
|
const char *option;
|
|
1034
1112
|
int x;
|
|
1035
1113
|
|
|
1036
|
-
|
|
1114
|
+
info = get_writable_info(self);
|
|
1037
1115
|
|
|
1038
1116
|
if (NIL_P(disp))
|
|
1039
1117
|
{
|
|
@@ -1065,7 +1143,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
|
|
|
1065
1143
|
VALUE
|
|
1066
1144
|
Info_dither(VALUE self)
|
|
1067
1145
|
{
|
|
1068
|
-
|
|
1146
|
+
IMPLEMENT_INFO_ATTR_READER(dither, boolean);
|
|
1069
1147
|
}
|
|
1070
1148
|
|
|
1071
1149
|
/**
|
|
@@ -1077,7 +1155,7 @@ Info_dither(VALUE self)
|
|
|
1077
1155
|
VALUE
|
|
1078
1156
|
Info_dither_eq(VALUE self, VALUE val)
|
|
1079
1157
|
{
|
|
1080
|
-
|
|
1158
|
+
IMPLEMENT_INFO_ATTR_WRITER(dither, boolean);
|
|
1081
1159
|
}
|
|
1082
1160
|
|
|
1083
1161
|
|
|
@@ -1091,7 +1169,7 @@ Info_endian(VALUE self)
|
|
|
1091
1169
|
{
|
|
1092
1170
|
Info *info;
|
|
1093
1171
|
|
|
1094
|
-
|
|
1172
|
+
info = rm_info_get(self);
|
|
1095
1173
|
return EndianType_find(info->endian);
|
|
1096
1174
|
}
|
|
1097
1175
|
|
|
@@ -1113,7 +1191,7 @@ Info_endian_eq(VALUE self, VALUE endian)
|
|
|
1113
1191
|
VALUE_TO_ENUM(endian, type, EndianType);
|
|
1114
1192
|
}
|
|
1115
1193
|
|
|
1116
|
-
|
|
1194
|
+
info = get_writable_info(self);
|
|
1117
1195
|
info->endian = type;
|
|
1118
1196
|
return endian;
|
|
1119
1197
|
}
|
|
@@ -1128,7 +1206,7 @@ Info_endian_eq(VALUE self, VALUE endian)
|
|
|
1128
1206
|
VALUE
|
|
1129
1207
|
Info_extract(VALUE self)
|
|
1130
1208
|
{
|
|
1131
|
-
|
|
1209
|
+
IMPLEMENT_INFO_ATTR_READER(extract, str);
|
|
1132
1210
|
}
|
|
1133
1211
|
|
|
1134
1212
|
/**
|
|
@@ -1145,7 +1223,7 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
|
|
|
1145
1223
|
char *extr;
|
|
1146
1224
|
VALUE extract;
|
|
1147
1225
|
|
|
1148
|
-
|
|
1226
|
+
info = get_writable_info(self);
|
|
1149
1227
|
|
|
1150
1228
|
if (NIL_P(extract_arg))
|
|
1151
1229
|
{
|
|
@@ -1181,7 +1259,7 @@ Info_filename(VALUE self)
|
|
|
1181
1259
|
{
|
|
1182
1260
|
Info *info;
|
|
1183
1261
|
|
|
1184
|
-
|
|
1262
|
+
info = rm_info_get(self);
|
|
1185
1263
|
return rb_str_new2(info->filename);
|
|
1186
1264
|
}
|
|
1187
1265
|
|
|
@@ -1198,7 +1276,7 @@ Info_filename_eq(VALUE self, VALUE filename)
|
|
|
1198
1276
|
{
|
|
1199
1277
|
Info *info;
|
|
1200
1278
|
|
|
1201
|
-
|
|
1279
|
+
info = get_writable_info(self);
|
|
1202
1280
|
|
|
1203
1281
|
// Allow "nil" - remove current filename
|
|
1204
1282
|
if (NIL_P(filename) || StringValueCStr(filename) == NULL)
|
|
@@ -1249,7 +1327,7 @@ Info_fill_eq(VALUE self, VALUE color)
|
|
|
1249
1327
|
VALUE
|
|
1250
1328
|
Info_font(VALUE self)
|
|
1251
1329
|
{
|
|
1252
|
-
|
|
1330
|
+
IMPLEMENT_INFO_ATTR_READER(font, str);
|
|
1253
1331
|
}
|
|
1254
1332
|
|
|
1255
1333
|
/**
|
|
@@ -1263,7 +1341,7 @@ Info_font_eq(VALUE self, VALUE font_arg)
|
|
|
1263
1341
|
{
|
|
1264
1342
|
Info *info;
|
|
1265
1343
|
|
|
1266
|
-
|
|
1344
|
+
info = get_writable_info(self);
|
|
1267
1345
|
if (NIL_P(font_arg) || StringValueCStr(font_arg) == NULL)
|
|
1268
1346
|
{
|
|
1269
1347
|
magick_free(info->font);
|
|
@@ -1288,7 +1366,7 @@ VALUE Info_format(VALUE self)
|
|
|
1288
1366
|
{
|
|
1289
1367
|
Info *info;
|
|
1290
1368
|
|
|
1291
|
-
|
|
1369
|
+
info = rm_info_get(self);
|
|
1292
1370
|
if (*info->magick)
|
|
1293
1371
|
{
|
|
1294
1372
|
const MagickInfo *magick_info;
|
|
@@ -1318,7 +1396,7 @@ Info_format_eq(VALUE self, VALUE magick)
|
|
|
1318
1396
|
char *mgk;
|
|
1319
1397
|
ExceptionInfo *exception;
|
|
1320
1398
|
|
|
1321
|
-
|
|
1399
|
+
info = get_writable_info(self);
|
|
1322
1400
|
|
|
1323
1401
|
mgk = StringValueCStr(magick);
|
|
1324
1402
|
|
|
@@ -1345,7 +1423,7 @@ Info_format_eq(VALUE self, VALUE magick)
|
|
|
1345
1423
|
VALUE
|
|
1346
1424
|
Info_fuzz(VALUE self)
|
|
1347
1425
|
{
|
|
1348
|
-
|
|
1426
|
+
IMPLEMENT_INFO_ATTR_READER(fuzz, dbl);
|
|
1349
1427
|
}
|
|
1350
1428
|
|
|
1351
1429
|
/**
|
|
@@ -1361,7 +1439,7 @@ Info_fuzz_eq(VALUE self, VALUE fuzz)
|
|
|
1361
1439
|
{
|
|
1362
1440
|
Info *info;
|
|
1363
1441
|
|
|
1364
|
-
|
|
1442
|
+
info = get_writable_info(self);
|
|
1365
1443
|
info->fuzz = rm_fuzz_to_dbl(fuzz);
|
|
1366
1444
|
return fuzz;
|
|
1367
1445
|
}
|
|
@@ -1428,7 +1506,7 @@ VALUE Info_gravity(VALUE self)
|
|
|
1428
1506
|
const char *gravity;
|
|
1429
1507
|
ID gravity_id;
|
|
1430
1508
|
|
|
1431
|
-
|
|
1509
|
+
info = rm_info_get(self);
|
|
1432
1510
|
|
|
1433
1511
|
gravity_id = rb_intern("UndefinedGravity");
|
|
1434
1512
|
|
|
@@ -1464,7 +1542,7 @@ Info_gravity_eq(VALUE self, VALUE grav)
|
|
|
1464
1542
|
const char *option;
|
|
1465
1543
|
int x;
|
|
1466
1544
|
|
|
1467
|
-
|
|
1545
|
+
info = get_writable_info(self);
|
|
1468
1546
|
|
|
1469
1547
|
if (NIL_P(grav))
|
|
1470
1548
|
{
|
|
@@ -1499,7 +1577,7 @@ Info_image_type(VALUE self)
|
|
|
1499
1577
|
{
|
|
1500
1578
|
Info *info;
|
|
1501
1579
|
|
|
1502
|
-
|
|
1580
|
+
info = rm_info_get(self);
|
|
1503
1581
|
return ImageType_find(info->type);
|
|
1504
1582
|
}
|
|
1505
1583
|
|
|
@@ -1514,7 +1592,7 @@ Info_image_type_eq(VALUE self, VALUE type)
|
|
|
1514
1592
|
{
|
|
1515
1593
|
Info *info;
|
|
1516
1594
|
|
|
1517
|
-
|
|
1595
|
+
info = get_writable_info(self);
|
|
1518
1596
|
VALUE_TO_ENUM(type, info->type, ImageType);
|
|
1519
1597
|
return type;
|
|
1520
1598
|
}
|
|
@@ -1529,7 +1607,7 @@ Info_interlace(VALUE self)
|
|
|
1529
1607
|
{
|
|
1530
1608
|
Info *info;
|
|
1531
1609
|
|
|
1532
|
-
|
|
1610
|
+
info = rm_info_get(self);
|
|
1533
1611
|
return InterlaceType_find(info->interlace);
|
|
1534
1612
|
}
|
|
1535
1613
|
|
|
@@ -1544,7 +1622,7 @@ Info_interlace_eq(VALUE self, VALUE inter)
|
|
|
1544
1622
|
{
|
|
1545
1623
|
Info *info;
|
|
1546
1624
|
|
|
1547
|
-
|
|
1625
|
+
info = get_writable_info(self);
|
|
1548
1626
|
VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
|
|
1549
1627
|
return inter;
|
|
1550
1628
|
}
|
|
@@ -1574,7 +1652,7 @@ VALUE Info_label_eq(VALUE self, VALUE string)
|
|
|
1574
1652
|
}
|
|
1575
1653
|
|
|
1576
1654
|
/**
|
|
1577
|
-
* Return the name of the matte color as a String.
|
|
1655
|
+
* Return the name of the matte color as a String. A CMYK color is named in sRGB.
|
|
1578
1656
|
*
|
|
1579
1657
|
* @return [String] the name of the matte color
|
|
1580
1658
|
* @see Image#matte_color
|
|
@@ -1584,7 +1662,7 @@ Info_matte_color(VALUE self)
|
|
|
1584
1662
|
{
|
|
1585
1663
|
Info *info;
|
|
1586
1664
|
|
|
1587
|
-
|
|
1665
|
+
info = rm_info_get(self);
|
|
1588
1666
|
return rm_pixelcolor_to_color_name_info(info, &info->matte_color);
|
|
1589
1667
|
}
|
|
1590
1668
|
|
|
@@ -1599,7 +1677,7 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
|
|
|
1599
1677
|
{
|
|
1600
1678
|
Info *info;
|
|
1601
1679
|
|
|
1602
|
-
|
|
1680
|
+
info = get_writable_info(self);
|
|
1603
1681
|
Color_to_PixelColor(&info->matte_color, matte_arg);
|
|
1604
1682
|
|
|
1605
1683
|
return matte_arg;
|
|
@@ -1613,7 +1691,7 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
|
|
|
1613
1691
|
VALUE
|
|
1614
1692
|
Info_monochrome(VALUE self)
|
|
1615
1693
|
{
|
|
1616
|
-
|
|
1694
|
+
IMPLEMENT_INFO_ATTR_READER(monochrome, boolean);
|
|
1617
1695
|
}
|
|
1618
1696
|
|
|
1619
1697
|
/**
|
|
@@ -1625,7 +1703,7 @@ Info_monochrome(VALUE self)
|
|
|
1625
1703
|
VALUE
|
|
1626
1704
|
Info_monochrome_eq(VALUE self, VALUE val)
|
|
1627
1705
|
{
|
|
1628
|
-
|
|
1706
|
+
IMPLEMENT_INFO_ATTR_WRITER(monochrome, boolean);
|
|
1629
1707
|
}
|
|
1630
1708
|
|
|
1631
1709
|
/**
|
|
@@ -1636,7 +1714,7 @@ Info_monochrome_eq(VALUE self, VALUE val)
|
|
|
1636
1714
|
VALUE
|
|
1637
1715
|
Info_number_scenes(VALUE self)
|
|
1638
1716
|
{
|
|
1639
|
-
|
|
1717
|
+
IMPLEMENT_INFO_ATTR_READER(number_scenes, ulong);
|
|
1640
1718
|
}
|
|
1641
1719
|
|
|
1642
1720
|
/**
|
|
@@ -1648,7 +1726,7 @@ Info_number_scenes(VALUE self)
|
|
|
1648
1726
|
VALUE
|
|
1649
1727
|
Info_number_scenes_eq(VALUE self, VALUE val)
|
|
1650
1728
|
{
|
|
1651
|
-
|
|
1729
|
+
IMPLEMENT_INFO_ATTR_WRITER(number_scenes, ulong);
|
|
1652
1730
|
}
|
|
1653
1731
|
|
|
1654
1732
|
/**
|
|
@@ -1661,7 +1739,7 @@ Info_orientation(VALUE self)
|
|
|
1661
1739
|
{
|
|
1662
1740
|
Info *info;
|
|
1663
1741
|
|
|
1664
|
-
|
|
1742
|
+
info = rm_info_get(self);
|
|
1665
1743
|
return OrientationType_find(info->orientation);
|
|
1666
1744
|
}
|
|
1667
1745
|
|
|
@@ -1677,7 +1755,7 @@ Info_orientation_eq(VALUE self, VALUE inter)
|
|
|
1677
1755
|
{
|
|
1678
1756
|
Info *info;
|
|
1679
1757
|
|
|
1680
|
-
|
|
1758
|
+
info = get_writable_info(self);
|
|
1681
1759
|
VALUE_TO_ENUM(inter, info->orientation, OrientationType);
|
|
1682
1760
|
return inter;
|
|
1683
1761
|
}
|
|
@@ -1695,7 +1773,7 @@ Info_origin(VALUE self)
|
|
|
1695
1773
|
Info *info;
|
|
1696
1774
|
const char *origin;
|
|
1697
1775
|
|
|
1698
|
-
|
|
1776
|
+
info = rm_info_get(self);
|
|
1699
1777
|
|
|
1700
1778
|
origin = GetImageOption(info, "origin");
|
|
1701
1779
|
return origin ? rb_str_new2(origin) : Qnil;
|
|
@@ -1720,7 +1798,7 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
|
|
|
1720
1798
|
VALUE origin_str;
|
|
1721
1799
|
char *origin;
|
|
1722
1800
|
|
|
1723
|
-
|
|
1801
|
+
info = get_writable_info(self);
|
|
1724
1802
|
|
|
1725
1803
|
if (NIL_P(origin_arg))
|
|
1726
1804
|
{
|
|
@@ -1756,7 +1834,7 @@ Info_page(VALUE self)
|
|
|
1756
1834
|
{
|
|
1757
1835
|
Info *info;
|
|
1758
1836
|
|
|
1759
|
-
|
|
1837
|
+
info = rm_info_get(self);
|
|
1760
1838
|
return info->page ? rb_str_new2(info->page) : Qnil;
|
|
1761
1839
|
|
|
1762
1840
|
}
|
|
@@ -1776,7 +1854,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
|
|
|
1776
1854
|
VALUE geom_str;
|
|
1777
1855
|
char *geometry;
|
|
1778
1856
|
|
|
1779
|
-
|
|
1857
|
+
info = get_writable_info(self);
|
|
1780
1858
|
if (NIL_P(page_arg))
|
|
1781
1859
|
{
|
|
1782
1860
|
magick_free(info->page);
|
|
@@ -1808,7 +1886,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
|
|
|
1808
1886
|
VALUE
|
|
1809
1887
|
Info_pointsize(VALUE self)
|
|
1810
1888
|
{
|
|
1811
|
-
|
|
1889
|
+
IMPLEMENT_INFO_ATTR_READER(pointsize, dbl);
|
|
1812
1890
|
}
|
|
1813
1891
|
|
|
1814
1892
|
/**
|
|
@@ -1820,7 +1898,7 @@ Info_pointsize(VALUE self)
|
|
|
1820
1898
|
VALUE
|
|
1821
1899
|
Info_pointsize_eq(VALUE self, VALUE val)
|
|
1822
1900
|
{
|
|
1823
|
-
|
|
1901
|
+
IMPLEMENT_INFO_ATTR_WRITER(pointsize, dbl);
|
|
1824
1902
|
}
|
|
1825
1903
|
|
|
1826
1904
|
/**
|
|
@@ -1831,7 +1909,7 @@ Info_pointsize_eq(VALUE self, VALUE val)
|
|
|
1831
1909
|
VALUE
|
|
1832
1910
|
Info_quality(VALUE self)
|
|
1833
1911
|
{
|
|
1834
|
-
|
|
1912
|
+
IMPLEMENT_INFO_ATTR_READER(quality, ulong);
|
|
1835
1913
|
}
|
|
1836
1914
|
|
|
1837
1915
|
/**
|
|
@@ -1843,7 +1921,7 @@ Info_quality(VALUE self)
|
|
|
1843
1921
|
VALUE
|
|
1844
1922
|
Info_quality_eq(VALUE self, VALUE val)
|
|
1845
1923
|
{
|
|
1846
|
-
|
|
1924
|
+
IMPLEMENT_INFO_ATTR_WRITER(quality, ulong);
|
|
1847
1925
|
}
|
|
1848
1926
|
|
|
1849
1927
|
/**
|
|
@@ -1856,7 +1934,7 @@ Info_sampling_factor(VALUE self)
|
|
|
1856
1934
|
{
|
|
1857
1935
|
Info *info;
|
|
1858
1936
|
|
|
1859
|
-
|
|
1937
|
+
info = rm_info_get(self);
|
|
1860
1938
|
if (info->sampling_factor)
|
|
1861
1939
|
{
|
|
1862
1940
|
return rb_str_new2(info->sampling_factor);
|
|
@@ -1880,7 +1958,7 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
|
|
|
1880
1958
|
char *sampling_factor_p = NULL;
|
|
1881
1959
|
size_t sampling_factor_len = 0;
|
|
1882
1960
|
|
|
1883
|
-
|
|
1961
|
+
info = get_writable_info(self);
|
|
1884
1962
|
|
|
1885
1963
|
if (!NIL_P(sampling_factor))
|
|
1886
1964
|
{
|
|
@@ -1911,7 +1989,7 @@ Info_scene(VALUE self)
|
|
|
1911
1989
|
{
|
|
1912
1990
|
Info *info;
|
|
1913
1991
|
|
|
1914
|
-
|
|
1992
|
+
info = rm_info_get(self);
|
|
1915
1993
|
return ULONG2NUM(info->scene);
|
|
1916
1994
|
}
|
|
1917
1995
|
|
|
@@ -1928,7 +2006,7 @@ Info_scene_eq(VALUE self, VALUE scene)
|
|
|
1928
2006
|
Info *info;
|
|
1929
2007
|
char buf[25];
|
|
1930
2008
|
|
|
1931
|
-
|
|
2009
|
+
info = get_writable_info(self);
|
|
1932
2010
|
info->scene = NUM2ULONG(scene);
|
|
1933
2011
|
|
|
1934
2012
|
snprintf(buf, sizeof(buf), "%" RMIuSIZE "", info->scene);
|
|
@@ -1946,7 +2024,7 @@ Info_scene_eq(VALUE self, VALUE scene)
|
|
|
1946
2024
|
VALUE
|
|
1947
2025
|
Info_server_name(VALUE self)
|
|
1948
2026
|
{
|
|
1949
|
-
|
|
2027
|
+
IMPLEMENT_INFO_ATTR_READER(server_name, str);
|
|
1950
2028
|
}
|
|
1951
2029
|
|
|
1952
2030
|
|
|
@@ -1961,7 +2039,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
|
|
|
1961
2039
|
{
|
|
1962
2040
|
Info *info;
|
|
1963
2041
|
|
|
1964
|
-
|
|
2042
|
+
info = get_writable_info(self);
|
|
1965
2043
|
if (NIL_P(server_arg) || StringValueCStr(server_arg) == NULL)
|
|
1966
2044
|
{
|
|
1967
2045
|
magick_free(info->server_name);
|
|
@@ -1986,7 +2064,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
|
|
|
1986
2064
|
VALUE
|
|
1987
2065
|
Info_size(VALUE self)
|
|
1988
2066
|
{
|
|
1989
|
-
|
|
2067
|
+
IMPLEMENT_INFO_ATTR_READER(size, str);
|
|
1990
2068
|
}
|
|
1991
2069
|
|
|
1992
2070
|
/**
|
|
@@ -2003,7 +2081,7 @@ Info_size_eq(VALUE self, VALUE size_arg)
|
|
|
2003
2081
|
VALUE size;
|
|
2004
2082
|
char *sz;
|
|
2005
2083
|
|
|
2006
|
-
|
|
2084
|
+
info = get_writable_info(self);
|
|
2007
2085
|
|
|
2008
2086
|
if (NIL_P(size_arg))
|
|
2009
2087
|
{
|
|
@@ -2089,7 +2167,7 @@ Info_texture_eq(VALUE self, VALUE texture)
|
|
|
2089
2167
|
Image *image;
|
|
2090
2168
|
char name[MaxTextExtent];
|
|
2091
2169
|
|
|
2092
|
-
|
|
2170
|
+
info = get_writable_info(self);
|
|
2093
2171
|
|
|
2094
2172
|
// Delete any existing texture file
|
|
2095
2173
|
if (info->texture)
|
|
@@ -2106,7 +2184,7 @@ Info_texture_eq(VALUE self, VALUE texture)
|
|
|
2106
2184
|
}
|
|
2107
2185
|
|
|
2108
2186
|
// Create a temp copy of the texture and store its name in the texture field
|
|
2109
|
-
image =
|
|
2187
|
+
image = rm_check_readable(texture);
|
|
2110
2188
|
rm_write_temp_image(image, name, sizeof(name));
|
|
2111
2189
|
|
|
2112
2190
|
magick_clone_string(&info->texture, name);
|
|
@@ -2127,7 +2205,7 @@ Info_tile_offset(VALUE self)
|
|
|
2127
2205
|
Info *info;
|
|
2128
2206
|
const char *tile_offset;
|
|
2129
2207
|
|
|
2130
|
-
|
|
2208
|
+
info = rm_info_get(self);
|
|
2131
2209
|
|
|
2132
2210
|
tile_offset = GetImageOption(info, "tile-offset");
|
|
2133
2211
|
|
|
@@ -2161,7 +2239,7 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
|
|
|
2161
2239
|
rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset);
|
|
2162
2240
|
}
|
|
2163
2241
|
|
|
2164
|
-
|
|
2242
|
+
info = get_writable_info(self);
|
|
2165
2243
|
|
|
2166
2244
|
DeleteImageOption(info, "tile-offset");
|
|
2167
2245
|
SetImageOption(info, "tile-offset", tile_offset);
|
|
@@ -2173,7 +2251,7 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
|
|
|
2173
2251
|
|
|
2174
2252
|
|
|
2175
2253
|
/**
|
|
2176
|
-
* Return the name of the transparent color.
|
|
2254
|
+
* Return the name of the transparent color. A CMYK color is named in sRGB.
|
|
2177
2255
|
*
|
|
2178
2256
|
* @return [String] the name of the transparent color
|
|
2179
2257
|
* @see Image#transparent_color
|
|
@@ -2183,7 +2261,7 @@ Info_transparent_color(VALUE self)
|
|
|
2183
2261
|
{
|
|
2184
2262
|
Info *info;
|
|
2185
2263
|
|
|
2186
|
-
|
|
2264
|
+
info = rm_info_get(self);
|
|
2187
2265
|
return rm_pixelcolor_to_color_name_info(info, &info->transparent_color);
|
|
2188
2266
|
}
|
|
2189
2267
|
|
|
@@ -2199,7 +2277,7 @@ Info_transparent_color_eq(VALUE self, VALUE tc_arg)
|
|
|
2199
2277
|
{
|
|
2200
2278
|
Info *info;
|
|
2201
2279
|
|
|
2202
|
-
|
|
2280
|
+
info = get_writable_info(self);
|
|
2203
2281
|
Color_to_PixelColor(&info->transparent_color, tc_arg);
|
|
2204
2282
|
|
|
2205
2283
|
return tc_arg;
|
|
@@ -2221,19 +2299,18 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
|
|
|
2221
2299
|
size_t format_l, key_l;
|
|
2222
2300
|
char fkey[MaxTextExtent];
|
|
2223
2301
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2302
|
+
format = rb_str_new_frozen(StringValue(format));
|
|
2303
|
+
format_p = StringValueCStr(format);
|
|
2304
|
+
format_l = (size_t)RSTRING_LEN(format);
|
|
2305
|
+
key_p = StringValueCStr(key);
|
|
2306
|
+
key_l = (size_t)RSTRING_LEN(key);
|
|
2307
|
+
build_option_key(format_p, format_l, key_p, key_l, fkey, sizeof(fkey));
|
|
2226
2308
|
|
|
2227
|
-
|
|
2228
|
-
{
|
|
2229
|
-
rb_raise(rb_eArgError, "can't undefine %.60s:%.1024s - too long", format_p, key_p);
|
|
2230
|
-
}
|
|
2231
|
-
|
|
2232
|
-
snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
|
|
2233
|
-
|
|
2234
|
-
TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
|
|
2309
|
+
info = get_writable_info(self);
|
|
2235
2310
|
DeleteImageOption(info, fkey);
|
|
2236
2311
|
|
|
2312
|
+
RB_GC_GUARD(format);
|
|
2313
|
+
|
|
2237
2314
|
return self;
|
|
2238
2315
|
}
|
|
2239
2316
|
|
|
@@ -2271,7 +2348,7 @@ Info_units(VALUE self)
|
|
|
2271
2348
|
{
|
|
2272
2349
|
Info *info;
|
|
2273
2350
|
|
|
2274
|
-
|
|
2351
|
+
info = rm_info_get(self);
|
|
2275
2352
|
return ResolutionType_find(info->units);
|
|
2276
2353
|
}
|
|
2277
2354
|
|
|
@@ -2286,7 +2363,7 @@ Info_units_eq(VALUE self, VALUE units)
|
|
|
2286
2363
|
{
|
|
2287
2364
|
Info *info;
|
|
2288
2365
|
|
|
2289
|
-
|
|
2366
|
+
info = get_writable_info(self);
|
|
2290
2367
|
VALUE_TO_ENUM(units, info->units, ResolutionType);
|
|
2291
2368
|
return units;
|
|
2292
2369
|
}
|
|
@@ -2301,7 +2378,7 @@ Info_view(VALUE self)
|
|
|
2301
2378
|
{
|
|
2302
2379
|
Info *info;
|
|
2303
2380
|
|
|
2304
|
-
|
|
2381
|
+
info = rm_info_get(self);
|
|
2305
2382
|
#if defined(IMAGEMAGICK_7)
|
|
2306
2383
|
return C_str_to_R_str(GetImageOption(info, "fpx:view"));
|
|
2307
2384
|
#else
|
|
@@ -2321,7 +2398,7 @@ Info_view_eq(VALUE self, VALUE view_arg)
|
|
|
2321
2398
|
Info *info;
|
|
2322
2399
|
char *view = NULL;
|
|
2323
2400
|
|
|
2324
|
-
|
|
2401
|
+
info = get_writable_info(self);
|
|
2325
2402
|
|
|
2326
2403
|
if (!NIL_P(view_arg))
|
|
2327
2404
|
{
|
|
@@ -2352,27 +2429,45 @@ Info_view_eq(VALUE self, VALUE view_arg)
|
|
|
2352
2429
|
}
|
|
2353
2430
|
|
|
2354
2431
|
|
|
2432
|
+
/**
|
|
2433
|
+
* Delete the texture image of an ImageInfo, and destroy the ImageInfo.
|
|
2434
|
+
*
|
|
2435
|
+
* No Ruby usage (internal function)
|
|
2436
|
+
*
|
|
2437
|
+
* @param info the ImageInfo, or NULL
|
|
2438
|
+
*/
|
|
2439
|
+
static void
|
|
2440
|
+
destroy_info(Info *info)
|
|
2441
|
+
{
|
|
2442
|
+
if (info)
|
|
2443
|
+
{
|
|
2444
|
+
if (info->texture)
|
|
2445
|
+
{
|
|
2446
|
+
rm_delete_temp_image(info->texture);
|
|
2447
|
+
magick_free(info->texture);
|
|
2448
|
+
info->texture = NULL;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
DestroyImageInfo(info);
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
|
|
2355
2456
|
/**
|
|
2356
2457
|
* If there is a texture image, delete it before destroying the Image::Info
|
|
2357
2458
|
* structure.
|
|
2358
2459
|
*
|
|
2359
2460
|
* No Ruby usage (internal function)
|
|
2360
2461
|
*
|
|
2361
|
-
* @param infoptr pointer to the
|
|
2462
|
+
* @param infoptr pointer to the MagickImageInfo struct
|
|
2362
2463
|
*/
|
|
2363
2464
|
static void
|
|
2364
2465
|
Info_free(void *infoptr)
|
|
2365
2466
|
{
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
if (info->texture)
|
|
2369
|
-
{
|
|
2370
|
-
rm_delete_temp_image(info->texture);
|
|
2371
|
-
magick_free(info->texture);
|
|
2372
|
-
info->texture = NULL;
|
|
2373
|
-
}
|
|
2467
|
+
MagickImageInfo *magick_image_info = (MagickImageInfo *)infoptr;
|
|
2374
2468
|
|
|
2375
|
-
|
|
2469
|
+
destroy_info(magick_image_info->info);
|
|
2470
|
+
xfree(magick_image_info);
|
|
2376
2471
|
}
|
|
2377
2472
|
|
|
2378
2473
|
/**
|
|
@@ -2380,12 +2475,14 @@ Info_free(void *infoptr)
|
|
|
2380
2475
|
*
|
|
2381
2476
|
* No Ruby usage (internal function)
|
|
2382
2477
|
*
|
|
2383
|
-
* @param infoptr pointer to the
|
|
2478
|
+
* @param infoptr pointer to the MagickImageInfo struct
|
|
2384
2479
|
*/
|
|
2385
2480
|
static size_t
|
|
2386
2481
|
Info_memsize(const void *infoptr)
|
|
2387
2482
|
{
|
|
2388
|
-
|
|
2483
|
+
const MagickImageInfo *magick_image_info = (const MagickImageInfo *)infoptr;
|
|
2484
|
+
|
|
2485
|
+
return sizeof(MagickImageInfo) + (magick_image_info->info ? sizeof(Info) : 0);
|
|
2389
2486
|
}
|
|
2390
2487
|
|
|
2391
2488
|
/**
|
|
@@ -2399,15 +2496,15 @@ Info_memsize(const void *infoptr)
|
|
|
2399
2496
|
VALUE
|
|
2400
2497
|
Info_alloc(VALUE klass)
|
|
2401
2498
|
{
|
|
2402
|
-
|
|
2499
|
+
MagickImageInfo *magick_image_info;
|
|
2403
2500
|
VALUE info_obj;
|
|
2404
2501
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2502
|
+
info_obj = TypedData_Make_Struct(klass, MagickImageInfo, &rm_info_data_type, magick_image_info);
|
|
2503
|
+
magick_image_info->info = CloneImageInfo(NULL);
|
|
2504
|
+
if (!magick_image_info->info)
|
|
2407
2505
|
{
|
|
2408
2506
|
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
|
2409
2507
|
}
|
|
2410
|
-
info_obj = TypedData_Wrap_Struct(klass, &rm_info_data_type, info);
|
|
2411
2508
|
|
|
2412
2509
|
RB_GC_GUARD(info_obj);
|
|
2413
2510
|
|
|
@@ -2438,6 +2535,24 @@ rm_info_new(void)
|
|
|
2438
2535
|
}
|
|
2439
2536
|
|
|
2440
2537
|
|
|
2538
|
+
/**
|
|
2539
|
+
* Get the ImageInfo of an Info object.
|
|
2540
|
+
*
|
|
2541
|
+
* No Ruby usage (internal function)
|
|
2542
|
+
*
|
|
2543
|
+
* @param obj the Info object
|
|
2544
|
+
* @return the ImageInfo
|
|
2545
|
+
*/
|
|
2546
|
+
Info *
|
|
2547
|
+
rm_info_get(VALUE obj)
|
|
2548
|
+
{
|
|
2549
|
+
MagickImageInfo *magick_image_info;
|
|
2550
|
+
|
|
2551
|
+
TypedData_Get_Struct(obj, MagickImageInfo, &rm_info_data_type, magick_image_info);
|
|
2552
|
+
return magick_image_info->info;
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
|
|
2441
2556
|
/**
|
|
2442
2557
|
* If an initializer block is present, run it.
|
|
2443
2558
|
*
|
|
@@ -2458,3 +2573,50 @@ Info_initialize(VALUE self)
|
|
|
2458
2573
|
}
|
|
2459
2574
|
return self;
|
|
2460
2575
|
}
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* Initialize clone, dup methods.
|
|
2580
|
+
*
|
|
2581
|
+
* @param orig the original object
|
|
2582
|
+
* @return [Magick::Image::Info] self
|
|
2583
|
+
*/
|
|
2584
|
+
VALUE
|
|
2585
|
+
Info_init_copy(VALUE self, VALUE orig)
|
|
2586
|
+
{
|
|
2587
|
+
MagickImageInfo *copy, *original;
|
|
2588
|
+
Info *info;
|
|
2589
|
+
char texture[MaxTextExtent];
|
|
2590
|
+
bool has_texture = false;
|
|
2591
|
+
|
|
2592
|
+
if (!rm_check_init_copy(self, orig))
|
|
2593
|
+
{
|
|
2594
|
+
return self;
|
|
2595
|
+
}
|
|
2596
|
+
rm_gvl_check_writable(self);
|
|
2597
|
+
rm_gvl_check_readable(orig);
|
|
2598
|
+
TypedData_Get_Struct(orig, MagickImageInfo, &rm_info_data_type, original);
|
|
2599
|
+
TypedData_Get_Struct(self, MagickImageInfo, &rm_info_data_type, copy);
|
|
2600
|
+
|
|
2601
|
+
// The texture names a temporary image that the copy must own by itself.
|
|
2602
|
+
if (original->info->texture)
|
|
2603
|
+
{
|
|
2604
|
+
has_texture = rm_copy_temp_image(original->info->texture, texture, sizeof(texture));
|
|
2605
|
+
}
|
|
2606
|
+
info = CloneImageInfo(original->info);
|
|
2607
|
+
if (!info)
|
|
2608
|
+
{
|
|
2609
|
+
if (has_texture)
|
|
2610
|
+
{
|
|
2611
|
+
rm_delete_temp_image(texture);
|
|
2612
|
+
}
|
|
2613
|
+
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
|
2614
|
+
}
|
|
2615
|
+
magick_clone_string(&info->texture, has_texture ? texture : NULL);
|
|
2616
|
+
|
|
2617
|
+
// A setter can keep a pointer into the ImageInfo while it calls Ruby code.
|
|
2618
|
+
std::swap(*copy->info, *info);
|
|
2619
|
+
destroy_info(info);
|
|
2620
|
+
|
|
2621
|
+
return self;
|
|
2622
|
+
}
|