rmagick 2.3.0 → 2.4.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.
- data/ChangeLog +3 -0
- data/README.html +215 -188
- data/build_tarball.rake +12 -11
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +2 -2
- data/doc/draw.html +2 -2
- data/doc/ex/get_type_metrics.rb +1 -1
- data/doc/ex/wet_floor.rb +12 -12
- data/doc/ilist.html +2 -2
- data/doc/image1.html +3 -3
- data/doc/image2.html +2 -2
- data/doc/image3.html +2 -2
- data/doc/imageattrs.html +42 -30
- data/doc/imusage.html +2 -2
- data/doc/index.html +3 -3
- data/doc/info.html +2 -2
- data/doc/magick.html +2 -2
- data/doc/optequiv.html +2 -2
- data/doc/rvg.html +2 -2
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +2 -2
- data/doc/rvgpattern.html +2 -2
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +2 -2
- data/doc/rvgtut.html +2 -2
- data/doc/rvguse.html +2 -2
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +18 -18
- data/doc/usage.html +2 -2
- data/ext/RMagick/MANIFEST +1 -2
- data/ext/RMagick/extconf.rb +26 -5
- data/ext/RMagick/rmagick.h +20 -9
- data/ext/RMagick/rmdraw.c +21 -13
- data/ext/RMagick/rmfill.c +8 -29
- data/ext/RMagick/rmilist.c +3 -3
- data/ext/RMagick/rmimage.c +235 -143
- data/ext/RMagick/rminfo.c +12 -11
- data/ext/RMagick/rmmain.c +13 -12
- data/ext/RMagick/rmutil.c +27 -27
- data/lib/RMagick.rb +3 -3
- data/rmagick.gemspec +1 -1
- metadata +2 -3
- data/README.txt +0 -245
data/ext/RMagick/rmagick.h
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmagick.h,v 1.
|
1
|
+
/* $Id: rmagick.h,v 1.234 2008/06/02 22:47:37 rmagick Exp $ */
|
2
2
|
/*=============================================================================
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmagick.h
|
@@ -122,6 +122,12 @@
|
|
122
122
|
#define RARRAY_PTR(a) RARRAY((a))->ptr
|
123
123
|
#endif
|
124
124
|
|
125
|
+
// These two functions are defined in IM starting with 6.3.2.
|
126
|
+
#if !defined(HAVE_GETSTRINGINFODATUM)
|
127
|
+
#define GetStringInfoDatum(p) (unsigned char *)((p)->datum)
|
128
|
+
#define GetStringInfoLength(p) (size_t)((p)->length)
|
129
|
+
#endif
|
130
|
+
|
125
131
|
// ImageLayerMethod replaced MagickLayerMethod starting with 6.3.6
|
126
132
|
#if defined(HAVE_TYPE_IMAGELAYERMETHOD)
|
127
133
|
#define LAYERMETHODTYPE ImageLayerMethod
|
@@ -530,6 +536,14 @@ Pixel_##_cmyk_channel_(VALUE self) \
|
|
530
536
|
// declaration can refer to a function defined in another source file or
|
531
537
|
// the same source file.
|
532
538
|
|
539
|
+
|
540
|
+
// rmmain.c
|
541
|
+
extern void Init_RMagick2(void);
|
542
|
+
extern VALUE Magick_colors(VALUE);
|
543
|
+
extern VALUE Magick_fonts(VALUE);
|
544
|
+
extern VALUE Magick_init_formats(VALUE);
|
545
|
+
|
546
|
+
|
533
547
|
// rmdraw.c
|
534
548
|
ATTR_WRITER(Draw, affine)
|
535
549
|
ATTR_WRITER(Draw, align)
|
@@ -598,10 +612,6 @@ ATTR_WRITER(PolaroidOptions, shadow_color);
|
|
598
612
|
ATTR_WRITER(PolaroidOptions, border_color);
|
599
613
|
|
600
614
|
|
601
|
-
// rmmain.c
|
602
|
-
extern VALUE rm_montage_new(void);
|
603
|
-
|
604
|
-
|
605
615
|
// rmilist.c
|
606
616
|
extern VALUE ImageList_animate(int, VALUE *, VALUE);
|
607
617
|
extern VALUE ImageList_append(VALUE, VALUE);
|
@@ -719,7 +729,7 @@ ATTR_ACCESSOR(Image, fuzz)
|
|
719
729
|
ATTR_ACCESSOR(Image, gamma)
|
720
730
|
ATTR_ACCESSOR(Image, geometry)
|
721
731
|
ATTR_ACCESSOR(Image, gravity)
|
722
|
-
|
732
|
+
ATTR_ACCESSOR(Image, image_type)
|
723
733
|
ATTR_ACCESSOR(Image, interlace)
|
724
734
|
ATTR_ACCESSOR(Image, iptc_profile)
|
725
735
|
ATTR_ACCESSOR(Image, iterations)
|
@@ -1025,7 +1035,7 @@ extern VALUE Pixel_to_hsla(VALUE);
|
|
1025
1035
|
extern VALUE Pixel_to_s(VALUE);
|
1026
1036
|
extern VALUE PixelPacket_to_Color_Name(Image *, PixelPacket *);
|
1027
1037
|
extern VALUE PixelPacket_to_Color_Name_Info(Info *, PixelPacket *);
|
1028
|
-
extern VALUE Pixel_from_PixelPacket(PixelPacket *);
|
1038
|
+
extern VALUE Pixel_from_PixelPacket(const PixelPacket *);
|
1029
1039
|
|
1030
1040
|
extern void Point_to_PointInfo(PointInfo *, VALUE);
|
1031
1041
|
extern VALUE PointInfo_to_Point(PointInfo *);
|
@@ -1047,11 +1057,12 @@ extern void Rectangle_to_RectangleInfo(RectangleInfo *, VALUE);
|
|
1047
1057
|
extern void Segment_to_SegmentInfo(SegmentInfo *, VALUE);
|
1048
1058
|
extern void Font_to_TypeInfo(TypeInfo *, VALUE);
|
1049
1059
|
extern void TypeMetric_to_TypeMetric(TypeMetric *, VALUE);
|
1050
|
-
extern VALUE Font_from_TypeInfo(TypeInfo *);
|
1060
|
+
extern VALUE Font_from_TypeInfo(const TypeInfo *);
|
1051
1061
|
extern VALUE TypeMetric_to_s(VALUE);
|
1052
1062
|
extern VALUE TypeMetric_from_TypeMetric(TypeMetric *);
|
1053
1063
|
extern const char *StorageType_name(StorageType);
|
1054
1064
|
extern VALUE VirtualPixelMethod_new(VirtualPixelMethod);
|
1065
|
+
extern VALUE LAYERMETHODTYPE_NEW(LAYERMETHODTYPE);
|
1055
1066
|
|
1056
1067
|
extern VALUE Enum_alloc(VALUE);
|
1057
1068
|
extern VALUE Enum_initialize(VALUE, VALUE, VALUE);
|
@@ -1086,7 +1097,7 @@ extern double rm_fuzz_to_dbl(VALUE);
|
|
1086
1097
|
extern Quantum rm_app2quantum(VALUE);
|
1087
1098
|
extern double rm_percentage(VALUE);
|
1088
1099
|
extern double rm_str_to_pct(VALUE);
|
1089
|
-
extern VALUE rm_define_enum_type(char *);
|
1100
|
+
extern VALUE rm_define_enum_type(const char *);
|
1090
1101
|
extern void rm_write_temp_image(Image *, char *);
|
1091
1102
|
extern void rm_delete_temp_image(char *);
|
1092
1103
|
extern void rm_not_implemented(void);
|
data/ext/RMagick/rmdraw.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmdraw.c,v 1.
|
1
|
+
/* $Id: rmdraw.c,v 1.64 2008/05/21 22:32:40 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmdraw.c
|
@@ -489,7 +489,11 @@ VALUE Draw_annotate(
|
|
489
489
|
}
|
490
490
|
|
491
491
|
// Translate & store in Draw structure
|
492
|
+
#if defined(HAVE_INTERPRETIMAGEPROPERTIES)
|
493
|
+
draw->info->text = InterpretImageProperties(NULL, image, StringValuePtr(text));
|
494
|
+
#else
|
492
495
|
draw->info->text = InterpretImageAttributes(NULL, image, StringValuePtr(text));
|
496
|
+
#endif
|
493
497
|
if (!draw->info->text)
|
494
498
|
{
|
495
499
|
rb_raise(rb_eArgError, "no text");
|
@@ -561,7 +565,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
561
565
|
CompositeOperator cop = OverCompositeOp;
|
562
566
|
volatile VALUE image;
|
563
567
|
Image *comp_img;
|
564
|
-
struct TmpFile_Name *
|
568
|
+
struct TmpFile_Name *tmpfile_name;
|
565
569
|
char name[MaxTextExtent];
|
566
570
|
// Buffer for "image" primitive
|
567
571
|
char primitive[MaxTextExtent];
|
@@ -656,10 +660,10 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
656
660
|
// Add the temp filename to the filename array.
|
657
661
|
// Use Magick storage since we need to keep the list around
|
658
662
|
// until destroy_Draw is called.
|
659
|
-
|
660
|
-
strcpy(
|
661
|
-
|
662
|
-
draw->tmpfile_ary =
|
663
|
+
tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name)+strlen(name));
|
664
|
+
strcpy(tmpfile_name->name, name);
|
665
|
+
tmpfile_name->next = draw->tmpfile_ary;
|
666
|
+
draw->tmpfile_ary = tmpfile_name;
|
663
667
|
|
664
668
|
// Form the drawing primitive
|
665
669
|
(void) sprintf(primitive, "image %s %g,%g,%g,%g '%s'", op, x, y, width, height, name);
|
@@ -879,7 +883,7 @@ static void
|
|
879
883
|
destroy_Draw(void *drawptr)
|
880
884
|
{
|
881
885
|
Draw *draw = (Draw *)drawptr;
|
882
|
-
struct TmpFile_Name *
|
886
|
+
struct TmpFile_Name *tmpfile_name;
|
883
887
|
|
884
888
|
if (draw->info)
|
885
889
|
{
|
@@ -890,10 +894,10 @@ destroy_Draw(void *drawptr)
|
|
890
894
|
// Erase any temporary image files.
|
891
895
|
while (draw->tmpfile_ary)
|
892
896
|
{
|
893
|
-
|
897
|
+
tmpfile_name = draw->tmpfile_ary;
|
894
898
|
draw->tmpfile_ary = draw->tmpfile_ary->next;
|
895
|
-
rm_delete_temp_image(
|
896
|
-
magick_free(
|
899
|
+
rm_delete_temp_image(tmpfile_name->name);
|
900
|
+
magick_free(tmpfile_name);
|
897
901
|
}
|
898
902
|
|
899
903
|
xfree(drawptr);
|
@@ -1254,7 +1258,7 @@ Montage_texture_eq(VALUE self, VALUE texture)
|
|
1254
1258
|
{
|
1255
1259
|
Montage *montage;
|
1256
1260
|
Image *texture_image;
|
1257
|
-
char
|
1261
|
+
char temp_name[MaxTextExtent];
|
1258
1262
|
|
1259
1263
|
Data_Get_Struct(self, Montage, montage);
|
1260
1264
|
|
@@ -1271,8 +1275,8 @@ Montage_texture_eq(VALUE self, VALUE texture)
|
|
1271
1275
|
texture_image = rm_check_destroyed(texture);
|
1272
1276
|
|
1273
1277
|
// Write a temp copy of the image & save its name.
|
1274
|
-
rm_write_temp_image(texture_image,
|
1275
|
-
magick_clone_string(&montage->info->texture,
|
1278
|
+
rm_write_temp_image(texture_image, temp_name);
|
1279
|
+
magick_clone_string(&montage->info->texture, temp_name);
|
1276
1280
|
|
1277
1281
|
return self;
|
1278
1282
|
}
|
@@ -1500,7 +1504,11 @@ get_type_metrics(
|
|
1500
1504
|
}
|
1501
1505
|
|
1502
1506
|
Data_Get_Struct(self, Draw, draw);
|
1507
|
+
#if defined(HAVE_INTERPRETIMAGEPROPERTIES)
|
1508
|
+
draw->info->text = InterpretImageProperties(NULL, image, text);
|
1509
|
+
#else
|
1503
1510
|
draw->info->text = InterpretImageAttributes(NULL, image, text);
|
1511
|
+
#endif
|
1504
1512
|
if (!draw->info->text)
|
1505
1513
|
{
|
1506
1514
|
rb_raise(rb_eArgError, "no text to measure");
|
data/ext/RMagick/rmfill.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmfill.c,v 1.
|
1
|
+
/* $Id: rmfill.c,v 1.29 2008/05/28 22:40:15 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmfill.c
|
@@ -131,20 +131,10 @@ vertical_fill(
|
|
131
131
|
{
|
132
132
|
double steps;
|
133
133
|
unsigned long x, y;
|
134
|
-
|
134
|
+
PixelPacket *master;
|
135
135
|
MagickRealType red_step, green_step, blue_step;
|
136
136
|
|
137
|
-
// Keep in mind that x1 could be < 0 or > image->columns. If steps
|
138
|
-
// is negative, swap the start and end colors and use the absolute
|
139
|
-
// value.
|
140
137
|
steps = FMAX(x1, ((long)image->columns)-x1);
|
141
|
-
if (steps < 0)
|
142
|
-
{
|
143
|
-
PixelPacket t = *start_color;
|
144
|
-
*start_color = *stop_color;
|
145
|
-
*stop_color = t;
|
146
|
-
steps = -steps;
|
147
|
-
}
|
148
138
|
|
149
139
|
// If x is to the left of the x-axis, add that many steps so that
|
150
140
|
// the color at the right side will be that many steps away from
|
@@ -181,14 +171,14 @@ vertical_fill(
|
|
181
171
|
rm_check_image_exception(image, RetainOnError);
|
182
172
|
}
|
183
173
|
|
184
|
-
memcpy(row_pixels,
|
174
|
+
memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
|
185
175
|
if (!SyncImagePixels(image))
|
186
176
|
{
|
187
177
|
rm_check_image_exception(image, RetainOnError);
|
188
178
|
}
|
189
179
|
}
|
190
180
|
|
191
|
-
xfree((
|
181
|
+
xfree((void *)master);
|
192
182
|
}
|
193
183
|
|
194
184
|
/*
|
@@ -204,19 +194,10 @@ horizontal_fill(
|
|
204
194
|
{
|
205
195
|
double steps;
|
206
196
|
unsigned long x, y;
|
207
|
-
|
197
|
+
PixelPacket *master;
|
208
198
|
MagickRealType red_step, green_step, blue_step;
|
209
199
|
|
210
|
-
// Bear in mind that y1 could be < 0 or > image->rows. If steps is
|
211
|
-
// negative, swap the start and end colors and use the absolute value.
|
212
200
|
steps = FMAX(y1, ((long)image->rows)-y1);
|
213
|
-
if (steps < 0)
|
214
|
-
{
|
215
|
-
PixelPacket t = *start_color;
|
216
|
-
*start_color = *stop_color;
|
217
|
-
*stop_color = t;
|
218
|
-
steps = -steps;
|
219
|
-
}
|
220
201
|
|
221
202
|
// If the line is below the y-axis, add that many steps so the color
|
222
203
|
// at the bottom of the image is that many steps away from the stop color
|
@@ -231,7 +212,7 @@ horizontal_fill(
|
|
231
212
|
|
232
213
|
// All the columns are the same, so make a master column and copy it to
|
233
214
|
// each of the "real" columns.
|
234
|
-
master = ALLOC_N(
|
215
|
+
master = ALLOC_N(PixelPacket, image->rows);
|
235
216
|
|
236
217
|
for (y = 0; y < image->rows; y++)
|
237
218
|
{
|
@@ -250,7 +231,7 @@ horizontal_fill(
|
|
250
231
|
{
|
251
232
|
rm_check_image_exception(image, RetainOnError);
|
252
233
|
}
|
253
|
-
memcpy(col_pixels,
|
234
|
+
memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
|
254
235
|
if (!SyncImagePixels(image))
|
255
236
|
{
|
256
237
|
rm_check_image_exception(image, RetainOnError);
|
@@ -452,8 +433,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
|
|
452
433
|
point_fill(image, x1, y1, &start_color, &stop_color);
|
453
434
|
}
|
454
435
|
|
455
|
-
// A vertical line is a special case.
|
456
|
-
// as both the 2nd and 4th arguments!)
|
436
|
+
// A vertical line is a special case.
|
457
437
|
else
|
458
438
|
{
|
459
439
|
vertical_fill(image, x1, &start_color, &stop_color);
|
@@ -463,7 +443,6 @@ GradientFill_fill(VALUE self, VALUE image_obj)
|
|
463
443
|
// A horizontal line is a special case.
|
464
444
|
else if (fabs(y2-y1) < 0.5)
|
465
445
|
{
|
466
|
-
// Pass y1 as both the 3rd and 5th arguments!
|
467
446
|
horizontal_fill(image, y1, &start_color, &stop_color);
|
468
447
|
}
|
469
448
|
|
data/ext/RMagick/rmilist.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmilist.c,v 1.
|
1
|
+
/* $Id: rmilist.c,v 1.71 2008/05/21 22:32:40 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmilist.c
|
@@ -611,7 +611,7 @@ ImageList_optimize_layers(VALUE self, VALUE method)
|
|
611
611
|
Notes: this simply calls ImageList.new() in RMagick.rb
|
612
612
|
*/
|
613
613
|
static VALUE
|
614
|
-
ImageList_new()
|
614
|
+
ImageList_new(void)
|
615
615
|
{
|
616
616
|
return rb_funcall(Class_ImageList, rm_ID_new, 0);
|
617
617
|
}
|
@@ -799,7 +799,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
799
799
|
// Create new ImageList object, convert mapped image sequence to images,
|
800
800
|
// append to images array.
|
801
801
|
new_imagelist = ImageList_new();
|
802
|
-
while ((new_image =
|
802
|
+
while ((new_image = RemoveFirstImageFromList(&new_images)))
|
803
803
|
{
|
804
804
|
imagelist_push(new_imagelist, rm_image_new(new_image));
|
805
805
|
}
|
data/ext/RMagick/rmimage.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmimage.c,v 1.
|
1
|
+
/* $Id: rmimage.c,v 1.295 2008/06/02 22:47:37 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmimage.c
|
@@ -26,7 +26,7 @@ static VALUE scale(int, int, VALUE *, VALUE, scaler_t);
|
|
26
26
|
static VALUE threshold_image(int, VALUE *, VALUE, thresholder_t);
|
27
27
|
static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, xformer_t);
|
28
28
|
static VALUE array_from_images(Image *);
|
29
|
-
static void call_trace_proc(Image *, char *);
|
29
|
+
static void call_trace_proc(Image *, const char *);
|
30
30
|
|
31
31
|
static const char *BlackPointCompensationKey = "PROFILE:black-point-compensation";
|
32
32
|
|
@@ -146,7 +146,7 @@ Image_adaptive_blur_channel(int argc, VALUE *argv, VALUE self)
|
|
146
146
|
|
147
147
|
|
148
148
|
/*
|
149
|
-
Method: Image#adaptive_resize(
|
149
|
+
Method: Image#adaptive_resize(scale_val)
|
150
150
|
Image#adaptive_resize(cols, rows)
|
151
151
|
Purpose: Call AdaptiveResizeImage
|
152
152
|
*/
|
@@ -155,7 +155,7 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
|
|
155
155
|
{
|
156
156
|
Image *image, *new_image;
|
157
157
|
unsigned long rows, columns;
|
158
|
-
double
|
158
|
+
double scale_val, drows, dcols;
|
159
159
|
ExceptionInfo exception;
|
160
160
|
|
161
161
|
image = rm_check_destroyed(self);
|
@@ -167,13 +167,13 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
|
|
167
167
|
columns = NUM2ULONG(argv[0]);
|
168
168
|
break;
|
169
169
|
case 1:
|
170
|
-
|
171
|
-
if (
|
170
|
+
scale_val = NUM2DBL(argv[0]);
|
171
|
+
if (scale_val < 0.0)
|
172
172
|
{
|
173
|
-
rb_raise(rb_eArgError, "invalid
|
173
|
+
rb_raise(rb_eArgError, "invalid scale_val value (%g given)", scale_val);
|
174
174
|
}
|
175
|
-
drows =
|
176
|
-
dcols =
|
175
|
+
drows = scale_val * image->rows + 0.5;
|
176
|
+
dcols = scale_val * image->columns + 0.5;
|
177
177
|
if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
|
178
178
|
{
|
179
179
|
rb_raise(rb_eRangeError, "resized image too big");
|
@@ -360,8 +360,15 @@ Image_add_profile(VALUE self, VALUE name)
|
|
360
360
|
{
|
361
361
|
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
362
362
|
}
|
363
|
-
|
364
|
-
|
363
|
+
#if defined(HAVE_ST_PROFILE)
|
364
|
+
profile = GetImageProfile(image, "iptc");
|
365
|
+
if (profile)
|
366
|
+
{
|
367
|
+
info->profile = (void *)CloneStringInfo(profile);
|
368
|
+
}
|
369
|
+
#else
|
370
|
+
info->client_data = GetImageProfile(image, "8bim");
|
371
|
+
#endif
|
365
372
|
strncpy(info->filename, profile_filename, min((size_t)profile_filename_l, sizeof(info->filename)));
|
366
373
|
info->filename[MaxTextExtent-1] = '\0';
|
367
374
|
|
@@ -379,7 +386,8 @@ Image_add_profile(VALUE self, VALUE name)
|
|
379
386
|
profile = GetImageProfile(profile_image, profile_name);
|
380
387
|
if (profile)
|
381
388
|
{
|
382
|
-
(void)ProfileImage(image, profile_name,
|
389
|
+
(void)ProfileImage(image, profile_name, GetStringInfoDatum(profile)
|
390
|
+
, GetStringInfoLength(profile), MagickFalse);
|
383
391
|
if (image->exception.severity >= ErrorException)
|
384
392
|
{
|
385
393
|
break;
|
@@ -602,13 +610,13 @@ Image_aref(VALUE self, VALUE key_arg)
|
|
602
610
|
Returns: self
|
603
611
|
Notes: Specify attr=nil to remove the key from the list.
|
604
612
|
|
605
|
-
|
613
|
+
SetImageProperty normally APPENDS the new value
|
606
614
|
to any existing value. Since this usage is tremendously
|
607
615
|
counter-intuitive, this function always deletes the
|
608
616
|
existing value before setting the new value.
|
609
617
|
|
610
618
|
There's no use checking the return value since
|
611
|
-
|
619
|
+
SetImageProperty returns "False" for many reasons,
|
612
620
|
some legitimate.
|
613
621
|
*/
|
614
622
|
VALUE
|
@@ -642,7 +650,7 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
|
|
642
650
|
}
|
643
651
|
|
644
652
|
|
645
|
-
// Delete existing value.
|
653
|
+
// Delete existing value. SetImageProperty returns False if
|
646
654
|
// the attribute doesn't exist - we don't care.
|
647
655
|
(void) rm_set_property(image, key, NULL);
|
648
656
|
// Set new value
|
@@ -651,7 +659,7 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
|
|
651
659
|
okay = rm_set_property(image, key, attr);
|
652
660
|
if (!okay)
|
653
661
|
{
|
654
|
-
rb_warning("
|
662
|
+
rb_warning("SetImageProperty failed (probably out of memory)");
|
655
663
|
}
|
656
664
|
}
|
657
665
|
return self;
|
@@ -924,7 +932,7 @@ VALUE
|
|
924
932
|
Image_black_point_compensation_eq(VALUE self, VALUE arg)
|
925
933
|
{
|
926
934
|
Image *image;
|
927
|
-
char *value;
|
935
|
+
const char *value;
|
928
936
|
|
929
937
|
image = rm_check_frozen(self);
|
930
938
|
(void) rm_set_property(image, BlackPointCompensationKey, NULL);
|
@@ -960,7 +968,7 @@ get_relative_offsets(
|
|
960
968
|
long *x_offset,
|
961
969
|
long *y_offset)
|
962
970
|
{
|
963
|
-
MagickEnum *
|
971
|
+
MagickEnum *m_enum;
|
964
972
|
GravityType gravity;
|
965
973
|
|
966
974
|
VALUE_TO_ENUM(grav, gravity, GravityType);
|
@@ -999,8 +1007,8 @@ get_relative_offsets(
|
|
999
1007
|
// Don't let these run into the default case
|
1000
1008
|
break;
|
1001
1009
|
default:
|
1002
|
-
Data_Get_Struct(grav, MagickEnum,
|
1003
|
-
rb_warning("gravity type `%s' has no effect", rb_id2name(
|
1010
|
+
Data_Get_Struct(grav, MagickEnum, m_enum);
|
1011
|
+
rb_warning("gravity type `%s' has no effect", rb_id2name(m_enum->id));
|
1004
1012
|
break;
|
1005
1013
|
}
|
1006
1014
|
|
@@ -2067,7 +2075,32 @@ Image_color_flood_fill(
|
|
2067
2075
|
|
2068
2076
|
new_image = rm_clone_image(image);
|
2069
2077
|
|
2078
|
+
#if defined(HAVE_FLOODFILLPAINTIMAGE)
|
2079
|
+
{
|
2080
|
+
MagickPixelPacket target_mpp;
|
2081
|
+
MagickBooleanType invert;
|
2082
|
+
|
2083
|
+
GetMagickPixelPacket(new_image, &target_mpp);
|
2084
|
+
if (fill_method == FillToBorderMethod)
|
2085
|
+
{
|
2086
|
+
invert = MagickTrue;
|
2087
|
+
target_mpp.red = (MagickRealType) image->border_color.red;
|
2088
|
+
target_mpp.green = (MagickRealType) image->border_color.green;
|
2089
|
+
target_mpp.blue = (MagickRealType) image->border_color.blue;
|
2090
|
+
}
|
2091
|
+
else
|
2092
|
+
{
|
2093
|
+
invert = MagickFalse;
|
2094
|
+
target_mpp.red = (MagickRealType) target.red;
|
2095
|
+
target_mpp.green = (MagickRealType) target.green;
|
2096
|
+
target_mpp.blue = (MagickRealType) target.blue;
|
2097
|
+
}
|
2098
|
+
|
2099
|
+
(void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert);
|
2100
|
+
}
|
2101
|
+
#else
|
2070
2102
|
(void) ColorFloodfillImage(new_image, draw_info, target, x, y, (PaintMethod)fill_method);
|
2103
|
+
#endif
|
2071
2104
|
// No need to check for error
|
2072
2105
|
|
2073
2106
|
(void) DestroyDrawInfo(draw_info);
|
@@ -2141,7 +2174,7 @@ VALUE
|
|
2141
2174
|
Image_colormap(int argc, VALUE *argv, VALUE self)
|
2142
2175
|
{
|
2143
2176
|
Image *image;
|
2144
|
-
unsigned long
|
2177
|
+
unsigned long idx;
|
2145
2178
|
PixelPacket color, new_color;
|
2146
2179
|
|
2147
2180
|
image = rm_check_destroyed(self);
|
@@ -2152,8 +2185,8 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2152
2185
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
|
2153
2186
|
}
|
2154
2187
|
|
2155
|
-
|
2156
|
-
if (
|
2188
|
+
idx = NUM2ULONG(argv[0]);
|
2189
|
+
if (idx > QuantumRange)
|
2157
2190
|
{
|
2158
2191
|
rb_raise(rb_eIndexError, "index out of range");
|
2159
2192
|
}
|
@@ -2167,11 +2200,11 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2167
2200
|
}
|
2168
2201
|
// Validate the index
|
2169
2202
|
|
2170
|
-
if (
|
2203
|
+
if (idx > image->colors-1)
|
2171
2204
|
{
|
2172
2205
|
rb_raise(rb_eIndexError, "index out of range");
|
2173
2206
|
}
|
2174
|
-
return PixelPacket_to_Color_Name(image, &image->colormap[
|
2207
|
+
return PixelPacket_to_Color_Name(image, &image->colormap[idx]);
|
2175
2208
|
}
|
2176
2209
|
|
2177
2210
|
// This is a "set" operation. Things are different.
|
@@ -2183,7 +2216,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2183
2216
|
Color_to_PixelPacket(&new_color, argv[1]);
|
2184
2217
|
|
2185
2218
|
// Handle no colormap or current colormap too small.
|
2186
|
-
if (!image->colormap ||
|
2219
|
+
if (!image->colormap || idx > image->colors-1)
|
2187
2220
|
{
|
2188
2221
|
PixelPacket black;
|
2189
2222
|
unsigned long i;
|
@@ -2192,24 +2225,24 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2192
2225
|
|
2193
2226
|
if (!image->colormap)
|
2194
2227
|
{
|
2195
|
-
image->colormap = (PixelPacket *)magick_safe_malloc((
|
2228
|
+
image->colormap = (PixelPacket *)magick_safe_malloc((idx+1), sizeof(PixelPacket));
|
2196
2229
|
image->colors = 0;
|
2197
2230
|
}
|
2198
2231
|
else
|
2199
2232
|
{
|
2200
|
-
image->colormap = (PixelPacket *)magick_safe_realloc(image->colormap, (
|
2233
|
+
image->colormap = (PixelPacket *)magick_safe_realloc(image->colormap, (idx+1), sizeof(PixelPacket));
|
2201
2234
|
}
|
2202
2235
|
|
2203
|
-
for (i = image->colors; i <
|
2236
|
+
for (i = image->colors; i < idx; i++)
|
2204
2237
|
{
|
2205
2238
|
image->colormap[i] = black;
|
2206
2239
|
}
|
2207
|
-
image->colors =
|
2240
|
+
image->colors = idx+1;
|
2208
2241
|
}
|
2209
2242
|
|
2210
2243
|
// Save the current color so we can return it. Set the new color.
|
2211
|
-
color = image->colormap[
|
2212
|
-
image->colormap[
|
2244
|
+
color = image->colormap[idx];
|
2245
|
+
image->colormap[idx] = new_color;
|
2213
2246
|
|
2214
2247
|
return PixelPacket_to_Color_Name(image, &color);
|
2215
2248
|
}
|
@@ -2439,7 +2472,7 @@ static VALUE composite(
|
|
2439
2472
|
Image *comp_image;
|
2440
2473
|
CompositeOperator operator = UndefinedCompositeOp;
|
2441
2474
|
GravityType gravity;
|
2442
|
-
MagickEnum *
|
2475
|
+
MagickEnum *m_enum;
|
2443
2476
|
volatile VALUE comp;
|
2444
2477
|
signed long x_offset = 0;
|
2445
2478
|
signed long y_offset = 0;
|
@@ -2557,8 +2590,8 @@ static VALUE composite(
|
|
2557
2590
|
// Don't let these run into the default case
|
2558
2591
|
break;
|
2559
2592
|
default:
|
2560
|
-
Data_Get_Struct(argv[1], MagickEnum,
|
2561
|
-
rb_warning("gravity type `%s' has no effect", rb_id2name(
|
2593
|
+
Data_Get_Struct(argv[1], MagickEnum, m_enum);
|
2594
|
+
rb_warning("gravity type `%s' has no effect", rb_id2name(m_enum->id));
|
2562
2595
|
break;
|
2563
2596
|
}
|
2564
2597
|
break;
|
@@ -2613,15 +2646,15 @@ Image_composite_affine(
|
|
2613
2646
|
VALUE source,
|
2614
2647
|
VALUE affine_matrix)
|
2615
2648
|
{
|
2616
|
-
Image *image, *
|
2649
|
+
Image *image, *composite_image, *new_image;
|
2617
2650
|
AffineMatrix affine;
|
2618
2651
|
|
2619
2652
|
image = rm_check_destroyed(self);
|
2620
|
-
|
2653
|
+
composite_image = rm_check_destroyed(source);
|
2621
2654
|
new_image = rm_clone_image(image);
|
2622
2655
|
|
2623
2656
|
AffineMatrix_to_AffineMatrix(&affine, affine_matrix);
|
2624
|
-
(void) DrawAffineImage(new_image,
|
2657
|
+
(void) DrawAffineImage(new_image, composite_image, &affine);
|
2625
2658
|
rm_check_image_exception(new_image, DestroyOnError);
|
2626
2659
|
|
2627
2660
|
return rm_image_new(new_image);
|
@@ -2730,11 +2763,11 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
|
|
2730
2763
|
long x, npixels;
|
2731
2764
|
char *map;
|
2732
2765
|
long map_l;
|
2733
|
-
union
|
2766
|
+
volatile union
|
2734
2767
|
{
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2768
|
+
double *f;
|
2769
|
+
Quantum *i;
|
2770
|
+
void *v;
|
2738
2771
|
} pixels;
|
2739
2772
|
volatile VALUE pixel_class;
|
2740
2773
|
StorageType stg_type;
|
@@ -2767,13 +2800,13 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
|
|
2767
2800
|
pixel0 = rb_ary_entry(pixels_arg, 0);
|
2768
2801
|
if (rb_obj_is_kind_of(pixel0, rb_cFloat) == Qtrue)
|
2769
2802
|
{
|
2770
|
-
pixels.f = ALLOC_N(
|
2803
|
+
pixels.f = ALLOC_N(double, npixels);
|
2771
2804
|
stg_type = DoublePixel;
|
2772
2805
|
pixel_class = rb_cFloat;
|
2773
2806
|
}
|
2774
2807
|
else if (rb_obj_is_kind_of(pixel0, rb_cInteger) == Qtrue)
|
2775
2808
|
{
|
2776
|
-
pixels.i = ALLOC_N(
|
2809
|
+
pixels.i = ALLOC_N(Quantum, npixels);
|
2777
2810
|
stg_type = QuantumPixel;
|
2778
2811
|
pixel_class = rb_cInteger;
|
2779
2812
|
}
|
@@ -2824,8 +2857,8 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
|
|
2824
2857
|
(void) SetImageBackgroundColor(image);
|
2825
2858
|
rm_check_image_exception(image, DestroyOnError);
|
2826
2859
|
|
2827
|
-
(void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, (void *)pixels.v);
|
2828
|
-
xfree(
|
2860
|
+
(void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, (const void *)pixels.v);
|
2861
|
+
xfree(pixels.v);
|
2829
2862
|
rm_check_image_exception(image, DestroyOnError);
|
2830
2863
|
|
2831
2864
|
(void) DestroyExceptionInfo(&exception);
|
@@ -2969,7 +3002,7 @@ Image_convolve(
|
|
2969
3002
|
VALUE kernel_arg)
|
2970
3003
|
{
|
2971
3004
|
Image *image, *new_image;
|
2972
|
-
|
3005
|
+
double *kernel;
|
2973
3006
|
unsigned int x, order;
|
2974
3007
|
ExceptionInfo exception;
|
2975
3008
|
|
@@ -2982,7 +3015,7 @@ Image_convolve(
|
|
2982
3015
|
|
2983
3016
|
// Convert the kernel array argument to an array of doubles
|
2984
3017
|
|
2985
|
-
kernel = (
|
3018
|
+
kernel = (double *)ALLOC_N(double, order*order);
|
2986
3019
|
for (x = 0; x < order*order; x++)
|
2987
3020
|
{
|
2988
3021
|
kernel[x] = NUM2DBL(rb_ary_entry(kernel_arg, (long)x));
|
@@ -2990,8 +3023,8 @@ Image_convolve(
|
|
2990
3023
|
|
2991
3024
|
GetExceptionInfo(&exception);
|
2992
3025
|
|
2993
|
-
new_image = ConvolveImage(image, order, (double *)kernel, &exception);
|
2994
|
-
xfree((
|
3026
|
+
new_image = ConvolveImage((const Image *)image, order, (double *)kernel, &exception);
|
3027
|
+
xfree((void *)kernel);
|
2995
3028
|
rm_check_exception(&exception, new_image, DestroyOnError);
|
2996
3029
|
|
2997
3030
|
(void) DestroyExceptionInfo(&exception);
|
@@ -3013,7 +3046,7 @@ Image_convolve_channel(
|
|
3013
3046
|
VALUE self)
|
3014
3047
|
{
|
3015
3048
|
Image *image, *new_image;
|
3016
|
-
|
3049
|
+
double *kernel;
|
3017
3050
|
volatile VALUE ary;
|
3018
3051
|
unsigned int x, order;
|
3019
3052
|
ChannelType channels;
|
@@ -3048,8 +3081,8 @@ Image_convolve_channel(
|
|
3048
3081
|
|
3049
3082
|
GetExceptionInfo(&exception);
|
3050
3083
|
|
3051
|
-
new_image = ConvolveImageChannel(image, channels, order,
|
3052
|
-
xfree((
|
3084
|
+
new_image = ConvolveImageChannel(image, channels, order, kernel, &exception);
|
3085
|
+
xfree((void *)kernel);
|
3053
3086
|
rm_check_exception(&exception, new_image, DestroyOnError);
|
3054
3087
|
|
3055
3088
|
(void) DestroyExceptionInfo(&exception);
|
@@ -3459,11 +3492,11 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
|
|
3459
3492
|
long mapL;
|
3460
3493
|
MagickBooleanType okay;
|
3461
3494
|
ExceptionInfo exception;
|
3462
|
-
union
|
3495
|
+
volatile union
|
3463
3496
|
{
|
3464
|
-
|
3465
|
-
|
3466
|
-
|
3497
|
+
Quantum *i;
|
3498
|
+
double *f;
|
3499
|
+
void *v;
|
3467
3500
|
} pixels;
|
3468
3501
|
|
3469
3502
|
(void) rm_check_destroyed(self);
|
@@ -3579,7 +3612,7 @@ Image_dispose_eq(VALUE self, VALUE dispose)
|
|
3579
3612
|
/*
|
3580
3613
|
Method: Image#dissolve(overlay, src_percent, dst_percent, x_offset=0, y_offset=0)
|
3581
3614
|
Image#dissolve(overlay, src_percent, dst_percent, gravity, x_offset=0, y_offset=0)
|
3582
|
-
Purpose: Corresponds to the
|
3615
|
+
Purpose: Corresponds to the composite_image -dissolve operation
|
3583
3616
|
Notes: `percent' can be a number or a string in the form "NN%"
|
3584
3617
|
The "default" value of dst_percent is -1.0, which tells
|
3585
3618
|
blend_geometry to leave it out of the geometry string.
|
@@ -3590,7 +3623,7 @@ Image_dissolve(int argc, VALUE *argv, VALUE self)
|
|
3590
3623
|
Image *image, *overlay;
|
3591
3624
|
double src_percent, dst_percent = -1.0;
|
3592
3625
|
long x_offset = 0L, y_offset = 0L;
|
3593
|
-
volatile VALUE
|
3626
|
+
volatile VALUE composite_image, ovly;
|
3594
3627
|
|
3595
3628
|
image = rm_check_destroyed(self);
|
3596
3629
|
|
@@ -3621,10 +3654,10 @@ Image_dissolve(int argc, VALUE *argv, VALUE self)
|
|
3621
3654
|
break;
|
3622
3655
|
}
|
3623
3656
|
|
3624
|
-
|
3625
|
-
|
3657
|
+
composite_image = special_composite(image, overlay, src_percent, dst_percent
|
3658
|
+
, x_offset, y_offset, DissolveCompositeOp);
|
3626
3659
|
|
3627
|
-
return
|
3660
|
+
return composite_image;
|
3628
3661
|
}
|
3629
3662
|
|
3630
3663
|
|
@@ -4174,8 +4207,8 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
|
|
4174
4207
|
unsigned long cols, rows;
|
4175
4208
|
long n, npixels;
|
4176
4209
|
unsigned int okay;
|
4177
|
-
char *map = "RGB";
|
4178
|
-
|
4210
|
+
const char *map = "RGB";
|
4211
|
+
Quantum *pixels;
|
4179
4212
|
volatile VALUE ary;
|
4180
4213
|
ExceptionInfo exception;
|
4181
4214
|
|
@@ -4223,7 +4256,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
|
|
4223
4256
|
okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, &exception);
|
4224
4257
|
if (!okay)
|
4225
4258
|
{
|
4226
|
-
xfree((
|
4259
|
+
xfree((void *)pixels);
|
4227
4260
|
CHECK_EXCEPTION()
|
4228
4261
|
|
4229
4262
|
// Should never get here...
|
@@ -4238,7 +4271,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
|
|
4238
4271
|
(void) rb_ary_push(ary, QUANTUM2NUM(pixels[n]));
|
4239
4272
|
}
|
4240
4273
|
|
4241
|
-
xfree((
|
4274
|
+
xfree((void *)pixels);
|
4242
4275
|
|
4243
4276
|
return ary;
|
4244
4277
|
}
|
@@ -4324,7 +4357,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
|
|
4324
4357
|
unsigned long npixels;
|
4325
4358
|
size_t sz;
|
4326
4359
|
unsigned int okay;
|
4327
|
-
char *map = "RGB";
|
4360
|
+
const char *map = "RGB";
|
4328
4361
|
StorageType type = CharPixel;
|
4329
4362
|
volatile VALUE string;
|
4330
4363
|
char *str;
|
@@ -4827,7 +4860,7 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
|
|
4827
4860
|
{
|
4828
4861
|
Image *image, *new_image;
|
4829
4862
|
double red_gamma, green_gamma, blue_gamma;
|
4830
|
-
char
|
4863
|
+
char gamma_arg[50];
|
4831
4864
|
|
4832
4865
|
image = rm_check_destroyed(self);
|
4833
4866
|
switch (argc)
|
@@ -4859,11 +4892,11 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
|
|
4859
4892
|
break;
|
4860
4893
|
}
|
4861
4894
|
|
4862
|
-
sprintf(
|
4895
|
+
sprintf(gamma_arg, "%f,%f,%f", red_gamma, green_gamma, blue_gamma);
|
4863
4896
|
|
4864
4897
|
new_image = rm_clone_image(image);
|
4865
4898
|
|
4866
|
-
(void) GammaImage(new_image,
|
4899
|
+
(void) GammaImage(new_image, gamma_arg);
|
4867
4900
|
rm_check_image_exception(new_image, DestroyOnError);
|
4868
4901
|
|
4869
4902
|
return rm_image_new(new_image);
|
@@ -4976,7 +5009,7 @@ Image_get_pixels(
|
|
4976
5009
|
VALUE rows_arg)
|
4977
5010
|
{
|
4978
5011
|
Image *image;
|
4979
|
-
PixelPacket *pixels;
|
5012
|
+
const PixelPacket *pixels;
|
4980
5013
|
ExceptionInfo exception;
|
4981
5014
|
long x, y;
|
4982
5015
|
unsigned long columns, rows;
|
@@ -4998,7 +5031,7 @@ Image_get_pixels(
|
|
4998
5031
|
// Cast AcquireImagePixels to get rid of the const qualifier. We're not going
|
4999
5032
|
// to change the pixels but I don't want to make "pixels" const.
|
5000
5033
|
GetExceptionInfo(&exception);
|
5001
|
-
pixels =
|
5034
|
+
pixels = AcquireImagePixels(image, x, y, columns, rows, &exception);
|
5002
5035
|
CHECK_EXCEPTION()
|
5003
5036
|
|
5004
5037
|
(void) DestroyExceptionInfo(&exception);
|
@@ -5120,9 +5153,9 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
|
|
5120
5153
|
volatile VALUE pixel_arg, pixel_ary;
|
5121
5154
|
StorageType stg_type = CharPixel;
|
5122
5155
|
size_t type_sz, map_l;
|
5123
|
-
|
5124
|
-
|
5125
|
-
|
5156
|
+
Quantum *pixels = NULL;
|
5157
|
+
double *fpixels = NULL;
|
5158
|
+
void *buffer;
|
5126
5159
|
unsigned int okay;
|
5127
5160
|
|
5128
5161
|
image = rm_check_frozen(self);
|
@@ -5245,7 +5278,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
|
|
5245
5278
|
}
|
5246
5279
|
|
5247
5280
|
|
5248
|
-
okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type,
|
5281
|
+
okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type, buffer);
|
5249
5282
|
|
5250
5283
|
// Free pixel array before checking for errors.
|
5251
5284
|
if (pixels)
|
@@ -5272,7 +5305,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
|
|
5272
5305
|
Purpose: Overrides Object#inspect - returns a string description of the
|
5273
5306
|
image.
|
5274
5307
|
Returns: the string
|
5275
|
-
Notes: this is essentially the
|
5308
|
+
Notes: this is essentially the IdentifyImage except the description is
|
5276
5309
|
built in a char buffer instead of being written to a file.
|
5277
5310
|
*/
|
5278
5311
|
static void build_inspect_string(Image *image, char *buffer, size_t len)
|
@@ -5363,19 +5396,19 @@ static void build_inspect_string(Image *image, char *buffer, size_t len)
|
|
5363
5396
|
x += sprintf(buffer+x, "%lu-bit", quantum_depth);
|
5364
5397
|
|
5365
5398
|
// Print blob info if appropriate.
|
5366
|
-
if (
|
5399
|
+
if (GetBlobSize(image) != 0)
|
5367
5400
|
{
|
5368
|
-
if (
|
5401
|
+
if (GetBlobSize(image) >= (1 << 24))
|
5369
5402
|
{
|
5370
|
-
x += sprintf(buffer+x, " %lumb", (unsigned long) (
|
5403
|
+
x += sprintf(buffer+x, " %lumb", (unsigned long) (GetBlobSize(image)/1024/1024));
|
5371
5404
|
}
|
5372
|
-
else if (
|
5405
|
+
else if (GetBlobSize(image) >= 1024)
|
5373
5406
|
{
|
5374
|
-
x += sprintf(buffer+x, " %lukb", (unsigned long) (
|
5407
|
+
x += sprintf(buffer+x, " %lukb", (unsigned long) (GetBlobSize(image)/1024));
|
5375
5408
|
}
|
5376
5409
|
else
|
5377
5410
|
{
|
5378
|
-
x += sprintf(buffer+x, " %lub", (unsigned long)
|
5411
|
+
x += sprintf(buffer+x, " %lub", (unsigned long) GetBlobSize(image));
|
5379
5412
|
}
|
5380
5413
|
}
|
5381
5414
|
|
@@ -5484,7 +5517,7 @@ VALUE
|
|
5484
5517
|
Image_level2(int argc, VALUE *argv, VALUE self)
|
5485
5518
|
{
|
5486
5519
|
Image *image, *new_image;
|
5487
|
-
double black_point = 0.0,
|
5520
|
+
double black_point = 0.0, gamma_val = 1.0, white_point = (double)QuantumRange;
|
5488
5521
|
char level[50];
|
5489
5522
|
|
5490
5523
|
image = rm_check_destroyed(self);
|
@@ -5503,7 +5536,7 @@ Image_level2(int argc, VALUE *argv, VALUE self)
|
|
5503
5536
|
case 3:
|
5504
5537
|
black_point = NUM2DBL(argv[0]);
|
5505
5538
|
white_point = NUM2DBL(argv[1]);
|
5506
|
-
|
5539
|
+
gamma_val = NUM2DBL(argv[2]);
|
5507
5540
|
break;
|
5508
5541
|
default:
|
5509
5542
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc);
|
@@ -5512,7 +5545,7 @@ Image_level2(int argc, VALUE *argv, VALUE self)
|
|
5512
5545
|
|
5513
5546
|
new_image = rm_clone_image(image);
|
5514
5547
|
|
5515
|
-
sprintf(level, "%gx%g+%g", black_point, white_point,
|
5548
|
+
sprintf(level, "%gx%g+%g", black_point, white_point, gamma_val);
|
5516
5549
|
(void) LevelImage(new_image, level);
|
5517
5550
|
rm_check_image_exception(new_image, DestroyOnError);
|
5518
5551
|
|
@@ -5528,7 +5561,7 @@ VALUE
|
|
5528
5561
|
Image_level_channel(int argc, VALUE *argv, VALUE self)
|
5529
5562
|
{
|
5530
5563
|
Image *image, *new_image;
|
5531
|
-
double black_point = 0.0,
|
5564
|
+
double black_point = 0.0, gamma_val = 1.0, white_point = (double)QuantumRange;
|
5532
5565
|
ChannelType channel;
|
5533
5566
|
|
5534
5567
|
image = rm_check_destroyed(self);
|
@@ -5547,7 +5580,7 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
|
|
5547
5580
|
case 4:
|
5548
5581
|
black_point = NUM2DBL(argv[1]);
|
5549
5582
|
white_point = NUM2DBL(argv[2]);
|
5550
|
-
|
5583
|
+
gamma_val = NUM2DBL(argv[3]);
|
5551
5584
|
break;
|
5552
5585
|
default:
|
5553
5586
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc);
|
@@ -5558,7 +5591,7 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
|
|
5558
5591
|
|
5559
5592
|
new_image = rm_clone_image(image);
|
5560
5593
|
|
5561
|
-
(void) LevelImageChannel(new_image, channel, black_point, white_point,
|
5594
|
+
(void) LevelImageChannel(new_image, channel, black_point, white_point, gamma_val);
|
5562
5595
|
rm_check_image_exception(new_image, DestroyOnError);
|
5563
5596
|
|
5564
5597
|
return rm_image_new(new_image);
|
@@ -6009,7 +6042,7 @@ Image_matte_color_eq(VALUE self, VALUE color)
|
|
6009
6042
|
}
|
6010
6043
|
|
6011
6044
|
/*
|
6012
|
-
Method: Image#matte_flood_fill(color, opacity, x, y,
|
6045
|
+
Method: Image#matte_flood_fill(color, opacity, x, y, method_obj)
|
6013
6046
|
Purpose: Call MatteFloodFillImage
|
6014
6047
|
*/
|
6015
6048
|
VALUE
|
@@ -6019,24 +6052,24 @@ Image_matte_flood_fill(
|
|
6019
6052
|
VALUE opacity,
|
6020
6053
|
VALUE x_obj,
|
6021
6054
|
VALUE y_obj,
|
6022
|
-
VALUE
|
6055
|
+
VALUE method_obj)
|
6023
6056
|
{
|
6024
6057
|
Image *image, *new_image;
|
6025
6058
|
PixelPacket target;
|
6026
6059
|
Quantum op;
|
6027
6060
|
long x, y;
|
6028
|
-
PaintMethod
|
6061
|
+
PaintMethod method;
|
6029
6062
|
|
6030
6063
|
image = rm_check_destroyed(self);
|
6031
6064
|
Color_to_PixelPacket(&target, color);
|
6032
6065
|
|
6033
6066
|
op = APP2QUANTUM(opacity);
|
6034
6067
|
|
6035
|
-
VALUE_TO_ENUM(
|
6036
|
-
if (!(
|
6068
|
+
VALUE_TO_ENUM(method_obj, method, PaintMethod);
|
6069
|
+
if (!(method == FloodfillMethod || method == FillToBorderMethod))
|
6037
6070
|
{
|
6038
|
-
rb_raise(rb_eArgError, "paint
|
6039
|
-
"FillToBorderMethod (%d given)",
|
6071
|
+
rb_raise(rb_eArgError, "paint method_obj must be FloodfillMethod or "
|
6072
|
+
"FillToBorderMethod (%d given)", method);
|
6040
6073
|
}
|
6041
6074
|
x = NUM2LONG(x_obj);
|
6042
6075
|
y = NUM2LONG(y_obj);
|
@@ -6049,7 +6082,40 @@ Image_matte_flood_fill(
|
|
6049
6082
|
|
6050
6083
|
new_image = rm_clone_image(image);
|
6051
6084
|
|
6052
|
-
|
6085
|
+
#if defined(HAVE_FLOODFILLPAINTIMAGE)
|
6086
|
+
{
|
6087
|
+
DrawInfo *draw_info;
|
6088
|
+
MagickPixelPacket target_mpp;
|
6089
|
+
MagickBooleanType invert;
|
6090
|
+
|
6091
|
+
// FloodfillPaintImage looks for the opacity in the DrawInfo.fill field.
|
6092
|
+
draw_info = CloneDrawInfo(NULL, NULL);
|
6093
|
+
if (!draw_info)
|
6094
|
+
{
|
6095
|
+
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
6096
|
+
}
|
6097
|
+
draw_info->fill.opacity = op;
|
6098
|
+
|
6099
|
+
if (method == FillToBorderMethod)
|
6100
|
+
{
|
6101
|
+
invert = MagickTrue;
|
6102
|
+
target_mpp.red = (MagickRealType) image->border_color.red;
|
6103
|
+
target_mpp.green = (MagickRealType) image->border_color.green;
|
6104
|
+
target_mpp.blue = (MagickRealType) image->border_color.blue;
|
6105
|
+
}
|
6106
|
+
else
|
6107
|
+
{
|
6108
|
+
invert = MagickFalse;
|
6109
|
+
target_mpp.red = (MagickRealType) target.red;
|
6110
|
+
target_mpp.green = (MagickRealType) target.green;
|
6111
|
+
target_mpp.blue = (MagickRealType) target.blue;
|
6112
|
+
}
|
6113
|
+
|
6114
|
+
(void) FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert);
|
6115
|
+
}
|
6116
|
+
#else
|
6117
|
+
(void) MatteFloodfillImage(new_image, target, op, x, y, method);
|
6118
|
+
#endif
|
6053
6119
|
rm_check_image_exception(new_image, DestroyOnError);
|
6054
6120
|
|
6055
6121
|
return rm_image_new(new_image);
|
@@ -6429,9 +6495,9 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
|
|
6429
6495
|
|
6430
6496
|
SetImageExtent(image, cols, rows);
|
6431
6497
|
|
6432
|
-
// If the caller did not supply a fill argument, call
|
6433
|
-
// image using the background color. The background color can
|
6434
|
-
// specifying it when creating the Info parm block.
|
6498
|
+
// If the caller did not supply a fill argument, call SetImageBackgroundColor
|
6499
|
+
// to fill the image using the background color. The background color can
|
6500
|
+
// be set by specifying it when creating the Info parm block.
|
6435
6501
|
if (!fill)
|
6436
6502
|
{
|
6437
6503
|
(void) SetImageBackgroundColor(image);
|
@@ -6853,7 +6919,7 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
|
|
6853
6919
|
keep = new_image->fuzz;
|
6854
6920
|
new_image->fuzz = fuzz;
|
6855
6921
|
|
6856
|
-
okay = TransparentPaintImage(new_image, &color, opacity, invert);
|
6922
|
+
okay = TransparentPaintImage(new_image, (const MagickPixelPacket *)&color, opacity, invert);
|
6857
6923
|
new_image->fuzz = keep;
|
6858
6924
|
|
6859
6925
|
// Is it possible for TransparentPaintImage to silently fail?
|
@@ -7759,7 +7825,7 @@ static VALUE
|
|
7759
7825
|
resize(int bang, int argc, VALUE *argv, VALUE self)
|
7760
7826
|
{
|
7761
7827
|
Image *image, *new_image;
|
7762
|
-
double
|
7828
|
+
double scale_arg;
|
7763
7829
|
FilterTypes filter;
|
7764
7830
|
unsigned long rows, columns;
|
7765
7831
|
double blur, drows, dcols;
|
@@ -7788,13 +7854,13 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
|
|
7788
7854
|
}
|
7789
7855
|
break;
|
7790
7856
|
case 1:
|
7791
|
-
|
7792
|
-
if (
|
7857
|
+
scale_arg = NUM2DBL(argv[0]);
|
7858
|
+
if (scale_arg < 0.0)
|
7793
7859
|
{
|
7794
|
-
rb_raise(rb_eArgError, "invalid
|
7860
|
+
rb_raise(rb_eArgError, "invalid scale_arg value (%g given)", scale_arg);
|
7795
7861
|
}
|
7796
|
-
drows =
|
7797
|
-
dcols =
|
7862
|
+
drows = scale_arg * image->rows + 0.5;
|
7863
|
+
dcols = scale_arg * image->columns + 0.5;
|
7798
7864
|
if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
|
7799
7865
|
{
|
7800
7866
|
rb_raise(rb_eRangeError, "resized image too big");
|
@@ -7993,7 +8059,7 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
|
|
7993
8059
|
{
|
7994
8060
|
Image *image, *new_image;
|
7995
8061
|
unsigned long columns, rows;
|
7996
|
-
double
|
8062
|
+
double scale_arg, drows, dcols;
|
7997
8063
|
ExceptionInfo exception;
|
7998
8064
|
|
7999
8065
|
Data_Get_Struct(self, Image, image);
|
@@ -8009,13 +8075,13 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
|
|
8009
8075
|
}
|
8010
8076
|
break;
|
8011
8077
|
case 1:
|
8012
|
-
|
8013
|
-
if (
|
8078
|
+
scale_arg = NUM2DBL(argv[0]);
|
8079
|
+
if (scale_arg <= 0)
|
8014
8080
|
{
|
8015
|
-
rb_raise(rb_eArgError, "invalid scale value (%g given)",
|
8081
|
+
rb_raise(rb_eArgError, "invalid scale value (%g given)", scale_arg);
|
8016
8082
|
}
|
8017
|
-
drows =
|
8018
|
-
dcols =
|
8083
|
+
drows = scale_arg * image->rows + 0.5;
|
8084
|
+
dcols = scale_arg * image->columns + 0.5;
|
8019
8085
|
if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
|
8020
8086
|
{
|
8021
8087
|
rb_raise(rb_eRangeError, "resized image too big");
|
@@ -8723,14 +8789,14 @@ VALUE
|
|
8723
8789
|
Image_spread(int argc, VALUE *argv, VALUE self)
|
8724
8790
|
{
|
8725
8791
|
Image *image, *new_image;
|
8726
|
-
|
8792
|
+
double radius = 3.0;
|
8727
8793
|
ExceptionInfo exception;
|
8728
8794
|
|
8729
8795
|
image = rm_check_destroyed(self);
|
8730
8796
|
switch (argc)
|
8731
8797
|
{
|
8732
8798
|
case 1:
|
8733
|
-
radius =
|
8799
|
+
radius = NUM2DBL(argv[0]);
|
8734
8800
|
case 0:
|
8735
8801
|
break;
|
8736
8802
|
default:
|
@@ -9059,16 +9125,34 @@ Image_texture_flood_fill(
|
|
9059
9125
|
draw_info->fill_pattern = rm_clone_image(texture_image);
|
9060
9126
|
new_image = rm_clone_image(image);
|
9061
9127
|
|
9062
|
-
|
9063
|
-
|
9128
|
+
|
9129
|
+
#if defined(HAVE_FLOODFILLPAINTIMAGE)
|
9130
|
+
{
|
9131
|
+
MagickPixelPacket color_mpp;
|
9132
|
+
MagickBooleanType invert;
|
9133
|
+
|
9134
|
+
GetMagickPixelPacket(new_image, &color_mpp);
|
9064
9135
|
if (method == FillToBorderMethod)
|
9065
9136
|
{
|
9066
|
-
|
9067
|
-
|
9068
|
-
|
9137
|
+
invert = MagickTrue;
|
9138
|
+
color_mpp.red = (MagickRealType) image->border_color.red;
|
9139
|
+
color_mpp.green = (MagickRealType) image->border_color.green;
|
9140
|
+
color_mpp.blue = (MagickRealType) image->border_color.blue;
|
9141
|
+
}
|
9142
|
+
else
|
9143
|
+
{
|
9144
|
+
invert = MagickFalse;
|
9145
|
+
color_mpp.red = (MagickRealType) color.red;
|
9146
|
+
color_mpp.green = (MagickRealType) color.green;
|
9147
|
+
color_mpp.blue = (MagickRealType) color.blue;
|
9069
9148
|
}
|
9070
9149
|
|
9150
|
+
(void) FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert);
|
9151
|
+
}
|
9152
|
+
|
9153
|
+
#else
|
9071
9154
|
(void) ColorFloodfillImage(new_image, draw_info, color, x, y, method);
|
9155
|
+
#endif
|
9072
9156
|
|
9073
9157
|
(void) DestroyDrawInfo(draw_info);
|
9074
9158
|
rm_check_image_exception(new_image, DestroyOnError);
|
@@ -9164,7 +9248,7 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
|
|
9164
9248
|
{
|
9165
9249
|
Image *image, *new_image;
|
9166
9250
|
unsigned long columns, rows;
|
9167
|
-
double
|
9251
|
+
double scale_arg, drows, dcols;
|
9168
9252
|
ExceptionInfo exception;
|
9169
9253
|
|
9170
9254
|
Data_Get_Struct(self, Image, image);
|
@@ -9180,13 +9264,13 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
|
|
9180
9264
|
}
|
9181
9265
|
break;
|
9182
9266
|
case 1:
|
9183
|
-
|
9184
|
-
if (
|
9267
|
+
scale_arg = NUM2DBL(argv[0]);
|
9268
|
+
if (scale_arg < 0.0)
|
9185
9269
|
{
|
9186
|
-
rb_raise(rb_eArgError, "invalid scale value (%g given)",
|
9270
|
+
rb_raise(rb_eArgError, "invalid scale value (%g given)", scale_arg);
|
9187
9271
|
}
|
9188
|
-
drows =
|
9189
|
-
dcols =
|
9272
|
+
drows = scale_arg * image->rows + 0.5;
|
9273
|
+
dcols = scale_arg * image->columns + 0.5;
|
9190
9274
|
if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX)
|
9191
9275
|
{
|
9192
9276
|
rb_raise(rb_eRangeError, "resized image too big");
|
@@ -9450,7 +9534,7 @@ Image_total_colors(VALUE self)
|
|
9450
9534
|
/*
|
9451
9535
|
Method: Image#transparent(color-name<, opacity>)
|
9452
9536
|
Image#transparent(pixel<, opacity>)
|
9453
|
-
Purpose: Call
|
9537
|
+
Purpose: Call TransparentPaintImage
|
9454
9538
|
Notes: Can use Magick::OpaqueOpacity or Magick::TransparentOpacity,
|
9455
9539
|
or any value >= 0 && <= QuantumRange. The default is
|
9456
9540
|
Magick::TransparentOpacity.
|
@@ -9573,7 +9657,6 @@ static VALUE
|
|
9573
9657
|
trimmer(int bang, int argc, VALUE *argv, VALUE self)
|
9574
9658
|
{
|
9575
9659
|
Image *image, *new_image;
|
9576
|
-
RectangleInfo geometry;
|
9577
9660
|
ExceptionInfo exception;
|
9578
9661
|
int reset_page = 0;
|
9579
9662
|
|
@@ -9591,11 +9674,7 @@ trimmer(int bang, int argc, VALUE *argv, VALUE self)
|
|
9591
9674
|
Data_Get_Struct(self, Image, image);
|
9592
9675
|
|
9593
9676
|
GetExceptionInfo(&exception);
|
9594
|
-
|
9595
|
-
geometry = GetImageBoundingBox(image, &exception);
|
9596
|
-
CHECK_EXCEPTION()
|
9597
|
-
|
9598
|
-
new_image = CropImage(image, &geometry, &exception);
|
9677
|
+
new_image = TrimImage(image, &exception);
|
9599
9678
|
rm_check_exception(&exception, new_image, DestroyOnError);
|
9600
9679
|
|
9601
9680
|
(void) DestroyExceptionInfo(&exception);
|
@@ -9658,8 +9737,8 @@ VALUE Image_gravity_eq(VALUE self, VALUE gravity)
|
|
9658
9737
|
|
9659
9738
|
|
9660
9739
|
/*
|
9661
|
-
Method: Image#image_type
|
9662
|
-
Purpose: Call GetImageType to get the image type
|
9740
|
+
Method: Image#image_type, image_type=
|
9741
|
+
Purpose: Call GetImageType/SetImageType to get/set the image type
|
9663
9742
|
*/
|
9664
9743
|
VALUE Image_image_type(VALUE self)
|
9665
9744
|
{
|
@@ -9678,6 +9757,18 @@ VALUE Image_image_type(VALUE self)
|
|
9678
9757
|
}
|
9679
9758
|
|
9680
9759
|
|
9760
|
+
VALUE Image_image_type_eq(VALUE self, VALUE image_type)
|
9761
|
+
{
|
9762
|
+
Image *image;
|
9763
|
+
ImageType type;
|
9764
|
+
|
9765
|
+
image = rm_check_frozen(self);
|
9766
|
+
VALUE_TO_ENUM(image_type, type, ImageType);
|
9767
|
+
SetImageType(image, type);
|
9768
|
+
return image_type;
|
9769
|
+
}
|
9770
|
+
|
9771
|
+
|
9681
9772
|
/*
|
9682
9773
|
Method: Image#unique_colors
|
9683
9774
|
Purpose: Call UniqueImageColors
|
@@ -10072,13 +10163,14 @@ VALUE
|
|
10072
10163
|
Image_wet_floor(int argc, VALUE *argv, VALUE self)
|
10073
10164
|
{
|
10074
10165
|
Image *image, *reflection, *flip_image;
|
10075
|
-
PixelPacket *p
|
10166
|
+
const PixelPacket *p;
|
10167
|
+
PixelPacket *q;
|
10076
10168
|
RectangleInfo geometry;
|
10077
10169
|
long x, y, max_rows;
|
10078
10170
|
double initial = 0.5;
|
10079
10171
|
double rate = 1.0;
|
10080
10172
|
double opacity, step;
|
10081
|
-
char *func;
|
10173
|
+
const char *func;
|
10082
10174
|
MagickBooleanType okay;
|
10083
10175
|
ExceptionInfo exception;
|
10084
10176
|
|
@@ -10151,7 +10243,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
|
|
10151
10243
|
opacity = TransparentOpacity;
|
10152
10244
|
}
|
10153
10245
|
|
10154
|
-
p =
|
10246
|
+
p = AcquireImagePixels(reflection, 0, y, image->columns, 1, &exception);
|
10155
10247
|
rm_check_exception(&exception, reflection, RetainOnError);
|
10156
10248
|
|
10157
10249
|
q = SetImagePixels(reflection, 0, y, image->columns, 1);
|
@@ -10296,7 +10388,7 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
|
|
10296
10388
|
unsigned long columns, rows;
|
10297
10389
|
int reset_page = 0;
|
10298
10390
|
GravityType gravity;
|
10299
|
-
MagickEnum *
|
10391
|
+
MagickEnum *m_enum;
|
10300
10392
|
Image *image;
|
10301
10393
|
VALUE cropped;
|
10302
10394
|
|
@@ -10367,8 +10459,8 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
|
|
10367
10459
|
// Don't let these run into the default case
|
10368
10460
|
break;
|
10369
10461
|
default:
|
10370
|
-
Data_Get_Struct(argv[0], MagickEnum,
|
10371
|
-
rb_warning("gravity type `%s' has no effect", rb_id2name(
|
10462
|
+
Data_Get_Struct(argv[0], MagickEnum, m_enum);
|
10463
|
+
rb_warning("gravity type `%s' has no effect", rb_id2name(m_enum->id));
|
10372
10464
|
break;
|
10373
10465
|
}
|
10374
10466
|
|
@@ -10575,10 +10667,10 @@ raise_ChannelType_error(VALUE arg)
|
|
10575
10667
|
Purpose: If Magick.trace_proc is not nil, build an argument
|
10576
10668
|
list and call the proc.
|
10577
10669
|
*/
|
10578
|
-
static void call_trace_proc(Image *image, char *which)
|
10670
|
+
static void call_trace_proc(Image *image, const char *which)
|
10579
10671
|
{
|
10580
10672
|
volatile VALUE trace;
|
10581
|
-
|
10673
|
+
VALUE trace_args[4];
|
10582
10674
|
|
10583
10675
|
if (rb_ivar_defined(Module_Magick, rm_ID_trace_proc) == Qtrue)
|
10584
10676
|
{
|