rmagick 4.0.0 → 4.1.0.rc1
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/.appveyor.yml +16 -4
- data/.circleci/config.yml +1 -1
- data/.travis.yml +4 -2
- data/CHANGELOG.md +9 -0
- data/README.textile +1 -1
- data/before_install_linux.sh +5 -1
- data/ext/RMagick/extconf.rb +37 -13
- data/ext/RMagick/rmagick.h +39 -16
- data/ext/RMagick/rmdraw.c +87 -2
- data/ext/RMagick/rmenum.c +12 -3
- data/ext/RMagick/rmfill.c +109 -2
- data/ext/RMagick/rmilist.c +92 -8
- data/ext/RMagick/rmimage.c +1538 -53
- data/ext/RMagick/rminfo.c +30 -0
- data/ext/RMagick/rmkinfo.c +32 -0
- data/ext/RMagick/rmmain.c +33 -11
- data/ext/RMagick/rmpixel.c +125 -10
- data/ext/RMagick/rmstruct.c +14 -1
- data/ext/RMagick/rmutil.c +151 -5
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +3 -1
- data/rmagick.gemspec +0 -1
- data/spec/rmagick/image/dissolve_spec.rb +54 -0
- data/spec/spec_helper.rb +1 -2
- metadata +7 -5
data/ext/RMagick/rminfo.c
CHANGED
@@ -443,7 +443,11 @@ Info_authenticate(VALUE self)
|
|
443
443
|
Info *info;
|
444
444
|
|
445
445
|
Data_Get_Struct(self, Info, info);
|
446
|
+
#if defined(IMAGEMAGICK_7)
|
447
|
+
return C_str_to_R_str(GetImageOption(info, "authenticate"));
|
448
|
+
#else
|
446
449
|
return C_str_to_R_str(info->authenticate);
|
450
|
+
#endif
|
447
451
|
}
|
448
452
|
|
449
453
|
|
@@ -470,6 +474,16 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
|
|
470
474
|
passwd = StringValuePtr(passwd_arg);
|
471
475
|
}
|
472
476
|
|
477
|
+
#if defined(IMAGEMAGICK_7)
|
478
|
+
if (passwd)
|
479
|
+
{
|
480
|
+
SetImageOption(info, "authenticate", passwd);
|
481
|
+
}
|
482
|
+
else
|
483
|
+
{
|
484
|
+
RemoveImageOption(info, "authenticate");
|
485
|
+
}
|
486
|
+
#else
|
473
487
|
if (info->authenticate)
|
474
488
|
{
|
475
489
|
magick_free(info->authenticate);
|
@@ -479,6 +493,7 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
|
|
479
493
|
{
|
480
494
|
magick_clone_string(&info->authenticate, passwd);
|
481
495
|
}
|
496
|
+
#endif
|
482
497
|
|
483
498
|
return passwd_arg;
|
484
499
|
}
|
@@ -2463,7 +2478,11 @@ Info_view(VALUE self)
|
|
2463
2478
|
Info *info;
|
2464
2479
|
|
2465
2480
|
Data_Get_Struct(self, Info, info);
|
2481
|
+
#if defined(IMAGEMAGICK_7)
|
2482
|
+
return C_str_to_R_str(GetImageOption(info, "fpx:view"));
|
2483
|
+
#else
|
2466
2484
|
return C_str_to_R_str(info->view);
|
2485
|
+
#endif
|
2467
2486
|
}
|
2468
2487
|
|
2469
2488
|
/**
|
@@ -2489,6 +2508,16 @@ Info_view_eq(VALUE self, VALUE view_arg)
|
|
2489
2508
|
view = StringValuePtr(view_arg);
|
2490
2509
|
}
|
2491
2510
|
|
2511
|
+
#if defined(IMAGEMAGICK_7)
|
2512
|
+
if (view)
|
2513
|
+
{
|
2514
|
+
SetImageOption(info, "fpx:view", view);
|
2515
|
+
}
|
2516
|
+
else
|
2517
|
+
{
|
2518
|
+
RemoveImageOption(info, "fpx:view");
|
2519
|
+
}
|
2520
|
+
#else
|
2492
2521
|
if (info->view)
|
2493
2522
|
{
|
2494
2523
|
magick_free(info->view);
|
@@ -2498,6 +2527,7 @@ Info_view_eq(VALUE self, VALUE view_arg)
|
|
2498
2527
|
{
|
2499
2528
|
magick_clone_string(&info->view, view);
|
2500
2529
|
}
|
2530
|
+
#endif
|
2501
2531
|
return view_arg;
|
2502
2532
|
}
|
2503
2533
|
|
data/ext/RMagick/rmkinfo.c
CHANGED
@@ -53,10 +53,26 @@ VALUE
|
|
53
53
|
KernelInfo_initialize(VALUE self, VALUE kernel_string)
|
54
54
|
{
|
55
55
|
KernelInfo *kernel;
|
56
|
+
#if defined(IMAGEMAGICK_7)
|
57
|
+
ExceptionInfo *exception;
|
58
|
+
#endif
|
56
59
|
|
57
60
|
Check_Type(kernel_string, T_STRING);
|
58
61
|
|
62
|
+
#if defined(IMAGEMAGICK_7)
|
63
|
+
exception = AcquireExceptionInfo();
|
64
|
+
kernel = AcquireKernelInfo(StringValueCStr(kernel_string), exception);
|
65
|
+
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
|
66
|
+
{
|
67
|
+
if (kernel != (KernelInfo *) NULL)
|
68
|
+
{
|
69
|
+
(void) DestroyKernelInfo(kernel);
|
70
|
+
}
|
71
|
+
rm_raise_exception(exception);
|
72
|
+
}
|
73
|
+
#else
|
59
74
|
kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
|
75
|
+
#endif
|
60
76
|
|
61
77
|
if (!kernel)
|
62
78
|
{
|
@@ -216,12 +232,28 @@ KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
|
|
216
232
|
KernelInfo *kernel;
|
217
233
|
KernelInfoType kernel_type;
|
218
234
|
GeometryInfo info;
|
235
|
+
#if defined(IMAGEMAGICK_7)
|
236
|
+
ExceptionInfo *exception;
|
237
|
+
#endif
|
219
238
|
|
220
239
|
Check_Type(geometry, T_STRING);
|
221
240
|
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
|
222
241
|
ParseGeometry(StringValueCStr(geometry), &info);
|
223
242
|
|
243
|
+
#if defined(IMAGEMAGICK_7)
|
244
|
+
exception = AcquireExceptionInfo();
|
245
|
+
kernel = AcquireKernelBuiltIn(kernel_type, &info, exception);
|
246
|
+
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
|
247
|
+
{
|
248
|
+
if (kernel != (KernelInfo *) NULL)
|
249
|
+
{
|
250
|
+
(void) DestroyKernelInfo(kernel);
|
251
|
+
}
|
252
|
+
rm_raise_exception(exception);
|
253
|
+
}
|
254
|
+
#else
|
224
255
|
kernel = AcquireKernelBuiltIn(kernel_type, &info);
|
256
|
+
#endif
|
225
257
|
|
226
258
|
if (!kernel)
|
227
259
|
{
|
data/ext/RMagick/rmmain.c
CHANGED
@@ -996,7 +996,6 @@ Init_RMagick2(void)
|
|
996
996
|
ENUMERATOR(CopyCyanCompositeOp)
|
997
997
|
ENUMERATOR(CopyGreenCompositeOp)
|
998
998
|
ENUMERATOR(CopyMagentaCompositeOp)
|
999
|
-
ENUMERATORV(CopyAlphaCompositeOp, CopyOpacityCompositeOp)
|
1000
999
|
ENUMERATOR(CopyRedCompositeOp)
|
1001
1000
|
ENUMERATOR(CopyYellowCompositeOp)
|
1002
1001
|
ENUMERATOR(DarkenCompositeOp)
|
@@ -1014,9 +1013,6 @@ Init_RMagick2(void)
|
|
1014
1013
|
ENUMERATOR(DissolveCompositeOp)
|
1015
1014
|
ENUMERATOR(ExclusionCompositeOp)
|
1016
1015
|
ENUMERATOR(HardLightCompositeOp)
|
1017
|
-
#if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
|
1018
|
-
ENUMERATOR(HardMixCompositeOp)
|
1019
|
-
#endif
|
1020
1016
|
ENUMERATOR(HueCompositeOp)
|
1021
1017
|
ENUMERATOR(InCompositeOp)
|
1022
1018
|
ENUMERATOR(LightenCompositeOp)
|
@@ -1052,6 +1048,14 @@ Init_RMagick2(void)
|
|
1052
1048
|
ENUMERATOR(UndefinedCompositeOp)
|
1053
1049
|
ENUMERATOR(VividLightCompositeOp)
|
1054
1050
|
ENUMERATOR(XorCompositeOp)
|
1051
|
+
#if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
|
1052
|
+
ENUMERATOR(HardMixCompositeOp)
|
1053
|
+
#endif
|
1054
|
+
#if defined(IMAGEMAGICK_7)
|
1055
|
+
ENUMERATOR(CopyAlphaCompositeOp)
|
1056
|
+
#else
|
1057
|
+
ENUMERATORV(CopyAlphaCompositeOp, CopyOpacityCompositeOp)
|
1058
|
+
#endif
|
1055
1059
|
END_ENUM
|
1056
1060
|
|
1057
1061
|
// CompressionType constants
|
@@ -1191,15 +1195,23 @@ Init_RMagick2(void)
|
|
1191
1195
|
ENUMERATOR(UndefinedType)
|
1192
1196
|
ENUMERATOR(BilevelType)
|
1193
1197
|
ENUMERATOR(GrayscaleType)
|
1194
|
-
ENUMERATORV(GrayscaleAlphaType, GrayscaleMatteType)
|
1195
1198
|
ENUMERATOR(PaletteType)
|
1196
|
-
ENUMERATORV(PaletteAlphaType, PaletteMatteType)
|
1197
1199
|
ENUMERATOR(TrueColorType)
|
1198
|
-
ENUMERATORV(TrueColorAlphaType, TrueColorMatteType)
|
1199
1200
|
ENUMERATOR(ColorSeparationType)
|
1200
|
-
ENUMERATORV(ColorSeparationAlphaType, ColorSeparationMatteType)
|
1201
1201
|
ENUMERATOR(OptimizeType)
|
1202
|
+
#if defined(IMAGEMAGICK_7)
|
1203
|
+
ENUMERATOR(GrayscaleAlphaType)
|
1204
|
+
ENUMERATOR(PaletteAlphaType)
|
1205
|
+
ENUMERATOR(TrueColorAlphaType)
|
1206
|
+
ENUMERATOR(ColorSeparationAlphaType)
|
1207
|
+
ENUMERATOR(PaletteBilevelAlphaType)
|
1208
|
+
#else
|
1209
|
+
ENUMERATORV(GrayscaleAlphaType, GrayscaleMatteType)
|
1210
|
+
ENUMERATORV(PaletteAlphaType, PaletteMatteType)
|
1211
|
+
ENUMERATORV(TrueColorAlphaType, TrueColorMatteType)
|
1212
|
+
ENUMERATORV(ColorSeparationAlphaType, ColorSeparationMatteType)
|
1202
1213
|
ENUMERATORV(PaletteBilevelAlphaType, PaletteBilevelMatteType)
|
1214
|
+
#endif
|
1203
1215
|
END_ENUM
|
1204
1216
|
|
1205
1217
|
// InterlaceType constants
|
@@ -1243,18 +1255,24 @@ Init_RMagick2(void)
|
|
1243
1255
|
END_ENUM
|
1244
1256
|
|
1245
1257
|
DEF_ENUM(MetricType)
|
1246
|
-
ENUMERATORV(UndefinedErrorMetric, UndefinedMetric)
|
1247
1258
|
ENUMERATOR(AbsoluteErrorMetric)
|
1248
1259
|
ENUMERATOR(MeanAbsoluteErrorMetric)
|
1249
|
-
ENUMERATORV(MeanErrorPerPixelErrorMetric, MeanErrorPerPixelMetric)
|
1250
1260
|
ENUMERATOR(MeanSquaredErrorMetric)
|
1251
1261
|
ENUMERATOR(PeakAbsoluteErrorMetric)
|
1252
|
-
ENUMERATORV(PeakSignalToNoiseRatioErrorMetric, PeakSignalToNoiseRatioMetric)
|
1253
1262
|
ENUMERATOR(RootMeanSquaredErrorMetric)
|
1254
1263
|
ENUMERATOR(NormalizedCrossCorrelationErrorMetric)
|
1255
1264
|
ENUMERATOR(FuzzErrorMetric)
|
1256
1265
|
#if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
|
1257
1266
|
ENUMERATOR(PerceptualHashErrorMetric)
|
1267
|
+
#endif
|
1268
|
+
#if defined(IMAGEMAGICK_7)
|
1269
|
+
ENUMERATOR(UndefinedErrorMetric)
|
1270
|
+
ENUMERATOR(MeanErrorPerPixelErrorMetric)
|
1271
|
+
ENUMERATOR(PeakSignalToNoiseRatioErrorMetric)
|
1272
|
+
#else
|
1273
|
+
ENUMERATORV(UndefinedErrorMetric, UndefinedMetric)
|
1274
|
+
ENUMERATORV(MeanErrorPerPixelErrorMetric, MeanErrorPerPixelMetric)
|
1275
|
+
ENUMERATORV(PeakSignalToNoiseRatioErrorMetric, PeakSignalToNoiseRatioMetric)
|
1258
1276
|
#endif
|
1259
1277
|
END_ENUM
|
1260
1278
|
|
@@ -1298,7 +1316,11 @@ Init_RMagick2(void)
|
|
1298
1316
|
ENUMERATOR(BilinearInterpolatePixel)
|
1299
1317
|
ENUMERATOR(IntegerInterpolatePixel)
|
1300
1318
|
ENUMERATOR(MeshInterpolatePixel)
|
1319
|
+
#if defined(IMAGEMAGICK_7)
|
1320
|
+
ENUMERATOR(NearestInterpolatePixel)
|
1321
|
+
#else
|
1301
1322
|
ENUMERATORV(NearestInterpolatePixel, NearestNeighborInterpolatePixel)
|
1323
|
+
#endif
|
1302
1324
|
ENUMERATOR(SplineInterpolatePixel)
|
1303
1325
|
ENUMERATOR(Average9InterpolatePixel)
|
1304
1326
|
ENUMERATOR(Average16InterpolatePixel)
|
data/ext/RMagick/rmpixel.c
CHANGED
@@ -12,6 +12,9 @@
|
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
|
15
|
+
#if defined(IMAGEMAGICK_6)
|
16
|
+
#define QueryColorname QueryMagickColorname
|
17
|
+
#endif
|
15
18
|
|
16
19
|
/*
|
17
20
|
* Declare Pixel channel attribute writers
|
@@ -124,7 +127,11 @@ Pixel_alpha(VALUE self)
|
|
124
127
|
{
|
125
128
|
Pixel *pixel;
|
126
129
|
Data_Get_Struct(self, Pixel, pixel);
|
130
|
+
#if defined(IMAGEMAGICK_7)
|
131
|
+
return C_int_to_R_int(pixel->alpha);
|
132
|
+
#else
|
127
133
|
return C_int_to_R_int(QuantumRange - pixel->opacity);
|
134
|
+
#endif
|
128
135
|
}
|
129
136
|
|
130
137
|
/**
|
@@ -200,10 +207,17 @@ Pixel_alpha_eq(VALUE self, VALUE v)
|
|
200
207
|
|
201
208
|
rb_check_frozen(self);
|
202
209
|
Data_Get_Struct(self, Pixel, pixel);
|
210
|
+
#if defined(IMAGEMAGICK_7)
|
211
|
+
pixel->alpha = APP2QUANTUM(v);
|
212
|
+
(void) rb_funcall(self, rm_ID_changed, 0);
|
213
|
+
(void) rb_funcall(self, rm_ID_notify_observers, 1, self);
|
214
|
+
return QUANTUM2NUM(pixel->alpha);
|
215
|
+
#else
|
203
216
|
pixel->opacity = QuantumRange - APP2QUANTUM(v);
|
204
217
|
(void) rb_funcall(self, rm_ID_changed, 0);
|
205
218
|
(void) rb_funcall(self, rm_ID_notify_observers, 1, self);
|
206
219
|
return QUANTUM2NUM(QuantumRange - pixel->opacity);
|
220
|
+
#endif
|
207
221
|
}
|
208
222
|
|
209
223
|
/*
|
@@ -212,7 +226,11 @@ Pixel_alpha_eq(VALUE self, VALUE v)
|
|
212
226
|
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(cyan, red)
|
213
227
|
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(magenta, green)
|
214
228
|
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(yellow, blue)
|
229
|
+
#if defined(IMAGEMAGICK_7)
|
230
|
+
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(black, black)
|
231
|
+
#else
|
215
232
|
DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(black, opacity)
|
233
|
+
#endif
|
216
234
|
|
217
235
|
|
218
236
|
/**
|
@@ -255,7 +273,11 @@ Color_to_PixelColor(PixelColor *pp, VALUE color)
|
|
255
273
|
pp->red = pixel->red;
|
256
274
|
pp->green = pixel->green;
|
257
275
|
pp->blue = pixel->blue;
|
276
|
+
#if defined(IMAGEMAGICK_7)
|
277
|
+
pp->alpha = pixel->alpha;
|
278
|
+
#else
|
258
279
|
pp->opacity = pixel->opacity;
|
280
|
+
#endif
|
259
281
|
}
|
260
282
|
else
|
261
283
|
{
|
@@ -336,7 +358,11 @@ Pixel_case_eq(VALUE self, VALUE other)
|
|
336
358
|
return (this->red == that->red
|
337
359
|
&& this->blue == that->blue
|
338
360
|
&& this->green == that->green
|
361
|
+
#if defined(IMAGEMAGICK_7)
|
362
|
+
&& this->alpha == that->alpha) ? Qtrue : Qfalse;
|
363
|
+
#else
|
339
364
|
&& this->opacity == that->opacity) ? Qtrue : Qfalse;
|
365
|
+
#endif
|
340
366
|
}
|
341
367
|
|
342
368
|
return Qfalse;
|
@@ -440,9 +466,13 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
440
466
|
double fuzz = 0.0;
|
441
467
|
unsigned int equal;
|
442
468
|
ColorspaceType colorspace = RGBColorspace;
|
469
|
+
#if defined(IMAGEMAGICK_7)
|
470
|
+
PixelColor this, that;
|
471
|
+
#else
|
443
472
|
Image *image;
|
444
473
|
Info *info;
|
445
474
|
Pixel *this, *that;
|
475
|
+
#endif
|
446
476
|
|
447
477
|
switch (argc)
|
448
478
|
{
|
@@ -458,6 +488,15 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
458
488
|
break;
|
459
489
|
}
|
460
490
|
|
491
|
+
#if defined(IMAGEMAGICK_7)
|
492
|
+
Color_to_PixelColor(&this, self);
|
493
|
+
Color_to_PixelColor(&that, argv[0]);
|
494
|
+
this.fuzz = fuzz;
|
495
|
+
this.colorspace = colorspace;
|
496
|
+
that.fuzz = fuzz;
|
497
|
+
that.colorspace = colorspace;
|
498
|
+
equal = IsFuzzyEquivalencePixelInfo(&this, &that);
|
499
|
+
#else
|
461
500
|
Data_Get_Struct(self, Pixel, this);
|
462
501
|
Data_Get_Struct(argv[0], Pixel, that);
|
463
502
|
|
@@ -485,6 +524,7 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
485
524
|
|
486
525
|
equal = IsColorSimilar(image, this, that);
|
487
526
|
(void) DestroyImage(image);
|
527
|
+
#endif
|
488
528
|
|
489
529
|
return equal ? Qtrue : Qfalse;
|
490
530
|
}
|
@@ -602,7 +642,11 @@ Pixel_from_hsla(int argc, VALUE *argv, VALUE class ATTRIBUTE_UNUSED)
|
|
602
642
|
|
603
643
|
exception = AcquireExceptionInfo();
|
604
644
|
|
645
|
+
#if defined(IMAGEMAGICK_7)
|
646
|
+
(void) QueryColorCompliance(name, AllCompliance, &pp, exception);
|
647
|
+
#else
|
605
648
|
(void) QueryMagickColor(name, &pp, exception);
|
649
|
+
#endif
|
606
650
|
CHECK_EXCEPTION()
|
607
651
|
|
608
652
|
(void) DestroyExceptionInfo(exception);
|
@@ -631,7 +675,11 @@ Pixel_from_MagickPixel(const MagickPixel *pp)
|
|
631
675
|
pixel->red = ROUND_TO_QUANTUM(pp->red);
|
632
676
|
pixel->green = ROUND_TO_QUANTUM(pp->green);
|
633
677
|
pixel->blue = ROUND_TO_QUANTUM(pp->blue);
|
678
|
+
#if defined(IMAGEMAGICK_7)
|
679
|
+
pixel->alpha = ROUND_TO_QUANTUM(pp->alpha);
|
680
|
+
#else
|
634
681
|
pixel->opacity = ROUND_TO_QUANTUM(pp->opacity);
|
682
|
+
#endif
|
635
683
|
|
636
684
|
return Data_Wrap_Struct(Class_Pixel, NULL, destroy_Pixel, pixel);
|
637
685
|
}
|
@@ -657,7 +705,11 @@ Pixel_from_PixelPacket(const PixelPacket *pp)
|
|
657
705
|
pixel->red = pp->red;
|
658
706
|
pixel->green = pp->green;
|
659
707
|
pixel->blue = pp->blue;
|
708
|
+
#if defined(IMAGEMAGICK_7)
|
709
|
+
pixel->alpha = pp->alpha;
|
710
|
+
#else
|
660
711
|
pixel->opacity = pp->opacity;
|
712
|
+
#endif
|
661
713
|
|
662
714
|
return Data_Wrap_Struct(Class_Pixel, NULL, destroy_Pixel, pixel);
|
663
715
|
}
|
@@ -683,7 +735,11 @@ Pixel_from_PixelColor(const PixelColor *pp)
|
|
683
735
|
pixel->red = pp->red;
|
684
736
|
pixel->green = pp->green;
|
685
737
|
pixel->blue = pp->blue;
|
738
|
+
#if defined(IMAGEMAGICK_7)
|
739
|
+
pixel->alpha = pp->alpha;
|
740
|
+
#else
|
686
741
|
pixel->opacity = pp->opacity;
|
742
|
+
#endif
|
687
743
|
|
688
744
|
return Data_Wrap_Struct(Class_Pixel, NULL, destroy_Pixel, pixel);
|
689
745
|
}
|
@@ -711,7 +767,11 @@ Pixel_hash(VALUE self)
|
|
711
767
|
hash = ScaleQuantumToChar(pixel->red) << 24;
|
712
768
|
hash += ScaleQuantumToChar(pixel->green) << 16;
|
713
769
|
hash += ScaleQuantumToChar(pixel->blue) << 8;
|
770
|
+
#if defined(IMAGEMAGICK_7)
|
771
|
+
hash += ScaleQuantumToChar(pixel->alpha);
|
772
|
+
#else
|
714
773
|
hash += ScaleQuantumToChar(QuantumRange - pixel->opacity);
|
774
|
+
#endif
|
715
775
|
|
716
776
|
return UINT2NUM(hash >> 1);
|
717
777
|
}
|
@@ -770,13 +830,24 @@ Pixel_initialize(int argc, VALUE *argv, VALUE self)
|
|
770
830
|
|
771
831
|
Data_Get_Struct(self, Pixel, pixel);
|
772
832
|
|
833
|
+
#if defined(IMAGEMAGICK_7)
|
834
|
+
pixel->alpha = OpaqueAlpha;
|
835
|
+
#endif
|
836
|
+
|
773
837
|
switch(argc)
|
774
838
|
{
|
775
839
|
case 4:
|
840
|
+
#if defined(IMAGEMAGICK_7)
|
841
|
+
if (argv[3] != Qnil)
|
842
|
+
{
|
843
|
+
pixel->alpha = APP2QUANTUM(argv[3]);
|
844
|
+
}
|
845
|
+
#else
|
776
846
|
if (argv[3] != Qnil)
|
777
847
|
{
|
778
848
|
pixel->opacity = APP2QUANTUM(argv[3]);
|
779
849
|
}
|
850
|
+
#endif
|
780
851
|
case 3:
|
781
852
|
if (argv[2] != Qnil)
|
782
853
|
{
|
@@ -847,7 +918,11 @@ Pixel_marshal_dump(VALUE self)
|
|
847
918
|
rb_hash_aset(dpixel, CSTR2SYM("red"), QUANTUM2NUM(pixel->red));
|
848
919
|
rb_hash_aset(dpixel, CSTR2SYM("green"), QUANTUM2NUM(pixel->green));
|
849
920
|
rb_hash_aset(dpixel, CSTR2SYM("blue"), QUANTUM2NUM(pixel->blue));
|
921
|
+
#if defined(IMAGEMAGICK_7)
|
922
|
+
rb_hash_aset(dpixel, CSTR2SYM("alpha"), QUANTUM2NUM(pixel->alpha));
|
923
|
+
#else
|
850
924
|
rb_hash_aset(dpixel, CSTR2SYM("opacity"), QUANTUM2NUM(pixel->opacity));
|
925
|
+
#endif
|
851
926
|
|
852
927
|
RB_GC_GUARD(dpixel);
|
853
928
|
|
@@ -874,7 +949,11 @@ Pixel_marshal_load(VALUE self, VALUE dpixel)
|
|
874
949
|
pixel->red = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("red")));
|
875
950
|
pixel->green = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("green")));
|
876
951
|
pixel->blue = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("blue")));
|
952
|
+
#if defined(IMAGEMAGICK_7)
|
953
|
+
pixel->alpha = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("alpha")));
|
954
|
+
#else
|
877
955
|
pixel->opacity = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("opacity")));
|
956
|
+
#endif
|
878
957
|
return self;
|
879
958
|
}
|
880
959
|
|
@@ -909,10 +988,17 @@ Pixel_spaceship(VALUE self, VALUE other)
|
|
909
988
|
{
|
910
989
|
return INT2NUM((this->blue - that->blue)/abs(this->blue - that->blue));
|
911
990
|
}
|
991
|
+
#if defined(IMAGEMAGICK_7)
|
992
|
+
else if(this->alpha != that->alpha)
|
993
|
+
{
|
994
|
+
return INT2NUM((this->alpha - that->alpha)/abs(this->alpha - that->alpha));
|
995
|
+
}
|
996
|
+
#else
|
912
997
|
else if(this->opacity != that->opacity)
|
913
998
|
{
|
914
999
|
return INT2NUM(((QuantumRange - this->opacity) - (QuantumRange - that->opacity))/abs((QuantumRange - this->opacity) - (QuantumRange - that->opacity)));
|
915
1000
|
}
|
1001
|
+
#endif
|
916
1002
|
|
917
1003
|
// Values are equal, check class.
|
918
1004
|
|
@@ -947,6 +1033,20 @@ Pixel_to_hsla(VALUE self)
|
|
947
1033
|
sat *= 255.0;
|
948
1034
|
lum *= 255.0;
|
949
1035
|
|
1036
|
+
#if defined(IMAGEMAGICK_7)
|
1037
|
+
if (pixel->alpha == OpaqueAlpha)
|
1038
|
+
{
|
1039
|
+
alpha = 1.0;
|
1040
|
+
}
|
1041
|
+
else if (pixel->alpha == TransparentAlpha)
|
1042
|
+
{
|
1043
|
+
alpha = 0.0;
|
1044
|
+
}
|
1045
|
+
else
|
1046
|
+
{
|
1047
|
+
alpha = (double)(pixel->alpha) / (double)QuantumRange;
|
1048
|
+
}
|
1049
|
+
#else
|
950
1050
|
if (pixel->opacity == OpaqueOpacity)
|
951
1051
|
{
|
952
1052
|
alpha = 1.0;
|
@@ -959,6 +1059,7 @@ Pixel_to_hsla(VALUE self)
|
|
959
1059
|
{
|
960
1060
|
alpha = (double)(QuantumRange - pixel->opacity) / (double)QuantumRange;
|
961
1061
|
}
|
1062
|
+
#endif
|
962
1063
|
|
963
1064
|
hsla = rb_ary_new3(4, rb_float_new(hue), rb_float_new(sat), rb_float_new(lum), rb_float_new(alpha));
|
964
1065
|
|
@@ -985,7 +1086,11 @@ rm_set_magick_pixel_packet(Pixel *pixel, MagickPixel *pp)
|
|
985
1086
|
pp->red = (MagickRealType) pixel->red;
|
986
1087
|
pp->green = (MagickRealType) pixel->green;
|
987
1088
|
pp->blue = (MagickRealType) pixel->blue;
|
1089
|
+
#if defined(IMAGEMAGICK_7)
|
1090
|
+
pp->alpha = (MagickRealType) pixel->alpha;
|
1091
|
+
#else
|
988
1092
|
pp->opacity = (MagickRealType) pixel->opacity;
|
1093
|
+
#endif
|
989
1094
|
pp->index = (MagickRealType) 0.0;
|
990
1095
|
}
|
991
1096
|
|
@@ -996,13 +1101,13 @@ rm_set_magick_pixel_packet(Pixel *pixel, MagickPixel *pp)
|
|
996
1101
|
* Ruby usage:
|
997
1102
|
* - @verbatim Magick::Pixel#to_color @endverbatim
|
998
1103
|
* - @verbatim Magick::Pixel#to_color(compliance) @endverbatim
|
999
|
-
* - @verbatim Magick::Pixel#to_color(compliance,
|
1000
|
-
* - @verbatim Magick::Pixel#to_color(compliance,
|
1001
|
-
* - @verbatim Magick::Pixel#to_color(compliance,
|
1104
|
+
* - @verbatim Magick::Pixel#to_color(compliance, alpha) @endverbatim
|
1105
|
+
* - @verbatim Magick::Pixel#to_color(compliance, alpha, depth) @endverbatim
|
1106
|
+
* - @verbatim Magick::Pixel#to_color(compliance, alpha, depth, hex) @endverbatim
|
1002
1107
|
*
|
1003
1108
|
* Notes:
|
1004
1109
|
* - Default compliance is AllCompliance
|
1005
|
-
* - Default
|
1110
|
+
* - Default alpha is false
|
1006
1111
|
* - Default depth is MAGICKCORE_QUANTUM_DEPTH
|
1007
1112
|
* - Default hex is false
|
1008
1113
|
* - The conversion respects the value of the 'opacity' field in the Pixel
|
@@ -1023,7 +1128,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1023
1128
|
char name[MaxTextExtent];
|
1024
1129
|
ExceptionInfo *exception;
|
1025
1130
|
ComplianceType compliance = AllCompliance;
|
1026
|
-
unsigned int
|
1131
|
+
unsigned int alpha = MagickFalse;
|
1027
1132
|
unsigned int depth = MAGICKCORE_QUANTUM_DEPTH;
|
1028
1133
|
|
1029
1134
|
switch (argc)
|
@@ -1049,7 +1154,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1049
1154
|
break;
|
1050
1155
|
}
|
1051
1156
|
case 2:
|
1052
|
-
|
1157
|
+
alpha = RTEST(argv[1]);
|
1053
1158
|
case 1:
|
1054
1159
|
VALUE_TO_ENUM(argv[0], compliance, ComplianceType);
|
1055
1160
|
case 0:
|
@@ -1069,28 +1174,34 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1069
1174
|
rb_raise(rb_eNoMemError, "not enough memory to continue.");
|
1070
1175
|
}
|
1071
1176
|
|
1177
|
+
exception = AcquireExceptionInfo();
|
1178
|
+
|
1072
1179
|
image->depth = depth;
|
1073
|
-
|
1180
|
+
#if defined(IMAGEMAGICK_6)
|
1181
|
+
image->matte = alpha;
|
1182
|
+
#endif
|
1074
1183
|
|
1075
1184
|
rm_init_magickpixel(image, &mpp);
|
1076
1185
|
rm_set_magick_pixel_packet(pixel, &mpp);
|
1077
1186
|
|
1078
|
-
exception = AcquireExceptionInfo();
|
1079
|
-
|
1080
1187
|
// Support for hex-format color names moved out of QueryMagickColorname
|
1081
1188
|
// in 6.4.1-9. The 'hex' argument was removed as well.
|
1082
1189
|
if (hex)
|
1083
1190
|
{
|
1084
1191
|
if (compliance == XPMCompliance)
|
1085
1192
|
{
|
1193
|
+
#if defined(IMAGEMAGICK_7)
|
1194
|
+
mpp.alpha_trait = UndefinedPixelTrait;
|
1195
|
+
#else
|
1086
1196
|
mpp.matte = MagickFalse;
|
1197
|
+
#endif
|
1087
1198
|
mpp.depth = (unsigned long) min(1.0 * image->depth, 16.0);
|
1088
1199
|
}
|
1089
1200
|
(void) GetColorTuple(&mpp, MagickTrue, name);
|
1090
1201
|
}
|
1091
1202
|
else
|
1092
1203
|
{
|
1093
|
-
(void)
|
1204
|
+
(void) QueryColorname(image, &mpp, compliance, name, exception);
|
1094
1205
|
}
|
1095
1206
|
|
1096
1207
|
(void) DestroyImage(image);
|
@@ -1120,7 +1231,11 @@ Pixel_to_s(VALUE self)
|
|
1120
1231
|
Data_Get_Struct(self, Pixel, pixel);
|
1121
1232
|
sprintf(buff, "red=" QuantumFormat ", green=" QuantumFormat ", blue=" QuantumFormat ", alpha=" QuantumFormat,
|
1122
1233
|
pixel->red, pixel->green, pixel->blue,
|
1234
|
+
#if defined(IMAGEMAGICK_7)
|
1235
|
+
pixel->alpha);
|
1236
|
+
#else
|
1123
1237
|
(QuantumRange - pixel->opacity));
|
1238
|
+
#endif
|
1124
1239
|
return rb_str_new2(buff);
|
1125
1240
|
}
|
1126
1241
|
|