rmagick 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/ImageMagick6/devcontainer.json +1 -1
- data/.devcontainer/devcontainer.json +1 -1
- data/.devcontainer/setup-user.sh +1 -1
- data/.editorconfig +1 -1
- data/.github/workflows/ci.yml +20 -16
- data/.gitignore +1 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +13 -0
- data/before_install_osx.sh +1 -1
- data/ext/RMagick/extconf.rb +19 -12
- data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
- data/ext/RMagick/rmagick.h +70 -49
- data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +25 -24
- data/ext/RMagick/{rmenum.c → rmenum.cpp} +42 -42
- data/ext/RMagick/{rmfill.c → rmfill.cpp} +6 -6
- data/ext/RMagick/{rmilist.c → rmilist.cpp} +23 -21
- data/ext/RMagick/{rmimage.c → rmimage.cpp} +202 -157
- data/ext/RMagick/{rminfo.c → rminfo.cpp} +11 -11
- data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +4 -9
- data/ext/RMagick/rmmain.cpp +1957 -0
- data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +5 -5
- data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +40 -41
- data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +6 -6
- data/ext/RMagick/{rmutil.c → rmutil.cpp} +33 -13
- data/lib/rmagick/version.rb +1 -1
- data/rmagick.gemspec +1 -0
- metadata +30 -16
- data/ext/RMagick/rmmain.c +0 -1955
@@ -5,8 +5,8 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmenum.
|
9
|
-
* @version $Id: rmenum.
|
8
|
+
* @file rmenum.cpp
|
9
|
+
* @version $Id: rmenum.cpp,v 1.9 2009/12/20 02:33:33 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
@@ -40,14 +40,14 @@ const rb_data_type_t rm_enum_data_type = {
|
|
40
40
|
VALUE
|
41
41
|
rm_define_enum_type(const char *tag)
|
42
42
|
{
|
43
|
-
VALUE
|
43
|
+
VALUE klass;
|
44
44
|
|
45
|
-
|
45
|
+
klass = rb_define_class_under(Module_Magick, tag, Class_Enum);\
|
46
46
|
|
47
|
-
rb_define_singleton_method(
|
48
|
-
rb_define_method(
|
49
|
-
rb_define_method(
|
50
|
-
return
|
47
|
+
rb_define_singleton_method(klass, "values", RUBY_METHOD_FUNC(Enum_type_values), 0);
|
48
|
+
rb_define_method(klass, "initialize", RUBY_METHOD_FUNC(Enum_type_initialize), 2);
|
49
|
+
rb_define_method(klass, "inspect", RUBY_METHOD_FUNC(Enum_type_inspect), 0);
|
50
|
+
return klass;
|
51
51
|
}
|
52
52
|
|
53
53
|
|
@@ -56,19 +56,19 @@ rm_define_enum_type(const char *tag)
|
|
56
56
|
*
|
57
57
|
* No Ruby usage (internal function)
|
58
58
|
*
|
59
|
-
* @param
|
59
|
+
* @param klass the subclass
|
60
60
|
* @param sym the symbol
|
61
61
|
* @param val the value for the symbol
|
62
62
|
* @return a new instance of class
|
63
63
|
*/
|
64
64
|
VALUE
|
65
|
-
rm_enum_new(VALUE
|
65
|
+
rm_enum_new(VALUE klass, VALUE sym, VALUE val)
|
66
66
|
{
|
67
67
|
VALUE argv[2];
|
68
68
|
|
69
69
|
argv[0] = sym;
|
70
70
|
argv[1] = val;
|
71
|
-
return rb_obj_freeze(rb_class_new_instance(2, argv,
|
71
|
+
return rb_obj_freeze(rb_class_new_instance(2, argv, klass));
|
72
72
|
}
|
73
73
|
|
74
74
|
/**
|
@@ -118,12 +118,12 @@ static void rm_enum_free(void *magick_enum)
|
|
118
118
|
* @return [Magick::Enum] a new enumerator
|
119
119
|
*/
|
120
120
|
VALUE
|
121
|
-
Enum_alloc(VALUE
|
121
|
+
Enum_alloc(VALUE klass)
|
122
122
|
{
|
123
123
|
MagickEnum *magick_enum;
|
124
124
|
VALUE enumr;
|
125
125
|
|
126
|
-
enumr = TypedData_Make_Struct(
|
126
|
+
enumr = TypedData_Make_Struct(klass, MagickEnum, &rm_enum_data_type, magick_enum);
|
127
127
|
rb_obj_freeze(enumr);
|
128
128
|
|
129
129
|
return enumr;
|
@@ -141,11 +141,11 @@ Enum_case_eq(VALUE self, VALUE other)
|
|
141
141
|
{
|
142
142
|
if (CLASS_OF(self) == CLASS_OF(other))
|
143
143
|
{
|
144
|
-
MagickEnum *
|
144
|
+
MagickEnum *self_enum, *other_enum;
|
145
145
|
|
146
|
-
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type,
|
147
|
-
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type,
|
148
|
-
return
|
146
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
|
147
|
+
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
|
148
|
+
return self_enum->val == other_enum->val ? Qtrue : Qfalse;
|
149
149
|
}
|
150
150
|
|
151
151
|
return Qfalse;
|
@@ -196,20 +196,20 @@ Enum_to_i(VALUE self)
|
|
196
196
|
VALUE
|
197
197
|
Enum_spaceship(VALUE self, VALUE other)
|
198
198
|
{
|
199
|
-
MagickEnum *
|
199
|
+
MagickEnum *self_enum, *other_enum;
|
200
200
|
|
201
201
|
if(CLASS_OF(self) != CLASS_OF(other)) {
|
202
202
|
return Qnil;
|
203
203
|
}
|
204
204
|
|
205
|
-
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type,
|
206
|
-
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type,
|
205
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
|
206
|
+
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
|
207
207
|
|
208
|
-
if (
|
208
|
+
if (self_enum->val > other_enum->val)
|
209
209
|
{
|
210
210
|
return INT2FIX(1);
|
211
211
|
}
|
212
|
-
else if (
|
212
|
+
else if (self_enum->val < other_enum->val)
|
213
213
|
{
|
214
214
|
return INT2FIX(-1);
|
215
215
|
}
|
@@ -224,25 +224,25 @@ Enum_spaceship(VALUE self, VALUE other)
|
|
224
224
|
* @return [Magick::Enum] new Enum instance
|
225
225
|
*/
|
226
226
|
VALUE
|
227
|
-
Enum_bitwise_or(VALUE self, VALUE
|
227
|
+
Enum_bitwise_or(VALUE self, VALUE other)
|
228
228
|
{
|
229
|
-
VALUE new_enum,
|
230
|
-
MagickEnum *
|
229
|
+
VALUE new_enum, klass;
|
230
|
+
MagickEnum *self_enum, *other_enum, *new_enum_data;
|
231
231
|
|
232
|
-
|
233
|
-
if (CLASS_OF(
|
232
|
+
klass = CLASS_OF(self);
|
233
|
+
if (CLASS_OF(other) != klass)
|
234
234
|
{
|
235
|
-
rb_raise(rb_eArgError, "Expected class %s but got %s", rb_class2name(
|
235
|
+
rb_raise(rb_eArgError, "Expected class %s but got %s", rb_class2name(klass), rb_class2name(CLASS_OF(other)));
|
236
236
|
}
|
237
237
|
|
238
|
-
new_enum = Enum_alloc(
|
238
|
+
new_enum = Enum_alloc(klass);
|
239
239
|
|
240
|
-
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type,
|
241
|
-
TypedData_Get_Struct(
|
240
|
+
TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
|
241
|
+
TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
|
242
242
|
TypedData_Get_Struct(new_enum, MagickEnum, &rm_enum_data_type, new_enum_data);
|
243
243
|
|
244
|
-
new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(
|
245
|
-
new_enum_data->val =
|
244
|
+
new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(self_enum->id), rb_id2name(other_enum->id)));
|
245
|
+
new_enum_data->val = self_enum->val | other_enum->val;
|
246
246
|
|
247
247
|
return new_enum;
|
248
248
|
}
|
@@ -321,13 +321,13 @@ Enum_type_inspect(VALUE self)
|
|
321
321
|
* @return [Magick::Enum] self
|
322
322
|
*/
|
323
323
|
static VALUE
|
324
|
-
Enum_type_values(VALUE
|
324
|
+
Enum_type_values(VALUE klass)
|
325
325
|
{
|
326
326
|
VALUE enumerators, copy;
|
327
327
|
VALUE rv;
|
328
328
|
int x;
|
329
329
|
|
330
|
-
enumerators = rb_cv_get(
|
330
|
+
enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
|
331
331
|
|
332
332
|
if (rb_block_given_p())
|
333
333
|
{
|
@@ -335,7 +335,7 @@ Enum_type_values(VALUE class)
|
|
335
335
|
{
|
336
336
|
rb_yield(rb_ary_entry(enumerators, x));
|
337
337
|
}
|
338
|
-
rv =
|
338
|
+
rv = klass;
|
339
339
|
}
|
340
340
|
else
|
341
341
|
{
|
@@ -360,19 +360,19 @@ Enum_type_values(VALUE class)
|
|
360
360
|
*
|
361
361
|
* No Ruby usage (internal function)
|
362
362
|
*
|
363
|
-
* @param
|
363
|
+
* @param klass the class type
|
364
364
|
* @param value the value for enum
|
365
365
|
* @return a enumerator
|
366
366
|
*/
|
367
367
|
|
368
368
|
VALUE
|
369
|
-
Enum_find(VALUE
|
369
|
+
Enum_find(VALUE klass, int val)
|
370
370
|
{
|
371
371
|
VALUE enumerators;
|
372
372
|
MagickEnum *magick_enum;
|
373
373
|
int x;
|
374
374
|
|
375
|
-
enumerators = rb_cv_get(
|
375
|
+
enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
|
376
376
|
enumerators = rm_check_ary_type(enumerators);
|
377
377
|
|
378
378
|
for (x = 0; x < RARRAY_LEN(enumerators); x++)
|
@@ -398,9 +398,9 @@ Enum_find(VALUE class, int val)
|
|
398
398
|
* @return a new enumerator
|
399
399
|
*/
|
400
400
|
VALUE
|
401
|
-
ClassType_find(ClassType
|
401
|
+
ClassType_find(ClassType klass)
|
402
402
|
{
|
403
|
-
return Enum_find(Class_ClassType,
|
403
|
+
return Enum_find(Class_ClassType, klass);
|
404
404
|
}
|
405
405
|
|
406
406
|
|
@@ -485,7 +485,7 @@ ComplianceType_find(ComplianceType compliance)
|
|
485
485
|
if ((compliance & (SVGCompliance|X11Compliance|XPMCompliance))
|
486
486
|
== (SVGCompliance|X11Compliance|XPMCompliance))
|
487
487
|
{
|
488
|
-
c = SVGCompliance|X11Compliance|XPMCompliance;
|
488
|
+
c = (ComplianceType)(SVGCompliance|X11Compliance|XPMCompliance);
|
489
489
|
}
|
490
490
|
else if (compliance & SVGCompliance)
|
491
491
|
{
|
@@ -5,8 +5,8 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmfill.
|
9
|
-
* @version $Id: rmfill.
|
8
|
+
* @file rmfill.cpp
|
9
|
+
* @version $Id: rmfill.cpp,v 1.33 2009/12/20 02:33:33 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
@@ -86,11 +86,11 @@ GradientFill_memsize(const void *ptr)
|
|
86
86
|
* @return [Magick::GradientFill] a new GradientFill object
|
87
87
|
*/
|
88
88
|
VALUE
|
89
|
-
GradientFill_alloc(VALUE
|
89
|
+
GradientFill_alloc(VALUE klass)
|
90
90
|
{
|
91
91
|
rm_GradientFill *fill;
|
92
92
|
|
93
|
-
return TypedData_Make_Struct(
|
93
|
+
return TypedData_Make_Struct(klass, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
94
94
|
}
|
95
95
|
|
96
96
|
|
@@ -741,10 +741,10 @@ TextureFill_memsize(const void *ptr)
|
|
741
741
|
* @return [Magick::TextureFill] a new TextureFill object
|
742
742
|
*/
|
743
743
|
VALUE
|
744
|
-
TextureFill_alloc(VALUE
|
744
|
+
TextureFill_alloc(VALUE klass)
|
745
745
|
{
|
746
746
|
rm_TextureFill *fill;
|
747
|
-
return TypedData_Make_Struct(
|
747
|
+
return TypedData_Make_Struct(klass, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
748
748
|
}
|
749
749
|
|
750
750
|
/**
|
@@ -5,8 +5,8 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmilist.
|
9
|
-
* @version $Id: rmilist.
|
8
|
+
* @file rmilist.cpp
|
9
|
+
* @version $Id: rmilist.cpp,v 1.94 2009/12/20 02:33:33 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
@@ -135,7 +135,7 @@ VALUE
|
|
135
135
|
ImageList_append(VALUE self, VALUE stack_arg)
|
136
136
|
{
|
137
137
|
Image *images, *new_image;
|
138
|
-
|
138
|
+
MagickBooleanType stack;
|
139
139
|
ExceptionInfo *exception;
|
140
140
|
|
141
141
|
// Convert the image array to an image sequence.
|
@@ -143,7 +143,7 @@ ImageList_append(VALUE self, VALUE stack_arg)
|
|
143
143
|
|
144
144
|
// If stack == true, stack rectangular images top-to-bottom,
|
145
145
|
// otherwise left-to-right.
|
146
|
-
stack = RTEST(stack_arg);
|
146
|
+
stack = (MagickBooleanType)RTEST(stack_arg);
|
147
147
|
|
148
148
|
exception = AcquireExceptionInfo();
|
149
149
|
GVL_STRUCT_TYPE(AppendImages) args = { images, stack, exception };
|
@@ -260,20 +260,20 @@ VALUE ImageList_combine(int argc, VALUE *argv, VALUE self)
|
|
260
260
|
{
|
261
261
|
case 5:
|
262
262
|
if (colorspace == CMYKColorspace)
|
263
|
-
channel
|
263
|
+
channel = (ChannelType)(channel | AlphaChannel);
|
264
264
|
else
|
265
265
|
rb_raise(rb_eArgError, "invalid number of images in this image list");
|
266
266
|
case 4:
|
267
267
|
if (colorspace == CMYKColorspace)
|
268
|
-
channel
|
268
|
+
channel = (ChannelType)(channel | IndexChannel);
|
269
269
|
else
|
270
|
-
channel
|
270
|
+
channel = (ChannelType)(channel | AlphaChannel);
|
271
271
|
case 3:
|
272
|
-
channel
|
273
|
-
channel
|
272
|
+
channel = (ChannelType)(channel | GreenChannel);
|
273
|
+
channel = (ChannelType)(channel | BlueChannel);
|
274
274
|
break;
|
275
275
|
case 2:
|
276
|
-
channel
|
276
|
+
channel = (ChannelType)(channel | AlphaChannel);
|
277
277
|
break;
|
278
278
|
case 1:
|
279
279
|
break;
|
@@ -311,10 +311,10 @@ VALUE ImageList_combine(int argc, VALUE *argv, VALUE self)
|
|
311
311
|
* @overload composite_layers(images)
|
312
312
|
* @param images [Magick::ImageList] the source images
|
313
313
|
*
|
314
|
-
* @overload composite_layers(images,
|
314
|
+
* @overload composite_layers(images, composite_op)
|
315
315
|
* - Default operator is {Magick::OverCompositeOp}
|
316
316
|
* @param images [Magick::ImageList] the source images
|
317
|
-
* @param
|
317
|
+
* @param composite_op [Magick::CompositeOperator] the operator
|
318
318
|
*
|
319
319
|
* @return [Magick::ImageList] a new imagelist
|
320
320
|
*/
|
@@ -324,13 +324,13 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
|
324
324
|
VALUE source_images;
|
325
325
|
Image *dest, *source, *new_images;
|
326
326
|
RectangleInfo geometry;
|
327
|
-
CompositeOperator
|
327
|
+
CompositeOperator composite_op = OverCompositeOp;
|
328
328
|
ExceptionInfo *exception;
|
329
329
|
|
330
330
|
switch (argc)
|
331
331
|
{
|
332
332
|
case 2:
|
333
|
-
VALUE_TO_ENUM(argv[1],
|
333
|
+
VALUE_TO_ENUM(argv[1], composite_op, CompositeOperator);
|
334
334
|
case 1:
|
335
335
|
source_images = argv[0];
|
336
336
|
break;
|
@@ -356,7 +356,7 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
|
356
356
|
new_images->gravity, &geometry);
|
357
357
|
|
358
358
|
exception = AcquireExceptionInfo();
|
359
|
-
GVL_STRUCT_TYPE(CompositeLayers) args = { new_images,
|
359
|
+
GVL_STRUCT_TYPE(CompositeLayers) args = { new_images, composite_op, source, geometry.x, geometry.y, exception };
|
360
360
|
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeLayers), &args);
|
361
361
|
rm_split(source);
|
362
362
|
rm_check_exception(exception, new_images, DestroyOnError);
|
@@ -532,16 +532,16 @@ ImageList_morph(VALUE self, VALUE nimages)
|
|
532
532
|
{
|
533
533
|
Image *images, *new_images;
|
534
534
|
ExceptionInfo *exception;
|
535
|
-
|
535
|
+
size_t number_images;
|
536
536
|
|
537
537
|
|
538
538
|
// Use a signed long so we can test for a negative argument.
|
539
|
-
|
540
|
-
if (number_images <= 0)
|
539
|
+
if (NUM2LONG(nimages) <= 0)
|
541
540
|
{
|
542
541
|
rb_raise(rb_eArgError, "number of intervening images must be > 0");
|
543
542
|
}
|
544
543
|
|
544
|
+
number_images = NUM2LONG(nimages);
|
545
545
|
images = images_from_imagelist(self);
|
546
546
|
exception = AcquireExceptionInfo();
|
547
547
|
GVL_STRUCT_TYPE(MorphImages) args = { images, number_images, exception };
|
@@ -970,7 +970,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
970
970
|
if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
|
971
971
|
{
|
972
972
|
VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
|
973
|
-
quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
|
973
|
+
quantize_info.dither = (MagickBooleanType)(quantize_info.dither_method != NoDitherMethod);
|
974
974
|
}
|
975
975
|
else
|
976
976
|
{
|
@@ -1155,7 +1155,7 @@ ImageList_to_blob(VALUE self)
|
|
1155
1155
|
return Qnil;
|
1156
1156
|
}
|
1157
1157
|
|
1158
|
-
blob_str = rb_str_new(blob, (long)length);
|
1158
|
+
blob_str = rb_str_new((const char *)blob, (long)length);
|
1159
1159
|
magick_free((void*)blob);
|
1160
1160
|
|
1161
1161
|
RB_GC_GUARD(info_obj);
|
@@ -1193,7 +1193,9 @@ ImageList_write(VALUE self, VALUE file)
|
|
1193
1193
|
|
1194
1194
|
// Ensure file is open - raise error if not
|
1195
1195
|
GetOpenFile(file, fptr);
|
1196
|
-
|
1196
|
+
rb_io_check_writable(fptr);
|
1197
|
+
|
1198
|
+
add_format_prefix(info, rm_io_path(file));
|
1197
1199
|
#if defined(_WIN32)
|
1198
1200
|
SetImageInfoFile(info, NULL);
|
1199
1201
|
#else
|