rmagick 7.2.0 → 7.3.1
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 +130 -0
- data/README.md +2 -1
- data/ext/RMagick/extconf.rb +5 -2
- data/ext/RMagick/rmagick.cpp +55 -58
- data/ext/RMagick/rmagick.h +97 -55
- data/ext/RMagick/rmagick_gvl.cpp +553 -375
- data/ext/RMagick/rmagick_gvl.hpp +15 -10
- data/ext/RMagick/rmdraw.cpp +654 -277
- data/ext/RMagick/rmenum.cpp +59 -19
- data/ext/RMagick/rmfill.cpp +131 -40
- data/ext/RMagick/rmilist.cpp +316 -166
- data/ext/RMagick/rmimage.cpp +2521 -1053
- data/ext/RMagick/rminfo.cpp +250 -107
- data/ext/RMagick/rmkinfo.cpp +87 -29
- data/ext/RMagick/rmmain.cpp +742 -571
- data/ext/RMagick/rmmontage.cpp +121 -46
- data/ext/RMagick/rmpixel.cpp +108 -108
- data/ext/RMagick/rmstruct.cpp +147 -98
- data/ext/RMagick/rmutil.cpp +386 -95
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +69 -19
- 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 +2 -2
data/ext/RMagick/rminfo.cpp
CHANGED
|
@@ -18,7 +18,7 @@ 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
|
|
|
@@ -29,18 +29,39 @@ const rb_data_type_t rm_info_data_type = {
|
|
|
29
29
|
*
|
|
30
30
|
* @param self the Info object
|
|
31
31
|
* @return the Info struct
|
|
32
|
-
* @throw
|
|
32
|
+
* @throw FrozenError if the Info is frozen
|
|
33
|
+
* @throw RuntimeError if a call in flight is using the Info
|
|
33
34
|
*/
|
|
34
35
|
static Info *
|
|
35
36
|
get_writable_info(VALUE self)
|
|
36
37
|
{
|
|
37
38
|
Info *info;
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
41
45
|
return info;
|
|
42
46
|
}
|
|
43
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
|
+
|
|
44
65
|
/**
|
|
45
66
|
* Return the value of the specified option.
|
|
46
67
|
*
|
|
@@ -56,7 +77,7 @@ get_option(VALUE self, const char *key)
|
|
|
56
77
|
Info *info;
|
|
57
78
|
const char *value;
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
info = rm_info_get(self);
|
|
60
81
|
|
|
61
82
|
value = GetImageOption(info, key);
|
|
62
83
|
if (value)
|
|
@@ -184,7 +205,7 @@ static VALUE get_dbl_option(VALUE self, const char *option)
|
|
|
184
205
|
double d;
|
|
185
206
|
long n;
|
|
186
207
|
|
|
187
|
-
|
|
208
|
+
info = rm_info_get(self);
|
|
188
209
|
|
|
189
210
|
value = GetImageOption(info, option);
|
|
190
211
|
if (!value)
|
|
@@ -262,7 +283,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
|
|
|
262
283
|
VALUE
|
|
263
284
|
Info_antialias(VALUE self)
|
|
264
285
|
{
|
|
265
|
-
|
|
286
|
+
IMPLEMENT_INFO_ATTR_READER(antialias, boolean);
|
|
266
287
|
}
|
|
267
288
|
|
|
268
289
|
/**
|
|
@@ -274,12 +295,40 @@ Info_antialias(VALUE self)
|
|
|
274
295
|
VALUE
|
|
275
296
|
Info_antialias_eq(VALUE self, VALUE val)
|
|
276
297
|
{
|
|
277
|
-
|
|
298
|
+
IMPLEMENT_INFO_ATTR_WRITER(antialias, boolean);
|
|
278
299
|
}
|
|
279
300
|
|
|
280
301
|
/** Maximum length of a format (@see Info_aref) */
|
|
281
302
|
#define MAX_FORMAT_LEN 60
|
|
282
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
|
+
|
|
283
332
|
/**
|
|
284
333
|
* Get the value of the specified option for the specified format.
|
|
285
334
|
*
|
|
@@ -300,6 +349,7 @@ VALUE
|
|
|
300
349
|
Info_aref(int argc, VALUE *argv, VALUE self)
|
|
301
350
|
{
|
|
302
351
|
Info *info;
|
|
352
|
+
VALUE format = Qnil, key = Qnil;
|
|
303
353
|
char *format_p, *key_p;
|
|
304
354
|
size_t format_l, key_l;
|
|
305
355
|
const char *value;
|
|
@@ -308,14 +358,13 @@ Info_aref(int argc, VALUE *argv, VALUE self)
|
|
|
308
358
|
switch (argc)
|
|
309
359
|
{
|
|
310
360
|
case 2:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
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));
|
|
319
368
|
break;
|
|
320
369
|
|
|
321
370
|
case 1:
|
|
@@ -328,7 +377,10 @@ Info_aref(int argc, VALUE *argv, VALUE self)
|
|
|
328
377
|
|
|
329
378
|
}
|
|
330
379
|
|
|
331
|
-
|
|
380
|
+
RB_GC_GUARD(format);
|
|
381
|
+
RB_GC_GUARD(key);
|
|
382
|
+
|
|
383
|
+
info = rm_info_get(self);
|
|
332
384
|
value = GetImageOption(info, fkey);
|
|
333
385
|
if (!value)
|
|
334
386
|
{
|
|
@@ -367,6 +419,7 @@ Info_aset(int argc, VALUE *argv, VALUE self)
|
|
|
367
419
|
{
|
|
368
420
|
Info *info;
|
|
369
421
|
VALUE value;
|
|
422
|
+
VALUE format = Qnil, key = Qnil;
|
|
370
423
|
char *format_p, *key_p, *value_p = NULL;
|
|
371
424
|
size_t format_l, key_l;
|
|
372
425
|
char ckey[MaxTextExtent];
|
|
@@ -376,15 +429,15 @@ Info_aset(int argc, VALUE *argv, VALUE self)
|
|
|
376
429
|
switch (argc)
|
|
377
430
|
{
|
|
378
431
|
case 3:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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);
|
|
388
441
|
|
|
389
442
|
value = argv[2];
|
|
390
443
|
break;
|
|
@@ -462,7 +515,7 @@ Info_authenticate(VALUE self)
|
|
|
462
515
|
{
|
|
463
516
|
Info *info;
|
|
464
517
|
|
|
465
|
-
|
|
518
|
+
info = rm_info_get(self);
|
|
466
519
|
#if defined(IMAGEMAGICK_7)
|
|
467
520
|
return C_str_to_R_str(GetImageOption(info, "authenticate"));
|
|
468
521
|
#else
|
|
@@ -516,7 +569,8 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
|
|
|
516
569
|
|
|
517
570
|
|
|
518
571
|
/**
|
|
519
|
-
* 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.
|
|
520
574
|
*
|
|
521
575
|
* @return [String] the name of the background color
|
|
522
576
|
* @see Image#background_color
|
|
@@ -526,7 +580,7 @@ Info_background_color(VALUE self)
|
|
|
526
580
|
{
|
|
527
581
|
Info *info;
|
|
528
582
|
|
|
529
|
-
|
|
583
|
+
info = rm_info_get(self);
|
|
530
584
|
return rm_pixelcolor_to_color_name_info(info, &info->background_color);
|
|
531
585
|
}
|
|
532
586
|
|
|
@@ -549,7 +603,7 @@ Info_background_color_eq(VALUE self, VALUE bc_arg)
|
|
|
549
603
|
}
|
|
550
604
|
|
|
551
605
|
/**
|
|
552
|
-
* 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.
|
|
553
607
|
*
|
|
554
608
|
* @return [String] the border color name
|
|
555
609
|
* @see Image#border_color
|
|
@@ -559,7 +613,7 @@ Info_border_color(VALUE self)
|
|
|
559
613
|
{
|
|
560
614
|
Info *info;
|
|
561
615
|
|
|
562
|
-
|
|
616
|
+
info = rm_info_get(self);
|
|
563
617
|
return rm_pixelcolor_to_color_name_info(info, &info->border_color);
|
|
564
618
|
}
|
|
565
619
|
|
|
@@ -653,7 +707,7 @@ Info_colorspace(VALUE self)
|
|
|
653
707
|
{
|
|
654
708
|
Info *info;
|
|
655
709
|
|
|
656
|
-
|
|
710
|
+
info = rm_info_get(self);
|
|
657
711
|
return ColorspaceType_find(info->colorspace);
|
|
658
712
|
}
|
|
659
713
|
|
|
@@ -707,7 +761,7 @@ Info_compression(VALUE self)
|
|
|
707
761
|
{
|
|
708
762
|
Info *info;
|
|
709
763
|
|
|
710
|
-
|
|
764
|
+
info = rm_info_get(self);
|
|
711
765
|
return CompressionType_find(info->compression);
|
|
712
766
|
}
|
|
713
767
|
|
|
@@ -744,9 +798,10 @@ Info_define(int argc, VALUE *argv, VALUE self)
|
|
|
744
798
|
char *format, *key;
|
|
745
799
|
const char *value = "";
|
|
746
800
|
size_t format_l, key_l;
|
|
747
|
-
char ckey[
|
|
801
|
+
char ckey[MaxTextExtent];
|
|
748
802
|
unsigned int okay;
|
|
749
|
-
VALUE
|
|
803
|
+
VALUE value_arg = Qnil;
|
|
804
|
+
VALUE format_arg = Qnil, key_arg = Qnil;
|
|
750
805
|
|
|
751
806
|
info = get_writable_info(self);
|
|
752
807
|
|
|
@@ -754,31 +809,35 @@ Info_define(int argc, VALUE *argv, VALUE self)
|
|
|
754
809
|
{
|
|
755
810
|
case 3:
|
|
756
811
|
/* Allow any argument that supports to_s */
|
|
757
|
-
|
|
758
|
-
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 */
|
|
759
815
|
case 2:
|
|
760
|
-
|
|
761
|
-
|
|
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);
|
|
762
822
|
break;
|
|
763
823
|
default:
|
|
764
824
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
|
|
765
825
|
}
|
|
766
826
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
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);
|
|
772
830
|
|
|
773
831
|
DeleteImageOption(info, ckey);
|
|
774
832
|
okay = SetImageOption(info, ckey, value);
|
|
775
833
|
if (!okay)
|
|
776
834
|
{
|
|
777
835
|
rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value);
|
|
836
|
+
RB_GC_GUARD(value_arg);
|
|
778
837
|
return Qnil;
|
|
779
838
|
}
|
|
780
839
|
|
|
781
|
-
RB_GC_GUARD(
|
|
840
|
+
RB_GC_GUARD(value_arg);
|
|
782
841
|
|
|
783
842
|
return self;
|
|
784
843
|
}
|
|
@@ -795,7 +854,7 @@ Info_delay(VALUE self)
|
|
|
795
854
|
const char *delay;
|
|
796
855
|
char *p;
|
|
797
856
|
|
|
798
|
-
|
|
857
|
+
info = rm_info_get(self);
|
|
799
858
|
|
|
800
859
|
delay = GetImageOption(info, "delay");
|
|
801
860
|
if (delay)
|
|
@@ -870,7 +929,7 @@ Info_delay_eq(VALUE self, VALUE string)
|
|
|
870
929
|
VALUE
|
|
871
930
|
Info_density(VALUE self)
|
|
872
931
|
{
|
|
873
|
-
|
|
932
|
+
IMPLEMENT_INFO_ATTR_READER(density, str);
|
|
874
933
|
}
|
|
875
934
|
|
|
876
935
|
/**
|
|
@@ -918,7 +977,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
|
|
|
918
977
|
VALUE
|
|
919
978
|
Info_depth(VALUE self)
|
|
920
979
|
{
|
|
921
|
-
|
|
980
|
+
IMPLEMENT_INFO_ATTR_READER(depth, int);
|
|
922
981
|
}
|
|
923
982
|
|
|
924
983
|
/**
|
|
@@ -1017,7 +1076,7 @@ Info_dispose(VALUE self)
|
|
|
1017
1076
|
ID dispose_id;
|
|
1018
1077
|
const char *dispose;
|
|
1019
1078
|
|
|
1020
|
-
|
|
1079
|
+
info = rm_info_get(self);
|
|
1021
1080
|
|
|
1022
1081
|
dispose_id = rb_intern("UndefinedDispose");
|
|
1023
1082
|
|
|
@@ -1084,7 +1143,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
|
|
|
1084
1143
|
VALUE
|
|
1085
1144
|
Info_dither(VALUE self)
|
|
1086
1145
|
{
|
|
1087
|
-
|
|
1146
|
+
IMPLEMENT_INFO_ATTR_READER(dither, boolean);
|
|
1088
1147
|
}
|
|
1089
1148
|
|
|
1090
1149
|
/**
|
|
@@ -1096,7 +1155,7 @@ Info_dither(VALUE self)
|
|
|
1096
1155
|
VALUE
|
|
1097
1156
|
Info_dither_eq(VALUE self, VALUE val)
|
|
1098
1157
|
{
|
|
1099
|
-
|
|
1158
|
+
IMPLEMENT_INFO_ATTR_WRITER(dither, boolean);
|
|
1100
1159
|
}
|
|
1101
1160
|
|
|
1102
1161
|
|
|
@@ -1110,7 +1169,7 @@ Info_endian(VALUE self)
|
|
|
1110
1169
|
{
|
|
1111
1170
|
Info *info;
|
|
1112
1171
|
|
|
1113
|
-
|
|
1172
|
+
info = rm_info_get(self);
|
|
1114
1173
|
return EndianType_find(info->endian);
|
|
1115
1174
|
}
|
|
1116
1175
|
|
|
@@ -1147,7 +1206,7 @@ Info_endian_eq(VALUE self, VALUE endian)
|
|
|
1147
1206
|
VALUE
|
|
1148
1207
|
Info_extract(VALUE self)
|
|
1149
1208
|
{
|
|
1150
|
-
|
|
1209
|
+
IMPLEMENT_INFO_ATTR_READER(extract, str);
|
|
1151
1210
|
}
|
|
1152
1211
|
|
|
1153
1212
|
/**
|
|
@@ -1200,7 +1259,7 @@ Info_filename(VALUE self)
|
|
|
1200
1259
|
{
|
|
1201
1260
|
Info *info;
|
|
1202
1261
|
|
|
1203
|
-
|
|
1262
|
+
info = rm_info_get(self);
|
|
1204
1263
|
return rb_str_new2(info->filename);
|
|
1205
1264
|
}
|
|
1206
1265
|
|
|
@@ -1268,7 +1327,7 @@ Info_fill_eq(VALUE self, VALUE color)
|
|
|
1268
1327
|
VALUE
|
|
1269
1328
|
Info_font(VALUE self)
|
|
1270
1329
|
{
|
|
1271
|
-
|
|
1330
|
+
IMPLEMENT_INFO_ATTR_READER(font, str);
|
|
1272
1331
|
}
|
|
1273
1332
|
|
|
1274
1333
|
/**
|
|
@@ -1307,7 +1366,7 @@ VALUE Info_format(VALUE self)
|
|
|
1307
1366
|
{
|
|
1308
1367
|
Info *info;
|
|
1309
1368
|
|
|
1310
|
-
|
|
1369
|
+
info = rm_info_get(self);
|
|
1311
1370
|
if (*info->magick)
|
|
1312
1371
|
{
|
|
1313
1372
|
const MagickInfo *magick_info;
|
|
@@ -1364,7 +1423,7 @@ Info_format_eq(VALUE self, VALUE magick)
|
|
|
1364
1423
|
VALUE
|
|
1365
1424
|
Info_fuzz(VALUE self)
|
|
1366
1425
|
{
|
|
1367
|
-
|
|
1426
|
+
IMPLEMENT_INFO_ATTR_READER(fuzz, dbl);
|
|
1368
1427
|
}
|
|
1369
1428
|
|
|
1370
1429
|
/**
|
|
@@ -1447,7 +1506,7 @@ VALUE Info_gravity(VALUE self)
|
|
|
1447
1506
|
const char *gravity;
|
|
1448
1507
|
ID gravity_id;
|
|
1449
1508
|
|
|
1450
|
-
|
|
1509
|
+
info = rm_info_get(self);
|
|
1451
1510
|
|
|
1452
1511
|
gravity_id = rb_intern("UndefinedGravity");
|
|
1453
1512
|
|
|
@@ -1518,7 +1577,7 @@ Info_image_type(VALUE self)
|
|
|
1518
1577
|
{
|
|
1519
1578
|
Info *info;
|
|
1520
1579
|
|
|
1521
|
-
|
|
1580
|
+
info = rm_info_get(self);
|
|
1522
1581
|
return ImageType_find(info->type);
|
|
1523
1582
|
}
|
|
1524
1583
|
|
|
@@ -1548,7 +1607,7 @@ Info_interlace(VALUE self)
|
|
|
1548
1607
|
{
|
|
1549
1608
|
Info *info;
|
|
1550
1609
|
|
|
1551
|
-
|
|
1610
|
+
info = rm_info_get(self);
|
|
1552
1611
|
return InterlaceType_find(info->interlace);
|
|
1553
1612
|
}
|
|
1554
1613
|
|
|
@@ -1593,7 +1652,7 @@ VALUE Info_label_eq(VALUE self, VALUE string)
|
|
|
1593
1652
|
}
|
|
1594
1653
|
|
|
1595
1654
|
/**
|
|
1596
|
-
* 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.
|
|
1597
1656
|
*
|
|
1598
1657
|
* @return [String] the name of the matte color
|
|
1599
1658
|
* @see Image#matte_color
|
|
@@ -1603,7 +1662,7 @@ Info_matte_color(VALUE self)
|
|
|
1603
1662
|
{
|
|
1604
1663
|
Info *info;
|
|
1605
1664
|
|
|
1606
|
-
|
|
1665
|
+
info = rm_info_get(self);
|
|
1607
1666
|
return rm_pixelcolor_to_color_name_info(info, &info->matte_color);
|
|
1608
1667
|
}
|
|
1609
1668
|
|
|
@@ -1632,7 +1691,7 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
|
|
|
1632
1691
|
VALUE
|
|
1633
1692
|
Info_monochrome(VALUE self)
|
|
1634
1693
|
{
|
|
1635
|
-
|
|
1694
|
+
IMPLEMENT_INFO_ATTR_READER(monochrome, boolean);
|
|
1636
1695
|
}
|
|
1637
1696
|
|
|
1638
1697
|
/**
|
|
@@ -1644,7 +1703,7 @@ Info_monochrome(VALUE self)
|
|
|
1644
1703
|
VALUE
|
|
1645
1704
|
Info_monochrome_eq(VALUE self, VALUE val)
|
|
1646
1705
|
{
|
|
1647
|
-
|
|
1706
|
+
IMPLEMENT_INFO_ATTR_WRITER(monochrome, boolean);
|
|
1648
1707
|
}
|
|
1649
1708
|
|
|
1650
1709
|
/**
|
|
@@ -1655,7 +1714,7 @@ Info_monochrome_eq(VALUE self, VALUE val)
|
|
|
1655
1714
|
VALUE
|
|
1656
1715
|
Info_number_scenes(VALUE self)
|
|
1657
1716
|
{
|
|
1658
|
-
|
|
1717
|
+
IMPLEMENT_INFO_ATTR_READER(number_scenes, ulong);
|
|
1659
1718
|
}
|
|
1660
1719
|
|
|
1661
1720
|
/**
|
|
@@ -1667,7 +1726,7 @@ Info_number_scenes(VALUE self)
|
|
|
1667
1726
|
VALUE
|
|
1668
1727
|
Info_number_scenes_eq(VALUE self, VALUE val)
|
|
1669
1728
|
{
|
|
1670
|
-
|
|
1729
|
+
IMPLEMENT_INFO_ATTR_WRITER(number_scenes, ulong);
|
|
1671
1730
|
}
|
|
1672
1731
|
|
|
1673
1732
|
/**
|
|
@@ -1680,7 +1739,7 @@ Info_orientation(VALUE self)
|
|
|
1680
1739
|
{
|
|
1681
1740
|
Info *info;
|
|
1682
1741
|
|
|
1683
|
-
|
|
1742
|
+
info = rm_info_get(self);
|
|
1684
1743
|
return OrientationType_find(info->orientation);
|
|
1685
1744
|
}
|
|
1686
1745
|
|
|
@@ -1714,7 +1773,7 @@ Info_origin(VALUE self)
|
|
|
1714
1773
|
Info *info;
|
|
1715
1774
|
const char *origin;
|
|
1716
1775
|
|
|
1717
|
-
|
|
1776
|
+
info = rm_info_get(self);
|
|
1718
1777
|
|
|
1719
1778
|
origin = GetImageOption(info, "origin");
|
|
1720
1779
|
return origin ? rb_str_new2(origin) : Qnil;
|
|
@@ -1775,7 +1834,7 @@ Info_page(VALUE self)
|
|
|
1775
1834
|
{
|
|
1776
1835
|
Info *info;
|
|
1777
1836
|
|
|
1778
|
-
|
|
1837
|
+
info = rm_info_get(self);
|
|
1779
1838
|
return info->page ? rb_str_new2(info->page) : Qnil;
|
|
1780
1839
|
|
|
1781
1840
|
}
|
|
@@ -1827,7 +1886,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
|
|
|
1827
1886
|
VALUE
|
|
1828
1887
|
Info_pointsize(VALUE self)
|
|
1829
1888
|
{
|
|
1830
|
-
|
|
1889
|
+
IMPLEMENT_INFO_ATTR_READER(pointsize, dbl);
|
|
1831
1890
|
}
|
|
1832
1891
|
|
|
1833
1892
|
/**
|
|
@@ -1839,7 +1898,7 @@ Info_pointsize(VALUE self)
|
|
|
1839
1898
|
VALUE
|
|
1840
1899
|
Info_pointsize_eq(VALUE self, VALUE val)
|
|
1841
1900
|
{
|
|
1842
|
-
|
|
1901
|
+
IMPLEMENT_INFO_ATTR_WRITER(pointsize, dbl);
|
|
1843
1902
|
}
|
|
1844
1903
|
|
|
1845
1904
|
/**
|
|
@@ -1850,7 +1909,7 @@ Info_pointsize_eq(VALUE self, VALUE val)
|
|
|
1850
1909
|
VALUE
|
|
1851
1910
|
Info_quality(VALUE self)
|
|
1852
1911
|
{
|
|
1853
|
-
|
|
1912
|
+
IMPLEMENT_INFO_ATTR_READER(quality, ulong);
|
|
1854
1913
|
}
|
|
1855
1914
|
|
|
1856
1915
|
/**
|
|
@@ -1862,7 +1921,7 @@ Info_quality(VALUE self)
|
|
|
1862
1921
|
VALUE
|
|
1863
1922
|
Info_quality_eq(VALUE self, VALUE val)
|
|
1864
1923
|
{
|
|
1865
|
-
|
|
1924
|
+
IMPLEMENT_INFO_ATTR_WRITER(quality, ulong);
|
|
1866
1925
|
}
|
|
1867
1926
|
|
|
1868
1927
|
/**
|
|
@@ -1875,7 +1934,7 @@ Info_sampling_factor(VALUE self)
|
|
|
1875
1934
|
{
|
|
1876
1935
|
Info *info;
|
|
1877
1936
|
|
|
1878
|
-
|
|
1937
|
+
info = rm_info_get(self);
|
|
1879
1938
|
if (info->sampling_factor)
|
|
1880
1939
|
{
|
|
1881
1940
|
return rb_str_new2(info->sampling_factor);
|
|
@@ -1930,7 +1989,7 @@ Info_scene(VALUE self)
|
|
|
1930
1989
|
{
|
|
1931
1990
|
Info *info;
|
|
1932
1991
|
|
|
1933
|
-
|
|
1992
|
+
info = rm_info_get(self);
|
|
1934
1993
|
return ULONG2NUM(info->scene);
|
|
1935
1994
|
}
|
|
1936
1995
|
|
|
@@ -1965,7 +2024,7 @@ Info_scene_eq(VALUE self, VALUE scene)
|
|
|
1965
2024
|
VALUE
|
|
1966
2025
|
Info_server_name(VALUE self)
|
|
1967
2026
|
{
|
|
1968
|
-
|
|
2027
|
+
IMPLEMENT_INFO_ATTR_READER(server_name, str);
|
|
1969
2028
|
}
|
|
1970
2029
|
|
|
1971
2030
|
|
|
@@ -2005,7 +2064,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
|
|
|
2005
2064
|
VALUE
|
|
2006
2065
|
Info_size(VALUE self)
|
|
2007
2066
|
{
|
|
2008
|
-
|
|
2067
|
+
IMPLEMENT_INFO_ATTR_READER(size, str);
|
|
2009
2068
|
}
|
|
2010
2069
|
|
|
2011
2070
|
/**
|
|
@@ -2146,7 +2205,7 @@ Info_tile_offset(VALUE self)
|
|
|
2146
2205
|
Info *info;
|
|
2147
2206
|
const char *tile_offset;
|
|
2148
2207
|
|
|
2149
|
-
|
|
2208
|
+
info = rm_info_get(self);
|
|
2150
2209
|
|
|
2151
2210
|
tile_offset = GetImageOption(info, "tile-offset");
|
|
2152
2211
|
|
|
@@ -2192,7 +2251,7 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
|
|
|
2192
2251
|
|
|
2193
2252
|
|
|
2194
2253
|
/**
|
|
2195
|
-
* Return the name of the transparent color.
|
|
2254
|
+
* Return the name of the transparent color. A CMYK color is named in sRGB.
|
|
2196
2255
|
*
|
|
2197
2256
|
* @return [String] the name of the transparent color
|
|
2198
2257
|
* @see Image#transparent_color
|
|
@@ -2202,7 +2261,7 @@ Info_transparent_color(VALUE self)
|
|
|
2202
2261
|
{
|
|
2203
2262
|
Info *info;
|
|
2204
2263
|
|
|
2205
|
-
|
|
2264
|
+
info = rm_info_get(self);
|
|
2206
2265
|
return rm_pixelcolor_to_color_name_info(info, &info->transparent_color);
|
|
2207
2266
|
}
|
|
2208
2267
|
|
|
@@ -2240,19 +2299,18 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
|
|
|
2240
2299
|
size_t format_l, key_l;
|
|
2241
2300
|
char fkey[MaxTextExtent];
|
|
2242
2301
|
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
|
|
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));
|
|
2252
2308
|
|
|
2253
2309
|
info = get_writable_info(self);
|
|
2254
2310
|
DeleteImageOption(info, fkey);
|
|
2255
2311
|
|
|
2312
|
+
RB_GC_GUARD(format);
|
|
2313
|
+
|
|
2256
2314
|
return self;
|
|
2257
2315
|
}
|
|
2258
2316
|
|
|
@@ -2290,7 +2348,7 @@ Info_units(VALUE self)
|
|
|
2290
2348
|
{
|
|
2291
2349
|
Info *info;
|
|
2292
2350
|
|
|
2293
|
-
|
|
2351
|
+
info = rm_info_get(self);
|
|
2294
2352
|
return ResolutionType_find(info->units);
|
|
2295
2353
|
}
|
|
2296
2354
|
|
|
@@ -2320,7 +2378,7 @@ Info_view(VALUE self)
|
|
|
2320
2378
|
{
|
|
2321
2379
|
Info *info;
|
|
2322
2380
|
|
|
2323
|
-
|
|
2381
|
+
info = rm_info_get(self);
|
|
2324
2382
|
#if defined(IMAGEMAGICK_7)
|
|
2325
2383
|
return C_str_to_R_str(GetImageOption(info, "fpx:view"));
|
|
2326
2384
|
#else
|
|
@@ -2371,27 +2429,45 @@ Info_view_eq(VALUE self, VALUE view_arg)
|
|
|
2371
2429
|
}
|
|
2372
2430
|
|
|
2373
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
|
+
|
|
2374
2456
|
/**
|
|
2375
2457
|
* If there is a texture image, delete it before destroying the Image::Info
|
|
2376
2458
|
* structure.
|
|
2377
2459
|
*
|
|
2378
2460
|
* No Ruby usage (internal function)
|
|
2379
2461
|
*
|
|
2380
|
-
* @param infoptr pointer to the
|
|
2462
|
+
* @param infoptr pointer to the MagickImageInfo struct
|
|
2381
2463
|
*/
|
|
2382
2464
|
static void
|
|
2383
2465
|
Info_free(void *infoptr)
|
|
2384
2466
|
{
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
if (info->texture)
|
|
2388
|
-
{
|
|
2389
|
-
rm_delete_temp_image(info->texture);
|
|
2390
|
-
magick_free(info->texture);
|
|
2391
|
-
info->texture = NULL;
|
|
2392
|
-
}
|
|
2467
|
+
MagickImageInfo *magick_image_info = (MagickImageInfo *)infoptr;
|
|
2393
2468
|
|
|
2394
|
-
|
|
2469
|
+
destroy_info(magick_image_info->info);
|
|
2470
|
+
xfree(magick_image_info);
|
|
2395
2471
|
}
|
|
2396
2472
|
|
|
2397
2473
|
/**
|
|
@@ -2399,12 +2475,14 @@ Info_free(void *infoptr)
|
|
|
2399
2475
|
*
|
|
2400
2476
|
* No Ruby usage (internal function)
|
|
2401
2477
|
*
|
|
2402
|
-
* @param infoptr pointer to the
|
|
2478
|
+
* @param infoptr pointer to the MagickImageInfo struct
|
|
2403
2479
|
*/
|
|
2404
2480
|
static size_t
|
|
2405
2481
|
Info_memsize(const void *infoptr)
|
|
2406
2482
|
{
|
|
2407
|
-
|
|
2483
|
+
const MagickImageInfo *magick_image_info = (const MagickImageInfo *)infoptr;
|
|
2484
|
+
|
|
2485
|
+
return sizeof(MagickImageInfo) + (magick_image_info->info ? sizeof(Info) : 0);
|
|
2408
2486
|
}
|
|
2409
2487
|
|
|
2410
2488
|
/**
|
|
@@ -2418,15 +2496,15 @@ Info_memsize(const void *infoptr)
|
|
|
2418
2496
|
VALUE
|
|
2419
2497
|
Info_alloc(VALUE klass)
|
|
2420
2498
|
{
|
|
2421
|
-
|
|
2499
|
+
MagickImageInfo *magick_image_info;
|
|
2422
2500
|
VALUE info_obj;
|
|
2423
2501
|
|
|
2424
|
-
|
|
2425
|
-
|
|
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)
|
|
2426
2505
|
{
|
|
2427
2506
|
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
|
2428
2507
|
}
|
|
2429
|
-
info_obj = TypedData_Wrap_Struct(klass, &rm_info_data_type, info);
|
|
2430
2508
|
|
|
2431
2509
|
RB_GC_GUARD(info_obj);
|
|
2432
2510
|
|
|
@@ -2457,6 +2535,24 @@ rm_info_new(void)
|
|
|
2457
2535
|
}
|
|
2458
2536
|
|
|
2459
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
|
+
|
|
2460
2556
|
/**
|
|
2461
2557
|
* If an initializer block is present, run it.
|
|
2462
2558
|
*
|
|
@@ -2477,3 +2573,50 @@ Info_initialize(VALUE self)
|
|
|
2477
2573
|
}
|
|
2478
2574
|
return self;
|
|
2479
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
|
+
}
|