rmagick 5.0.0 → 5.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +5 -14
- data/before_install_osx.sh +2 -1
- data/ext/RMagick/extconf.rb +21 -21
- data/ext/RMagick/rmagick.h +23 -11
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/rmdraw.c +101 -69
- data/ext/RMagick/rmenum.c +34 -15
- data/ext/RMagick/rmfill.c +77 -16
- data/ext/RMagick/rmilist.c +156 -58
- data/ext/RMagick/rmimage.c +1073 -486
- data/ext/RMagick/rminfo.c +107 -85
- data/ext/RMagick/rmkinfo.c +43 -13
- data/ext/RMagick/rmmain.c +4 -0
- data/ext/RMagick/rmmontage.c +41 -20
- data/ext/RMagick/rmpixel.c +64 -40
- data/ext/RMagick/rmutil.c +7 -3
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +8 -13
- data/rmagick.gemspec +2 -0
- metadata +17 -2
data/ext/RMagick/rmkinfo.c
CHANGED
@@ -10,8 +10,28 @@
|
|
10
10
|
|
11
11
|
#include "rmagick.h"
|
12
12
|
|
13
|
+
static void rm_kernel_info_destroy(void *kernel);
|
14
|
+
static size_t rm_kernel_info_memsize(const void *ptr);
|
15
|
+
|
16
|
+
const rb_data_type_t rm_kernel_info_data_type = {
|
17
|
+
"Magick::KernelInfo",
|
18
|
+
{ NULL, rm_kernel_info_destroy, rm_kernel_info_memsize, },
|
19
|
+
0, 0,
|
20
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
21
|
+
};
|
22
|
+
|
23
|
+
/* UnityAddKernelInfo() was private function until IM 6.9 */
|
24
|
+
MagickExport void UnityAddKernelInfo(KernelInfo *kernel, const double scale);
|
25
|
+
/* ScaleKernelInfo() was private function until IM 6.9 */
|
26
|
+
MagickExport void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor, const GeometryFlags normalize_flags);
|
27
|
+
|
28
|
+
DEFINE_GVL_VOID_STUB2(UnityAddKernelInfo, KernelInfo *, const double);
|
29
|
+
DEFINE_GVL_VOID_STUB3(ScaleKernelInfo, KernelInfo *, const double, const GeometryFlags);
|
30
|
+
DEFINE_GVL_VOID_STUB2(ScaleGeometryKernelInfo, KernelInfo *, const char *);
|
31
|
+
|
32
|
+
|
13
33
|
/**
|
14
|
-
* If there's a kernel info, delete it before destroying the KernelInfo
|
34
|
+
* If there's a kernel info, delete it before destroying the KernelInfo
|
15
35
|
*
|
16
36
|
* No Ruby usage (internal function)
|
17
37
|
*
|
@@ -25,6 +45,19 @@ rm_kernel_info_destroy(void *kernel)
|
|
25
45
|
DestroyKernelInfo((KernelInfo*)kernel);
|
26
46
|
}
|
27
47
|
|
48
|
+
/**
|
49
|
+
* Get KernelInfo object size.
|
50
|
+
*
|
51
|
+
* No Ruby usage (internal function)
|
52
|
+
*
|
53
|
+
* @param ptr pointer to the KernelInfo object
|
54
|
+
*/
|
55
|
+
static size_t
|
56
|
+
rm_kernel_info_memsize(const void *ptr)
|
57
|
+
{
|
58
|
+
return sizeof(KernelInfo);
|
59
|
+
}
|
60
|
+
|
28
61
|
/**
|
29
62
|
* Create a KernelInfo object.
|
30
63
|
*
|
@@ -33,7 +66,7 @@ rm_kernel_info_destroy(void *kernel)
|
|
33
66
|
VALUE
|
34
67
|
KernelInfo_alloc(VALUE class)
|
35
68
|
{
|
36
|
-
return
|
69
|
+
return TypedData_Wrap_Struct(class, &rm_kernel_info_data_type, NULL);
|
37
70
|
}
|
38
71
|
|
39
72
|
/**
|
@@ -89,10 +122,8 @@ KernelInfo_unity_add(VALUE self, VALUE scale)
|
|
89
122
|
if (!FIXNUM_P(scale))
|
90
123
|
Check_Type(scale, T_FLOAT);
|
91
124
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
UnityAddKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale));
|
125
|
+
GVL_STRUCT_TYPE(UnityAddKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale) };
|
126
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnityAddKernelInfo), &args);
|
96
127
|
return Qnil;
|
97
128
|
}
|
98
129
|
|
@@ -118,10 +149,8 @@ KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
|
|
118
149
|
else
|
119
150
|
rb_raise(rb_eArgError, "expected Integer or Magick::GeometryFlags to specify flags");
|
120
151
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
ScaleKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags);
|
152
|
+
GVL_STRUCT_TYPE(ScaleKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags };
|
153
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleKernelInfo), &args);
|
125
154
|
return Qnil;
|
126
155
|
}
|
127
156
|
|
@@ -135,7 +164,8 @@ VALUE
|
|
135
164
|
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
|
136
165
|
{
|
137
166
|
Check_Type(geometry, T_STRING);
|
138
|
-
ScaleGeometryKernelInfo(
|
167
|
+
GVL_STRUCT_TYPE(ScaleGeometryKernelInfo) args = { (KernelInfo*)DATA_PTR(self), StringValueCStr(geometry) };
|
168
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleGeometryKernelInfo), &args);
|
139
169
|
return Qnil;
|
140
170
|
}
|
141
171
|
|
@@ -148,7 +178,7 @@ VALUE
|
|
148
178
|
KernelInfo_clone(VALUE self)
|
149
179
|
{
|
150
180
|
KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
|
151
|
-
return
|
181
|
+
return TypedData_Wrap_Struct(Class_KernelInfo, &rm_kernel_info_data_type, kernel);
|
152
182
|
}
|
153
183
|
|
154
184
|
/**
|
@@ -194,5 +224,5 @@ KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
|
|
194
224
|
rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
|
195
225
|
}
|
196
226
|
|
197
|
-
return
|
227
|
+
return TypedData_Wrap_Struct(self, &rm_kernel_info_data_type, kernel);
|
198
228
|
}
|
data/ext/RMagick/rmmain.c
CHANGED
data/ext/RMagick/rmmontage.c
CHANGED
@@ -12,8 +12,15 @@
|
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
|
15
|
+
static void Montage_destroy(void *obj);
|
16
|
+
static size_t Montage_memsize(const void *obj);
|
15
17
|
|
16
|
-
|
18
|
+
const rb_data_type_t rm_montage_data_type = {
|
19
|
+
"Magick::ImageList::Montage",
|
20
|
+
{ NULL, Montage_destroy, Montage_memsize, },
|
21
|
+
0, 0,
|
22
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
23
|
+
};
|
17
24
|
|
18
25
|
|
19
26
|
/**
|
@@ -28,7 +35,7 @@
|
|
28
35
|
* @param obj the montage object
|
29
36
|
*/
|
30
37
|
static void
|
31
|
-
|
38
|
+
Montage_destroy(void *obj)
|
32
39
|
{
|
33
40
|
Montage *montage = obj;
|
34
41
|
|
@@ -48,6 +55,20 @@ destroy_Montage(void *obj)
|
|
48
55
|
}
|
49
56
|
|
50
57
|
|
58
|
+
/**
|
59
|
+
* Get Montage object size.
|
60
|
+
*
|
61
|
+
* No Ruby usage (internal function)
|
62
|
+
*
|
63
|
+
* @param ptr pointer to the Montage object
|
64
|
+
*/
|
65
|
+
static size_t
|
66
|
+
Montage_memsize(const void *ptr)
|
67
|
+
{
|
68
|
+
return sizeof(Montage);
|
69
|
+
}
|
70
|
+
|
71
|
+
|
51
72
|
/**
|
52
73
|
* Create a new Montage object.
|
53
74
|
*
|
@@ -79,7 +100,7 @@ Montage_alloc(VALUE class)
|
|
79
100
|
montage = ALLOC(Montage);
|
80
101
|
montage->info = montage_info;
|
81
102
|
montage->compose = OverCompositeOp;
|
82
|
-
montage_obj =
|
103
|
+
montage_obj = TypedData_Wrap_Struct(class, &rm_montage_data_type, montage);
|
83
104
|
|
84
105
|
RB_GC_GUARD(montage_obj);
|
85
106
|
|
@@ -98,7 +119,7 @@ Montage_background_color_eq(VALUE self, VALUE color)
|
|
98
119
|
{
|
99
120
|
Montage *montage;
|
100
121
|
|
101
|
-
|
122
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
102
123
|
Color_to_PixelColor(&montage->info->background_color, color);
|
103
124
|
return color;
|
104
125
|
}
|
@@ -115,7 +136,7 @@ Montage_border_color_eq(VALUE self, VALUE color)
|
|
115
136
|
{
|
116
137
|
Montage *montage;
|
117
138
|
|
118
|
-
|
139
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
119
140
|
Color_to_PixelColor(&montage->info->border_color, color);
|
120
141
|
return color;
|
121
142
|
}
|
@@ -132,7 +153,7 @@ Montage_border_width_eq(VALUE self, VALUE width)
|
|
132
153
|
{
|
133
154
|
Montage *montage;
|
134
155
|
|
135
|
-
|
156
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
136
157
|
montage->info->border_width = NUM2ULONG(width);
|
137
158
|
return width;
|
138
159
|
}
|
@@ -149,7 +170,7 @@ Montage_compose_eq(VALUE self, VALUE compose)
|
|
149
170
|
{
|
150
171
|
Montage *montage;
|
151
172
|
|
152
|
-
|
173
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
153
174
|
VALUE_TO_ENUM(compose, montage->compose, CompositeOperator);
|
154
175
|
return compose;
|
155
176
|
}
|
@@ -166,7 +187,7 @@ Montage_filename_eq(VALUE self, VALUE filename)
|
|
166
187
|
{
|
167
188
|
Montage *montage;
|
168
189
|
|
169
|
-
|
190
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
170
191
|
strlcpy(montage->info->filename, StringValueCStr(filename), sizeof(montage->info->filename));
|
171
192
|
return filename;
|
172
193
|
}
|
@@ -183,7 +204,7 @@ Montage_fill_eq(VALUE self, VALUE color)
|
|
183
204
|
{
|
184
205
|
Montage *montage;
|
185
206
|
|
186
|
-
|
207
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
187
208
|
Color_to_PixelColor(&montage->info->fill, color);
|
188
209
|
return color;
|
189
210
|
}
|
@@ -200,7 +221,7 @@ Montage_font_eq(VALUE self, VALUE font)
|
|
200
221
|
{
|
201
222
|
Montage *montage;
|
202
223
|
|
203
|
-
|
224
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
204
225
|
magick_clone_string(&montage->info->font, StringValueCStr(font));
|
205
226
|
|
206
227
|
return font;
|
@@ -223,7 +244,7 @@ Montage_frame_eq(VALUE self, VALUE frame_arg)
|
|
223
244
|
Montage *montage;
|
224
245
|
VALUE frame;
|
225
246
|
|
226
|
-
|
247
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
227
248
|
frame = rb_String(frame_arg);
|
228
249
|
magick_clone_string(&montage->info->frame, StringValueCStr(frame));
|
229
250
|
|
@@ -250,7 +271,7 @@ Montage_geometry_eq(VALUE self, VALUE geometry_arg)
|
|
250
271
|
Montage *montage;
|
251
272
|
VALUE geometry;
|
252
273
|
|
253
|
-
|
274
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
254
275
|
geometry = rb_String(geometry_arg);
|
255
276
|
magick_clone_string(&montage->info->geometry, StringValueCStr(geometry));
|
256
277
|
|
@@ -271,7 +292,7 @@ Montage_gravity_eq(VALUE self, VALUE gravity)
|
|
271
292
|
{
|
272
293
|
Montage *montage;
|
273
294
|
|
274
|
-
|
295
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
275
296
|
VALUE_TO_ENUM(gravity, montage->info->gravity, GravityType);
|
276
297
|
return gravity;
|
277
298
|
}
|
@@ -301,7 +322,7 @@ Montage_matte_color_eq(VALUE self, VALUE color)
|
|
301
322
|
{
|
302
323
|
Montage *montage;
|
303
324
|
|
304
|
-
|
325
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
305
326
|
Color_to_PixelColor(&montage->info->matte_color, color);
|
306
327
|
return color;
|
307
328
|
}
|
@@ -318,7 +339,7 @@ Montage_pointsize_eq(VALUE self, VALUE size)
|
|
318
339
|
{
|
319
340
|
Montage *montage;
|
320
341
|
|
321
|
-
|
342
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
322
343
|
montage->info->pointsize = NUM2DBL(size);
|
323
344
|
return size;
|
324
345
|
}
|
@@ -335,7 +356,7 @@ Montage_shadow_eq(VALUE self, VALUE shadow)
|
|
335
356
|
{
|
336
357
|
Montage *montage;
|
337
358
|
|
338
|
-
|
359
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
339
360
|
montage->info->shadow = (MagickBooleanType) RTEST(shadow);
|
340
361
|
return shadow;
|
341
362
|
}
|
@@ -352,7 +373,7 @@ Montage_stroke_eq(VALUE self, VALUE color)
|
|
352
373
|
{
|
353
374
|
Montage *montage;
|
354
375
|
|
355
|
-
|
376
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
356
377
|
Color_to_PixelColor(&montage->info->stroke, color);
|
357
378
|
return color;
|
358
379
|
}
|
@@ -372,7 +393,7 @@ Montage_texture_eq(VALUE self, VALUE texture)
|
|
372
393
|
Image *texture_image;
|
373
394
|
char temp_name[MaxTextExtent];
|
374
395
|
|
375
|
-
|
396
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
376
397
|
|
377
398
|
// If we had a previously defined temp texture image,
|
378
399
|
// remove it now in preparation for this new one.
|
@@ -411,7 +432,7 @@ Montage_tile_eq(VALUE self, VALUE tile_arg)
|
|
411
432
|
Montage *montage;
|
412
433
|
VALUE tile;
|
413
434
|
|
414
|
-
|
435
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
415
436
|
tile = rb_String(tile_arg);
|
416
437
|
magick_clone_string(&montage->info->tile, StringValueCStr(tile));
|
417
438
|
|
@@ -432,7 +453,7 @@ Montage_title_eq(VALUE self, VALUE title)
|
|
432
453
|
{
|
433
454
|
Montage *montage;
|
434
455
|
|
435
|
-
|
456
|
+
TypedData_Get_Struct(self, Montage, &rm_montage_data_type, montage);
|
436
457
|
magick_clone_string(&montage->info->title, StringValueCStr(title));
|
437
458
|
return title;
|
438
459
|
}
|
data/ext/RMagick/rmpixel.c
CHANGED
@@ -19,6 +19,15 @@
|
|
19
19
|
|
20
20
|
static VALUE color_arg_rescue(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
|
21
21
|
static void Color_Name_to_PixelColor(PixelColor *, VALUE);
|
22
|
+
static void Pixel_destroy(void *);
|
23
|
+
static size_t Pixel_memsize(const void *);
|
24
|
+
|
25
|
+
const rb_data_type_t rm_pixel_data_type = {
|
26
|
+
"Magick::Pixel",
|
27
|
+
{ NULL, Pixel_destroy, Pixel_memsize, },
|
28
|
+
0, 0,
|
29
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
30
|
+
};
|
22
31
|
|
23
32
|
|
24
33
|
/**
|
@@ -26,15 +35,30 @@ static void Color_Name_to_PixelColor(PixelColor *, VALUE);
|
|
26
35
|
*
|
27
36
|
* No Ruby usage (internal function)
|
28
37
|
*
|
29
|
-
* @param
|
38
|
+
* @param ptr the Pixel object to destroy
|
30
39
|
*/
|
31
|
-
void
|
32
|
-
|
40
|
+
static void
|
41
|
+
Pixel_destroy(void *ptr)
|
33
42
|
{
|
43
|
+
Pixel *pixel = (Pixel *)ptr;
|
34
44
|
xfree(pixel);
|
35
45
|
}
|
36
46
|
|
37
47
|
|
48
|
+
/**
|
49
|
+
* Get Pixel object size.
|
50
|
+
*
|
51
|
+
* No Ruby usage (internal function)
|
52
|
+
*
|
53
|
+
* @param ptr pointer to the Pixel object
|
54
|
+
*/
|
55
|
+
static size_t
|
56
|
+
Pixel_memsize(const void *ptr)
|
57
|
+
{
|
58
|
+
return sizeof(Pixel);
|
59
|
+
}
|
60
|
+
|
61
|
+
|
38
62
|
/**
|
39
63
|
* Get Pixel red value.
|
40
64
|
*
|
@@ -43,7 +67,7 @@ destroy_Pixel(Pixel *pixel)
|
|
43
67
|
VALUE
|
44
68
|
Pixel_red(VALUE self)
|
45
69
|
{
|
46
|
-
|
70
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, red, int, &rm_pixel_data_type);
|
47
71
|
}
|
48
72
|
|
49
73
|
/**
|
@@ -54,7 +78,7 @@ Pixel_red(VALUE self)
|
|
54
78
|
VALUE
|
55
79
|
Pixel_green(VALUE self)
|
56
80
|
{
|
57
|
-
|
81
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, green, int, &rm_pixel_data_type);
|
58
82
|
}
|
59
83
|
|
60
84
|
/**
|
@@ -65,7 +89,7 @@ Pixel_green(VALUE self)
|
|
65
89
|
VALUE
|
66
90
|
Pixel_blue(VALUE self)
|
67
91
|
{
|
68
|
-
|
92
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, blue, int, &rm_pixel_data_type);
|
69
93
|
}
|
70
94
|
|
71
95
|
/**
|
@@ -77,7 +101,7 @@ VALUE
|
|
77
101
|
Pixel_alpha(VALUE self)
|
78
102
|
{
|
79
103
|
Pixel *pixel;
|
80
|
-
|
104
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
81
105
|
#if defined(IMAGEMAGICK_7)
|
82
106
|
return C_int_to_R_int(pixel->alpha);
|
83
107
|
#else
|
@@ -102,7 +126,7 @@ Pixel_red_eq(VALUE self, VALUE v)
|
|
102
126
|
Pixel *pixel;
|
103
127
|
|
104
128
|
rb_check_frozen(self);
|
105
|
-
|
129
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
106
130
|
pixel->red = APP2QUANTUM(v);
|
107
131
|
rb_funcall(self, rm_ID_changed, 0);
|
108
132
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -126,7 +150,7 @@ Pixel_green_eq(VALUE self, VALUE v)
|
|
126
150
|
Pixel *pixel;
|
127
151
|
|
128
152
|
rb_check_frozen(self);
|
129
|
-
|
153
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
130
154
|
pixel->green = APP2QUANTUM(v);
|
131
155
|
rb_funcall(self, rm_ID_changed, 0);
|
132
156
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -150,7 +174,7 @@ Pixel_blue_eq(VALUE self, VALUE v)
|
|
150
174
|
Pixel *pixel;
|
151
175
|
|
152
176
|
rb_check_frozen(self);
|
153
|
-
|
177
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
154
178
|
pixel->blue = APP2QUANTUM(v);
|
155
179
|
rb_funcall(self, rm_ID_changed, 0);
|
156
180
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -174,7 +198,7 @@ Pixel_alpha_eq(VALUE self, VALUE v)
|
|
174
198
|
Pixel *pixel;
|
175
199
|
|
176
200
|
rb_check_frozen(self);
|
177
|
-
|
201
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
178
202
|
#if defined(IMAGEMAGICK_7)
|
179
203
|
pixel->alpha = APP2QUANTUM(v);
|
180
204
|
rb_funcall(self, rm_ID_changed, 0);
|
@@ -198,7 +222,7 @@ Pixel_cyan(VALUE self)
|
|
198
222
|
{
|
199
223
|
Pixel *pixel;
|
200
224
|
|
201
|
-
|
225
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
202
226
|
return INT2NUM(pixel->red);
|
203
227
|
}
|
204
228
|
|
@@ -219,7 +243,7 @@ Pixel_cyan_eq(VALUE self, VALUE v)
|
|
219
243
|
Pixel *pixel;
|
220
244
|
|
221
245
|
rb_check_frozen(self);
|
222
|
-
|
246
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
223
247
|
pixel->red = APP2QUANTUM(v);
|
224
248
|
rb_funcall(self, rm_ID_changed, 0);
|
225
249
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -236,7 +260,7 @@ Pixel_magenta(VALUE self)
|
|
236
260
|
{
|
237
261
|
Pixel *pixel;
|
238
262
|
|
239
|
-
|
263
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
240
264
|
return INT2NUM(pixel->green);
|
241
265
|
}
|
242
266
|
|
@@ -257,7 +281,7 @@ Pixel_magenta_eq(VALUE self, VALUE v)
|
|
257
281
|
Pixel *pixel;
|
258
282
|
|
259
283
|
rb_check_frozen(self);
|
260
|
-
|
284
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
261
285
|
pixel->green = APP2QUANTUM(v);
|
262
286
|
rb_funcall(self, rm_ID_changed, 0);
|
263
287
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -274,7 +298,7 @@ Pixel_yellow(VALUE self)
|
|
274
298
|
{
|
275
299
|
Pixel *pixel;
|
276
300
|
|
277
|
-
|
301
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
278
302
|
return INT2NUM(pixel->blue);
|
279
303
|
}
|
280
304
|
|
@@ -295,7 +319,7 @@ Pixel_yellow_eq(VALUE self, VALUE v)
|
|
295
319
|
Pixel *pixel;
|
296
320
|
|
297
321
|
rb_check_frozen(self);
|
298
|
-
|
322
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
299
323
|
pixel->blue = APP2QUANTUM(v);
|
300
324
|
rb_funcall(self, rm_ID_changed, 0);
|
301
325
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -312,7 +336,7 @@ Pixel_black(VALUE self)
|
|
312
336
|
{
|
313
337
|
Pixel *pixel;
|
314
338
|
|
315
|
-
|
339
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
316
340
|
return INT2NUM(pixel->black);
|
317
341
|
}
|
318
342
|
|
@@ -333,7 +357,7 @@ Pixel_black_eq(VALUE self, VALUE v)
|
|
333
357
|
Pixel *pixel;
|
334
358
|
|
335
359
|
rb_check_frozen(self);
|
336
|
-
|
360
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
337
361
|
pixel->black = APP2QUANTUM(v);
|
338
362
|
rb_funcall(self, rm_ID_changed, 0);
|
339
363
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -376,7 +400,7 @@ Color_to_PixelColor(PixelColor *pp, VALUE color)
|
|
376
400
|
if (CLASS_OF(color) == Class_Pixel)
|
377
401
|
{
|
378
402
|
memset(pp, 0, sizeof(*pp));
|
379
|
-
|
403
|
+
TypedData_Get_Struct(color, Pixel, &rm_pixel_data_type, pixel);
|
380
404
|
pp->red = pixel->red;
|
381
405
|
pp->green = pixel->green;
|
382
406
|
pp->blue = pixel->blue;
|
@@ -415,7 +439,7 @@ Color_to_Pixel(Pixel *pp, VALUE color)
|
|
415
439
|
{
|
416
440
|
Pixel *pixel;
|
417
441
|
|
418
|
-
|
442
|
+
TypedData_Get_Struct(color, Pixel, &rm_pixel_data_type, pixel);
|
419
443
|
memcpy(pp, pixel, sizeof(Pixel));
|
420
444
|
}
|
421
445
|
else
|
@@ -474,7 +498,7 @@ Pixel_alloc(VALUE class)
|
|
474
498
|
|
475
499
|
pixel = ALLOC(Pixel);
|
476
500
|
memset(pixel, '\0', sizeof(Pixel));
|
477
|
-
return
|
501
|
+
return TypedData_Wrap_Struct(class, &rm_pixel_data_type, pixel);
|
478
502
|
}
|
479
503
|
|
480
504
|
|
@@ -492,8 +516,8 @@ Pixel_case_eq(VALUE self, VALUE other)
|
|
492
516
|
{
|
493
517
|
Pixel *this, *that;
|
494
518
|
|
495
|
-
|
496
|
-
|
519
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, this);
|
520
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, that);
|
497
521
|
return (this->red == that->red
|
498
522
|
&& this->blue == that->blue
|
499
523
|
&& this->green == that->green
|
@@ -547,7 +571,7 @@ Pixel_dup(VALUE self)
|
|
547
571
|
|
548
572
|
pixel = ALLOC(Pixel);
|
549
573
|
memset(pixel, '\0', sizeof(Pixel));
|
550
|
-
dup =
|
574
|
+
dup = TypedData_Wrap_Struct(CLASS_OF(self), &rm_pixel_data_type, pixel);
|
551
575
|
RB_GC_GUARD(dup);
|
552
576
|
|
553
577
|
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
@@ -785,7 +809,7 @@ Pixel_from_MagickPixel(const MagickPixel *pp)
|
|
785
809
|
#endif
|
786
810
|
pixel->black = pp->index;
|
787
811
|
|
788
|
-
return
|
812
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
789
813
|
}
|
790
814
|
|
791
815
|
|
@@ -817,7 +841,7 @@ Pixel_from_PixelPacket(const PixelPacket *pp)
|
|
817
841
|
pixel->black = 0;
|
818
842
|
#endif
|
819
843
|
|
820
|
-
return
|
844
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
821
845
|
}
|
822
846
|
|
823
847
|
|
@@ -849,7 +873,7 @@ Pixel_from_PixelColor(const PixelColor *pp)
|
|
849
873
|
pixel->black = 0;
|
850
874
|
#endif
|
851
875
|
|
852
|
-
return
|
876
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
853
877
|
}
|
854
878
|
|
855
879
|
|
@@ -864,7 +888,7 @@ Pixel_hash(VALUE self)
|
|
864
888
|
Pixel *pixel;
|
865
889
|
unsigned int hash;
|
866
890
|
|
867
|
-
|
891
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
868
892
|
|
869
893
|
hash = ScaleQuantumToChar(pixel->red) << 24;
|
870
894
|
hash += ScaleQuantumToChar(pixel->green) << 16;
|
@@ -892,8 +916,8 @@ Pixel_init_copy(VALUE self, VALUE orig)
|
|
892
916
|
{
|
893
917
|
Pixel *copy, *original;
|
894
918
|
|
895
|
-
|
896
|
-
|
919
|
+
TypedData_Get_Struct(orig, Pixel, &rm_pixel_data_type, original);
|
920
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, copy);
|
897
921
|
|
898
922
|
*copy = *original;
|
899
923
|
|
@@ -916,7 +940,7 @@ Pixel_initialize(int argc, VALUE *argv, VALUE self)
|
|
916
940
|
{
|
917
941
|
Pixel *pixel;
|
918
942
|
|
919
|
-
|
943
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
920
944
|
|
921
945
|
#if defined(IMAGEMAGICK_7)
|
922
946
|
pixel->alpha = OpaqueAlpha;
|
@@ -972,7 +996,7 @@ Pixel_intensity(VALUE self)
|
|
972
996
|
Pixel *pixel;
|
973
997
|
Quantum intensity;
|
974
998
|
|
975
|
-
|
999
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
976
1000
|
|
977
1001
|
intensity = ROUND_TO_QUANTUM((0.299*pixel->red)
|
978
1002
|
+ (0.587*pixel->green)
|
@@ -993,7 +1017,7 @@ Pixel_marshal_dump(VALUE self)
|
|
993
1017
|
Pixel *pixel;
|
994
1018
|
VALUE dpixel;
|
995
1019
|
|
996
|
-
|
1020
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
997
1021
|
dpixel = rb_hash_new();
|
998
1022
|
rb_hash_aset(dpixel, CSTR2SYM("red"), QUANTUM2NUM(pixel->red));
|
999
1023
|
rb_hash_aset(dpixel, CSTR2SYM("green"), QUANTUM2NUM(pixel->green));
|
@@ -1021,7 +1045,7 @@ Pixel_marshal_load(VALUE self, VALUE dpixel)
|
|
1021
1045
|
{
|
1022
1046
|
Pixel *pixel;
|
1023
1047
|
|
1024
|
-
|
1048
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1025
1049
|
pixel->red = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("red")));
|
1026
1050
|
pixel->green = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("green")));
|
1027
1051
|
pixel->blue = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("blue")));
|
@@ -1045,8 +1069,8 @@ Pixel_spaceship(VALUE self, VALUE other)
|
|
1045
1069
|
{
|
1046
1070
|
Pixel *this, *that;
|
1047
1071
|
|
1048
|
-
|
1049
|
-
|
1072
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, this);
|
1073
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, that);
|
1050
1074
|
|
1051
1075
|
if (this->red != that->red)
|
1052
1076
|
{
|
@@ -1093,7 +1117,7 @@ Pixel_to_hsla(VALUE self)
|
|
1093
1117
|
Pixel *pixel;
|
1094
1118
|
VALUE hsla;
|
1095
1119
|
|
1096
|
-
|
1120
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1097
1121
|
|
1098
1122
|
ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
|
1099
1123
|
hue *= 360.0;
|
@@ -1218,7 +1242,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1218
1242
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
1219
1243
|
}
|
1220
1244
|
|
1221
|
-
|
1245
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1222
1246
|
|
1223
1247
|
info = CloneImageInfo(NULL);
|
1224
1248
|
image = rm_acquire_image(info);
|
@@ -1284,7 +1308,7 @@ Pixel_to_s(VALUE self)
|
|
1284
1308
|
Pixel *pixel;
|
1285
1309
|
char buff[100];
|
1286
1310
|
|
1287
|
-
|
1311
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1288
1312
|
snprintf(buff, sizeof(buff), "red=" QuantumFormat ", green=" QuantumFormat ", blue=" QuantumFormat ", alpha=" QuantumFormat,
|
1289
1313
|
pixel->red, pixel->green, pixel->blue,
|
1290
1314
|
#if defined(IMAGEMAGICK_7)
|