rmagick 2.8.0 → 2.9.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 +10 -2
- data/README.html +7 -7
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +5 -5
- data/doc/draw.html +131 -20
- data/doc/ex/InitialCoords.rb +1 -1
- data/doc/ex/NewCoordSys.rb +2 -2
- data/doc/ex/OrigCoordSys.rb +1 -1
- data/doc/ex/RotateScale.rb +2 -2
- data/doc/ex/Skew.rb +2 -2
- data/doc/ex/ViewBox.rb +1 -1
- data/doc/ex/arc.rb +4 -2
- data/doc/ex/arcs02.rb +1 -1
- data/doc/ex/bounding_box.rb +3 -0
- data/doc/ex/cbezier1.rb +2 -0
- data/doc/ex/cbezier2.rb +2 -0
- data/doc/ex/cbezier3.rb +2 -0
- data/doc/ex/cbezier4.rb +2 -0
- data/doc/ex/cbezier5.rb +2 -0
- data/doc/ex/cbezier6.rb +2 -0
- data/doc/ex/channel.rb +1 -0
- data/doc/ex/circle.rb +2 -0
- data/doc/ex/cubic01.rb +1 -1
- data/doc/ex/cubic02.rb +1 -1
- data/doc/ex/ellipse.rb +2 -0
- data/doc/ex/font_styles.rb +12 -10
- data/doc/ex/get_type_metrics.rb +2 -0
- data/doc/ex/grav.rb +2 -0
- data/doc/ex/image.rb +1 -1
- data/doc/ex/line.rb +2 -0
- data/doc/ex/opacity.rb +6 -4
- data/doc/ex/path.rb +2 -0
- data/doc/ex/polaroid.rb +2 -0
- data/doc/ex/qbezierpath.rb +3 -0
- data/doc/ex/rectangle.rb +2 -0
- data/doc/ex/rotate.rb +2 -0
- data/doc/ex/roundrect.rb +2 -0
- data/doc/ex/skewx.rb +2 -0
- data/doc/ex/skewy.rb +2 -0
- data/doc/ex/stroke_dasharray.rb +2 -0
- data/doc/ex/stroke_width.rb +2 -0
- data/doc/ex/text.rb +3 -2
- data/doc/ex/text01.rb +1 -1
- data/doc/ex/text_styles.rb +1 -1
- data/doc/ex/text_undercolor.rb +2 -0
- data/doc/ex/translate.rb +3 -1
- data/doc/ilist.html +2 -2
- data/doc/image1.html +2 -2
- data/doc/image2.html +2 -2
- data/doc/image3.html +37 -6
- data/doc/imageattrs.html +2 -2
- data/doc/imusage.html +3 -3
- data/doc/index.html +3 -3
- data/doc/info.html +2 -2
- data/doc/magick.html +2 -2
- data/doc/optequiv.html +24 -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 +2 -2
- data/doc/usage.html +6 -4
- data/ext/RMagick/MANIFEST +6 -1
- data/ext/RMagick/extconf.rb +18 -2
- data/ext/RMagick/rmagick.c +312 -0
- data/ext/RMagick/rmagick.h +137 -61
- data/ext/RMagick/rmdraw.c +271 -377
- data/ext/RMagick/rmenum.c +1016 -0
- data/ext/RMagick/rmimage.c +172 -16
- data/ext/RMagick/rminfo.c +5 -5
- data/ext/RMagick/rmmain.c +50 -303
- data/ext/RMagick/rmmontage.c +386 -0
- data/ext/RMagick/rmpixel.c +816 -0
- data/ext/RMagick/rmstruct.c +887 -0
- data/ext/RMagick/rmutil.c +25 -2634
- data/lib/RMagick.rb +46 -2
- data/lib/rvg/misc.rb +5 -4
- data/lib/rvg/stylable.rb +7 -1
- data/rmagick.gemspec +1 -1
- metadata +7 -2
data/ext/RMagick/rmimage.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmimage.c,v 1.
|
1
|
+
/* $Id: rmimage.c,v 1.343 2009/01/12 23:08:35 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmimage.c
|
@@ -584,7 +584,7 @@ Image_affine_transform(VALUE self, VALUE affine)
|
|
584
584
|
image = rm_check_destroyed(self);
|
585
585
|
|
586
586
|
// Convert Magick::AffineMatrix to AffineMatrix structure.
|
587
|
-
|
587
|
+
Export_AffineMatrix(&matrix, affine);
|
588
588
|
|
589
589
|
GetExceptionInfo(&exception);
|
590
590
|
new_image = AffineTransformImage(image, &matrix, &exception);
|
@@ -829,7 +829,7 @@ VALUE
|
|
829
829
|
Image_background_color(VALUE self)
|
830
830
|
{
|
831
831
|
Image *image = rm_check_destroyed(self);
|
832
|
-
return
|
832
|
+
return rm_pixelpacket_to_color_name(image, &image->background_color);
|
833
833
|
}
|
834
834
|
|
835
835
|
|
@@ -1438,7 +1438,7 @@ VALUE
|
|
1438
1438
|
Image_border_color(VALUE self)
|
1439
1439
|
{
|
1440
1440
|
Image *image = rm_check_destroyed(self);
|
1441
|
-
return
|
1441
|
+
return rm_pixelpacket_to_color_name(image, &image->border_color);
|
1442
1442
|
}
|
1443
1443
|
|
1444
1444
|
|
@@ -1473,7 +1473,7 @@ Image_bounding_box(VALUE self)
|
|
1473
1473
|
|
1474
1474
|
(void) DestroyExceptionInfo(&exception);
|
1475
1475
|
|
1476
|
-
return
|
1476
|
+
return Import_RectangleInfo(&box);
|
1477
1477
|
}
|
1478
1478
|
|
1479
1479
|
|
@@ -1787,7 +1787,7 @@ VALUE
|
|
1787
1787
|
Image_chromaticity_eq(VALUE self, VALUE chroma)
|
1788
1788
|
{
|
1789
1789
|
Image *image = rm_check_frozen(self);
|
1790
|
-
|
1790
|
+
Export_ChromaticityInfo(&image->chromaticity, chroma);
|
1791
1791
|
return self;
|
1792
1792
|
}
|
1793
1793
|
|
@@ -2217,7 +2217,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2217
2217
|
{
|
2218
2218
|
rb_raise(rb_eIndexError, "index out of range");
|
2219
2219
|
}
|
2220
|
-
return
|
2220
|
+
return rm_pixelpacket_to_color_name(image, &image->colormap[idx]);
|
2221
2221
|
}
|
2222
2222
|
|
2223
2223
|
// This is a "set" operation. Things are different.
|
@@ -2257,7 +2257,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
|
|
2257
2257
|
color = image->colormap[idx];
|
2258
2258
|
image->colormap[idx] = new_color;
|
2259
2259
|
|
2260
|
-
return
|
2260
|
+
return rm_pixelpacket_to_color_name(image, &color);
|
2261
2261
|
}
|
2262
2262
|
|
2263
2263
|
DEF_ATTR_READER(Image, colors, ulong)
|
@@ -2661,7 +2661,7 @@ Image_composite_affine(VALUE self, VALUE source, VALUE affine_matrix)
|
|
2661
2661
|
composite_image = rm_check_destroyed(source);
|
2662
2662
|
new_image = rm_clone_image(image);
|
2663
2663
|
|
2664
|
-
|
2664
|
+
Export_AffineMatrix(&affine, affine_matrix);
|
2665
2665
|
(void) DrawAffineImage(new_image, composite_image, &affine);
|
2666
2666
|
rm_check_image_exception(new_image, DestroyOnError);
|
2667
2667
|
|
@@ -4051,7 +4051,9 @@ Image__dump(VALUE self, VALUE depth)
|
|
4051
4051
|
|
4052
4052
|
// Concatenate the blob onto the header & return the result
|
4053
4053
|
str = rb_str_new((char *)&mi, (long)(mi.len+offsetof(DumpedImage,magick)));
|
4054
|
-
|
4054
|
+
str = rb_str_buf_cat(str, (char *)blob, (long)length);
|
4055
|
+
magick_free((void*)blob);
|
4056
|
+
return str;
|
4055
4057
|
}
|
4056
4058
|
|
4057
4059
|
|
@@ -4702,7 +4704,7 @@ VALUE
|
|
4702
4704
|
Image_extract_info(VALUE self)
|
4703
4705
|
{
|
4704
4706
|
Image *image = rm_check_destroyed(self);
|
4705
|
-
return
|
4707
|
+
return Import_RectangleInfo(&image->extract_info);
|
4706
4708
|
}
|
4707
4709
|
|
4708
4710
|
|
@@ -4710,7 +4712,7 @@ VALUE
|
|
4710
4712
|
Image_extract_info_eq(VALUE self, VALUE rect)
|
4711
4713
|
{
|
4712
4714
|
Image *image = rm_check_frozen(self);
|
4713
|
-
|
4715
|
+
Export_RectangleInfo(&image->extract_info, rect);
|
4714
4716
|
return self;
|
4715
4717
|
}
|
4716
4718
|
|
@@ -6255,6 +6257,94 @@ Image_map(int argc, VALUE *argv, VALUE self)
|
|
6255
6257
|
}
|
6256
6258
|
|
6257
6259
|
|
6260
|
+
/*
|
6261
|
+
Method: Image#marshal_dump
|
6262
|
+
Purpose: Support Marshal.dump >= 1.8
|
6263
|
+
Returns: [img.filename, img.to_blob]
|
6264
|
+
*/
|
6265
|
+
VALUE
|
6266
|
+
Image_marshal_dump(VALUE self)
|
6267
|
+
{
|
6268
|
+
Image *image;
|
6269
|
+
Info *info;
|
6270
|
+
unsigned char *blob;
|
6271
|
+
size_t length;
|
6272
|
+
VALUE ary;
|
6273
|
+
ExceptionInfo exception;
|
6274
|
+
|
6275
|
+
image = rm_check_destroyed(self);
|
6276
|
+
|
6277
|
+
info = CloneImageInfo(NULL);
|
6278
|
+
if (!info)
|
6279
|
+
{
|
6280
|
+
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
6281
|
+
}
|
6282
|
+
|
6283
|
+
ary = rb_ary_new2(2);
|
6284
|
+
if (image->filename)
|
6285
|
+
{
|
6286
|
+
rb_ary_store(ary, 0, rb_str_new2(image->filename));
|
6287
|
+
}
|
6288
|
+
else
|
6289
|
+
{
|
6290
|
+
rb_ary_store(ary, 0, Qnil);
|
6291
|
+
}
|
6292
|
+
|
6293
|
+
GetExceptionInfo(&exception);
|
6294
|
+
blob = ImageToBlob(info, image, &length, &exception);
|
6295
|
+
|
6296
|
+
// Destroy info before raising an exception
|
6297
|
+
DestroyImageInfo(info);
|
6298
|
+
CHECK_EXCEPTION()
|
6299
|
+
(void) DestroyExceptionInfo(&exception);
|
6300
|
+
|
6301
|
+
rb_ary_store(ary, 1, rb_str_new((char *)blob, (long)length));
|
6302
|
+
magick_free((void*)blob);
|
6303
|
+
|
6304
|
+
return ary;
|
6305
|
+
}
|
6306
|
+
|
6307
|
+
|
6308
|
+
/*
|
6309
|
+
Method: Image#marshal_load
|
6310
|
+
Purpose: Support Marshal.load >= 1.8
|
6311
|
+
Notes: On entry, ary is the array returned from marshal_dump.
|
6312
|
+
*/
|
6313
|
+
VALUE
|
6314
|
+
Image_marshal_load(VALUE self, VALUE ary)
|
6315
|
+
{
|
6316
|
+
VALUE blob, filename;
|
6317
|
+
Info *info;
|
6318
|
+
Image *image;
|
6319
|
+
ExceptionInfo exception;
|
6320
|
+
|
6321
|
+
info = CloneImageInfo(NULL);
|
6322
|
+
if (!info)
|
6323
|
+
{
|
6324
|
+
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
6325
|
+
}
|
6326
|
+
|
6327
|
+
filename = rb_ary_shift(ary);
|
6328
|
+
blob = rb_ary_shift(ary);
|
6329
|
+
|
6330
|
+
GetExceptionInfo(&exception);
|
6331
|
+
if (filename != Qnil)
|
6332
|
+
{
|
6333
|
+
strcpy(info->filename, RSTRING_PTR(filename));
|
6334
|
+
}
|
6335
|
+
image = BlobToImage(info, RSTRING_PTR(blob), RSTRING_LEN(blob), &exception);
|
6336
|
+
|
6337
|
+
// Destroy info before raising an exception
|
6338
|
+
DestroyImageInfo(info);
|
6339
|
+
CHECK_EXCEPTION();
|
6340
|
+
(void) DestroyExceptionInfo(&exception);
|
6341
|
+
|
6342
|
+
UPDATE_DATA_PTR(self, image);
|
6343
|
+
|
6344
|
+
return self;
|
6345
|
+
}
|
6346
|
+
|
6347
|
+
|
6258
6348
|
/*
|
6259
6349
|
Static: get_image_mask
|
6260
6350
|
Purpose: Return the image's clip mask, or nil if it doesn't have a clip
|
@@ -6441,7 +6531,7 @@ VALUE
|
|
6441
6531
|
Image_matte_color(VALUE self)
|
6442
6532
|
{
|
6443
6533
|
Image *image = rm_check_destroyed(self);
|
6444
|
-
return
|
6534
|
+
return rm_pixelpacket_to_color_name(image, &image->matte_color);
|
6445
6535
|
}
|
6446
6536
|
|
6447
6537
|
/*
|
@@ -7281,7 +7371,7 @@ VALUE
|
|
7281
7371
|
Image_page(VALUE self)
|
7282
7372
|
{
|
7283
7373
|
Image *image = rm_check_destroyed(self);
|
7284
|
-
return
|
7374
|
+
return Import_RectangleInfo(&image->page);
|
7285
7375
|
}
|
7286
7376
|
|
7287
7377
|
|
@@ -7293,7 +7383,7 @@ VALUE
|
|
7293
7383
|
Image_page_eq(VALUE self, VALUE rect)
|
7294
7384
|
{
|
7295
7385
|
Image *image = rm_check_frozen(self);
|
7296
|
-
|
7386
|
+
Export_RectangleInfo(&image->page, rect);
|
7297
7387
|
return self;
|
7298
7388
|
}
|
7299
7389
|
|
@@ -7763,6 +7853,71 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
|
|
7763
7853
|
case PowQuantumOperator:
|
7764
7854
|
qop = PowEvaluateOperator;
|
7765
7855
|
break;
|
7856
|
+
#endif
|
7857
|
+
#if defined(HAVE_ENUM_LOGEVALUATEOPERATOR)
|
7858
|
+
case LogQuantumOperator:
|
7859
|
+
qop = LogEvaluateOperator;
|
7860
|
+
break;
|
7861
|
+
#endif
|
7862
|
+
#if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR)
|
7863
|
+
case ThresholdQuantumOperator:
|
7864
|
+
qop = ThresholdEvaluateOperator;
|
7865
|
+
break;
|
7866
|
+
#endif
|
7867
|
+
#if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR)
|
7868
|
+
case ThresholdBlackQuantumOperator:
|
7869
|
+
qop = ThresholdBlackEvaluateOperator;
|
7870
|
+
break;
|
7871
|
+
#endif
|
7872
|
+
#if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR)
|
7873
|
+
case ThresholdWhiteQuantumOperator:
|
7874
|
+
qop = ThresholdWhiteEvaluateOperator;
|
7875
|
+
break;
|
7876
|
+
#endif
|
7877
|
+
#if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR)
|
7878
|
+
case GaussianNoiseQuantumOperator:
|
7879
|
+
qop = GaussianNoiseEvaluateOperator;
|
7880
|
+
break;
|
7881
|
+
#endif
|
7882
|
+
#if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR)
|
7883
|
+
case ImpulseNoiseQuantumOperator:
|
7884
|
+
qop = ImpulseNoiseEvaluateOperator;
|
7885
|
+
break;
|
7886
|
+
#endif
|
7887
|
+
#if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR)
|
7888
|
+
case LaplacianNoiseQuantumOperator:
|
7889
|
+
qop = LaplacianNoiseEvaluateOperator;
|
7890
|
+
break;
|
7891
|
+
#endif
|
7892
|
+
#if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR)
|
7893
|
+
case MultiplicativeNoiseQuantumOperator:
|
7894
|
+
qop = MultiplicativeNoiseEvaluateOperator;
|
7895
|
+
break;
|
7896
|
+
#endif
|
7897
|
+
#if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR)
|
7898
|
+
case PoissonNoiseQuantumOperator:
|
7899
|
+
qop = PoissonNoiseEvaluateOperator;
|
7900
|
+
break;
|
7901
|
+
#endif
|
7902
|
+
#if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR)
|
7903
|
+
case UniformNoiseQuantumOperator:
|
7904
|
+
qop = UniformNoiseEvaluateOperator;
|
7905
|
+
break;
|
7906
|
+
#endif
|
7907
|
+
#if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR)
|
7908
|
+
case CosineQuantumOperator:
|
7909
|
+
qop = CosineEvaluateOperator;
|
7910
|
+
break;
|
7911
|
+
#endif
|
7912
|
+
#if defined(HAVE_ENUM_SINEEVALUATEOPERATOR)
|
7913
|
+
case SineQuantumOperator:
|
7914
|
+
qop = SineEvaluateOperator;
|
7915
|
+
break;
|
7916
|
+
#endif
|
7917
|
+
#if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR)
|
7918
|
+
case AddModulusQuantumOperator:
|
7919
|
+
qop = AddModulusEvaluateOperator;
|
7920
|
+
break;
|
7766
7921
|
#endif
|
7767
7922
|
}
|
7768
7923
|
|
@@ -10262,6 +10417,7 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
|
|
10262
10417
|
return rm_image_new(new_image);
|
10263
10418
|
#else
|
10264
10419
|
rm_not_implemented();
|
10420
|
+
return (VALUE)0;
|
10265
10421
|
argc = argc;
|
10266
10422
|
argv = argv;
|
10267
10423
|
self = self;
|
@@ -10277,7 +10433,7 @@ VALUE
|
|
10277
10433
|
Image_transparent_color(VALUE self)
|
10278
10434
|
{
|
10279
10435
|
Image *image = rm_check_destroyed(self);
|
10280
|
-
return
|
10436
|
+
return rm_pixelpacket_to_color_name(image, &image->transparent_color);
|
10281
10437
|
}
|
10282
10438
|
|
10283
10439
|
|
data/ext/RMagick/rminfo.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rminfo.c,v 1.
|
1
|
+
/* $Id: rminfo.c,v 1.75 2009/01/01 23:36:00 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rminfo.c
|
@@ -380,7 +380,7 @@ Info_background_color(VALUE self)
|
|
380
380
|
Info *info;
|
381
381
|
|
382
382
|
Data_Get_Struct(self, Info, info);
|
383
|
-
return
|
383
|
+
return rm_pixelpacket_to_color_name_info(info, &info->background_color);
|
384
384
|
}
|
385
385
|
|
386
386
|
|
@@ -412,7 +412,7 @@ Info_border_color(VALUE self)
|
|
412
412
|
Info *info;
|
413
413
|
|
414
414
|
Data_Get_Struct(self, Info, info);
|
415
|
-
return
|
415
|
+
return rm_pixelpacket_to_color_name_info(info, &info->border_color);
|
416
416
|
}
|
417
417
|
|
418
418
|
/*
|
@@ -1256,7 +1256,7 @@ Info_matte_color(VALUE self)
|
|
1256
1256
|
Info *info;
|
1257
1257
|
|
1258
1258
|
Data_Get_Struct(self, Info, info);
|
1259
|
-
return
|
1259
|
+
return rm_pixelpacket_to_color_name_info(info, &info->matte_color);
|
1260
1260
|
}
|
1261
1261
|
|
1262
1262
|
/*
|
@@ -1703,7 +1703,7 @@ Info_transparent_color(VALUE self)
|
|
1703
1703
|
Info *info;
|
1704
1704
|
|
1705
1705
|
Data_Get_Struct(self, Info, info);
|
1706
|
-
return
|
1706
|
+
return rm_pixelpacket_to_color_name_info(info, &info->transparent_color);
|
1707
1707
|
}
|
1708
1708
|
|
1709
1709
|
|
data/ext/RMagick/rmmain.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmmain.c,v 1.
|
1
|
+
/* $Id: rmmain.c,v 1.285 2009/01/12 23:08:35 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmmain.c
|
@@ -21,306 +21,6 @@ static void test_Magick_version(void);
|
|
21
21
|
static void version_constants(void);
|
22
22
|
|
23
23
|
|
24
|
-
|
25
|
-
/*
|
26
|
-
Method: Magick::colors [ { |colorinfo| } ]
|
27
|
-
Purpose: If called with the optional block, iterates over the colors,
|
28
|
-
otherwise returns an array of Magick::Color objects
|
29
|
-
Notes: There are 3 implementations
|
30
|
-
|
31
|
-
*/
|
32
|
-
VALUE
|
33
|
-
Magick_colors(VALUE class)
|
34
|
-
{
|
35
|
-
const ColorInfo **color_info_list;
|
36
|
-
unsigned long number_colors, x;
|
37
|
-
volatile VALUE ary;
|
38
|
-
ExceptionInfo exception;
|
39
|
-
|
40
|
-
GetExceptionInfo(&exception);
|
41
|
-
|
42
|
-
color_info_list = GetColorInfoList("*", &number_colors, &exception);
|
43
|
-
CHECK_EXCEPTION()
|
44
|
-
(void) DestroyExceptionInfo(&exception);
|
45
|
-
|
46
|
-
|
47
|
-
if (rb_block_given_p())
|
48
|
-
{
|
49
|
-
for (x = 0; x < number_colors; x++)
|
50
|
-
{
|
51
|
-
(void) rb_yield(Color_from_ColorInfo(color_info_list[x]));
|
52
|
-
}
|
53
|
-
magick_free((void *)color_info_list);
|
54
|
-
return class;
|
55
|
-
}
|
56
|
-
else
|
57
|
-
{
|
58
|
-
ary = rb_ary_new2((long) number_colors);
|
59
|
-
for (x = 0; x < number_colors; x++)
|
60
|
-
{
|
61
|
-
(void) rb_ary_push(ary, Color_from_ColorInfo(color_info_list[x]));
|
62
|
-
}
|
63
|
-
|
64
|
-
magick_free((void *)color_info_list);
|
65
|
-
return ary;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
/*
|
71
|
-
Method: Magick::fonts [ { |fontinfo| } ]
|
72
|
-
Purpose: If called with the optional block, iterates over the fonts,
|
73
|
-
otherwise returns an array of Magick::Font objects
|
74
|
-
*/
|
75
|
-
VALUE
|
76
|
-
Magick_fonts(VALUE class)
|
77
|
-
{
|
78
|
-
const TypeInfo **type_info;
|
79
|
-
unsigned long number_types, x;
|
80
|
-
volatile VALUE ary;
|
81
|
-
ExceptionInfo exception;
|
82
|
-
|
83
|
-
GetExceptionInfo(&exception);
|
84
|
-
type_info = GetTypeInfoList("*", &number_types, &exception);
|
85
|
-
CHECK_EXCEPTION()
|
86
|
-
(void) DestroyExceptionInfo(&exception);
|
87
|
-
|
88
|
-
if (rb_block_given_p())
|
89
|
-
{
|
90
|
-
for (x = 0; x < number_types; x++)
|
91
|
-
{
|
92
|
-
(void) rb_yield(Font_from_TypeInfo((const TypeInfo *)type_info[x]));
|
93
|
-
}
|
94
|
-
magick_free((void *)type_info);
|
95
|
-
return class;
|
96
|
-
}
|
97
|
-
else
|
98
|
-
{
|
99
|
-
ary = rb_ary_new2((long)number_types);
|
100
|
-
for (x = 0; x < number_types; x++)
|
101
|
-
{
|
102
|
-
(void) rb_ary_push(ary, Font_from_TypeInfo((const TypeInfo *)type_info[x]));
|
103
|
-
}
|
104
|
-
magick_free((void *)type_info);
|
105
|
-
return ary;
|
106
|
-
}
|
107
|
-
|
108
|
-
}
|
109
|
-
|
110
|
-
|
111
|
-
/*
|
112
|
-
Method: Magick.init_formats
|
113
|
-
Purpose: Build the @@formats hash
|
114
|
-
|
115
|
-
The hash keys are image formats. The hash values
|
116
|
-
specify the format "mode string", i.e. a description of what
|
117
|
-
ImageMagick can do with that format. The mode string is in the
|
118
|
-
form "BRWA", where
|
119
|
-
"B" is "*" if the format has native blob support, or " " otherwise.
|
120
|
-
"R" is "r" if ImageMagick can read that format, or "-" otherwise.
|
121
|
-
"W" is "w" if ImageMagick can write that format, or "-" otherwise.
|
122
|
-
"A" is "+" if the format supports multi-image files, or "-" otherwise.
|
123
|
-
Notes: Only called once.
|
124
|
-
There are 3 implementations.
|
125
|
-
*/
|
126
|
-
|
127
|
-
static VALUE
|
128
|
-
MagickInfo_to_format(const MagickInfo *magick_info)
|
129
|
-
{
|
130
|
-
char mode[4];
|
131
|
-
|
132
|
-
mode[0] = magick_info->blob_support ? '*': ' ';
|
133
|
-
mode[1] = magick_info->decoder ? 'r' : '-';
|
134
|
-
mode[2] = magick_info->encoder ? 'w' : '-';
|
135
|
-
mode[3] = magick_info->encoder && magick_info->adjoin ? '+' : '-';
|
136
|
-
|
137
|
-
return rb_str_new(mode, sizeof(mode));
|
138
|
-
}
|
139
|
-
|
140
|
-
|
141
|
-
VALUE
|
142
|
-
Magick_init_formats(VALUE class)
|
143
|
-
{
|
144
|
-
const MagickInfo **magick_info;
|
145
|
-
unsigned long number_formats, x;
|
146
|
-
volatile VALUE formats;
|
147
|
-
ExceptionInfo exception;
|
148
|
-
|
149
|
-
class = class; // defeat "never referenced" message from icc
|
150
|
-
formats = rb_hash_new();
|
151
|
-
|
152
|
-
// IM 6.1.3 added an exception argument to GetMagickInfoList
|
153
|
-
GetExceptionInfo(&exception);
|
154
|
-
magick_info = GetMagickInfoList("*", &number_formats, &exception);
|
155
|
-
CHECK_EXCEPTION()
|
156
|
-
(void) DestroyExceptionInfo(&exception);
|
157
|
-
|
158
|
-
|
159
|
-
for (x = 0; x < number_formats; x++)
|
160
|
-
{
|
161
|
-
(void) rb_hash_aset(formats
|
162
|
-
, rb_str_new2(magick_info[x]->name)
|
163
|
-
, MagickInfo_to_format((const MagickInfo *)magick_info[x]));
|
164
|
-
}
|
165
|
-
return formats;
|
166
|
-
}
|
167
|
-
|
168
|
-
|
169
|
-
/*
|
170
|
-
Method: Magick.limit_resource(resource[, limit])
|
171
|
-
Purpose: Get/set resource limits. If a limit is specified the old limit
|
172
|
-
is set to the new value. Either way the current/old limit is returned.
|
173
|
-
*/
|
174
|
-
static VALUE
|
175
|
-
Magick_limit_resource(int argc, VALUE *argv, VALUE class)
|
176
|
-
{
|
177
|
-
volatile VALUE resource, limit;
|
178
|
-
ResourceType res = UndefinedResource;
|
179
|
-
char *str;
|
180
|
-
ID id;
|
181
|
-
unsigned long cur_limit;
|
182
|
-
|
183
|
-
rb_scan_args(argc, argv, "11", &resource, &limit);
|
184
|
-
|
185
|
-
switch (TYPE(resource))
|
186
|
-
{
|
187
|
-
case T_NIL:
|
188
|
-
return class;
|
189
|
-
|
190
|
-
case T_SYMBOL:
|
191
|
-
id = (ID)SYM2ID(resource);
|
192
|
-
if (id == rb_intern("area"))
|
193
|
-
{
|
194
|
-
res = AreaResource;
|
195
|
-
}
|
196
|
-
else if (id == rb_intern("memory"))
|
197
|
-
{
|
198
|
-
res = MemoryResource;
|
199
|
-
}
|
200
|
-
else if (id == rb_intern("map"))
|
201
|
-
{
|
202
|
-
res = MapResource;
|
203
|
-
}
|
204
|
-
else if (id == rb_intern("disk"))
|
205
|
-
{
|
206
|
-
res = DiskResource;
|
207
|
-
}
|
208
|
-
else if (id == rb_intern("file"))
|
209
|
-
{
|
210
|
-
res = FileResource;
|
211
|
-
}
|
212
|
-
else
|
213
|
-
{
|
214
|
-
rb_raise(rb_eArgError, "unknown resource: `:%s'", rb_id2name(id));
|
215
|
-
}
|
216
|
-
break;
|
217
|
-
|
218
|
-
default:
|
219
|
-
str = StringValuePtr(resource);
|
220
|
-
if (*str == '\0')
|
221
|
-
{
|
222
|
-
return class;
|
223
|
-
}
|
224
|
-
else if (rm_strcasecmp("area", str) == 0)
|
225
|
-
{
|
226
|
-
res = AreaResource;
|
227
|
-
}
|
228
|
-
else if (rm_strcasecmp("memory", str) == 0)
|
229
|
-
{
|
230
|
-
res = MemoryResource;
|
231
|
-
}
|
232
|
-
else if (rm_strcasecmp("map", str) == 0)
|
233
|
-
{
|
234
|
-
res = MapResource;
|
235
|
-
}
|
236
|
-
else if (rm_strcasecmp("disk", str) == 0)
|
237
|
-
{
|
238
|
-
res = DiskResource;
|
239
|
-
}
|
240
|
-
else if (rm_strcasecmp("file", str) == 0)
|
241
|
-
{
|
242
|
-
res = FileResource;
|
243
|
-
}
|
244
|
-
else
|
245
|
-
{
|
246
|
-
rb_raise(rb_eArgError, "unknown resource: `%s'", str);
|
247
|
-
}
|
248
|
-
break;
|
249
|
-
}
|
250
|
-
|
251
|
-
cur_limit = GetMagickResourceLimit(res);
|
252
|
-
|
253
|
-
if (argc > 1)
|
254
|
-
{
|
255
|
-
(void) SetMagickResourceLimit(res, (MagickSizeType)NUM2ULONG(limit));
|
256
|
-
}
|
257
|
-
|
258
|
-
return ULONG2NUM(cur_limit);
|
259
|
-
}
|
260
|
-
|
261
|
-
|
262
|
-
/*
|
263
|
-
Method Magick.set_cache_threshold(megabytes)
|
264
|
-
Purpose: sets the amount of free memory allocated for the
|
265
|
-
pixel cache. Once this threshold is exceeded, all
|
266
|
-
subsequent pixels cache operations are to/from disk.
|
267
|
-
Notes: singleton method
|
268
|
-
*/
|
269
|
-
static VALUE
|
270
|
-
Magick_set_cache_threshold(VALUE class, VALUE threshold)
|
271
|
-
{
|
272
|
-
unsigned long thrshld = NUM2ULONG(threshold);
|
273
|
-
(void) SetMagickResourceLimit(MemoryResource, (MagickSizeType)thrshld);
|
274
|
-
(void) SetMagickResourceLimit(MapResource, (MagickSizeType)(2*thrshld));
|
275
|
-
return class;
|
276
|
-
}
|
277
|
-
|
278
|
-
|
279
|
-
/*
|
280
|
-
Method: Magick.set_log_event_mask(event,...) -> Magick
|
281
|
-
Notes: "event" is one of "all", "annotate", "blob", "cache",
|
282
|
-
"coder", "configure", "deprecate", "locale", "none",
|
283
|
-
"render", "transform", "user", "x11". Multiple events
|
284
|
-
can be specified. Event names may be capitalized.
|
285
|
-
*/
|
286
|
-
static VALUE
|
287
|
-
Magick_set_log_event_mask(int argc, VALUE *argv, VALUE class)
|
288
|
-
{
|
289
|
-
int x;
|
290
|
-
|
291
|
-
if (argc == 0)
|
292
|
-
{
|
293
|
-
rb_raise(rb_eArgError, "wrong number of arguments (at least 1 required)");
|
294
|
-
}
|
295
|
-
for (x = 0; x < argc; x++)
|
296
|
-
{
|
297
|
-
(void) SetLogEventMask(StringValuePtr(argv[x]));
|
298
|
-
}
|
299
|
-
return class;
|
300
|
-
}
|
301
|
-
|
302
|
-
/*
|
303
|
-
Method: Magick.set_log_format(format) -> Magick
|
304
|
-
Notes: Format is a string containing one or more of:
|
305
|
-
%t - current time
|
306
|
-
%r - elapsed time
|
307
|
-
%u - user time
|
308
|
-
%p - pid
|
309
|
-
%m - module (source file name)
|
310
|
-
%f - function name
|
311
|
-
%l - line number
|
312
|
-
%d - event domain (one of the events listed above)
|
313
|
-
%e - event name
|
314
|
-
Plus other characters, including \n, etc.
|
315
|
-
*/
|
316
|
-
static VALUE
|
317
|
-
Magick_set_log_format(VALUE class, VALUE format)
|
318
|
-
{
|
319
|
-
SetLogFormat(StringValuePtr(format));
|
320
|
-
return class;
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
24
|
/*
|
325
25
|
External: Init_RMagick2
|
326
26
|
Purpose: define the classes and constants
|
@@ -589,6 +289,8 @@ Init_RMagick2(void)
|
|
589
289
|
rb_define_method(Class_Image, "magnify", Image_magnify, 0);
|
590
290
|
rb_define_method(Class_Image, "magnify!", Image_magnify_bang, 0);
|
591
291
|
rb_define_method(Class_Image, "map", Image_map, -1);
|
292
|
+
rb_define_method(Class_Image, "marshal_dump", Image_marshal_dump, 0);
|
293
|
+
rb_define_method(Class_Image, "marshal_load", Image_marshal_load, 1);
|
592
294
|
rb_define_method(Class_Image, "mask", Image_mask, -1);
|
593
295
|
rb_define_method(Class_Image, "matte_flood_fill", Image_matte_flood_fill, 5);
|
594
296
|
rb_define_method(Class_Image, "median_filter", Image_median_filter, -1);
|
@@ -729,6 +431,8 @@ Init_RMagick2(void)
|
|
729
431
|
DCL_ATTR_WRITER(Draw, font_style)
|
730
432
|
DCL_ATTR_WRITER(Draw, font_weight)
|
731
433
|
DCL_ATTR_WRITER(Draw, gravity)
|
434
|
+
DCL_ATTR_WRITER(Draw, interword_spacing)
|
435
|
+
DCL_ATTR_WRITER(Draw, kerning)
|
732
436
|
DCL_ATTR_WRITER(Draw, pointsize)
|
733
437
|
DCL_ATTR_WRITER(Draw, rotation)
|
734
438
|
DCL_ATTR_WRITER(Draw, stroke)
|
@@ -748,6 +452,8 @@ Init_RMagick2(void)
|
|
748
452
|
rb_define_method(Class_Draw, "initialize", Draw_initialize, 0);
|
749
453
|
rb_define_method(Class_Draw, "initialize_copy", Draw_init_copy, 1);
|
750
454
|
rb_define_method(Class_Draw, "inspect", Draw_inspect, 0);
|
455
|
+
rb_define_method(Class_Draw, "marshal_dump", Draw_marshal_dump, 0);
|
456
|
+
rb_define_method(Class_Draw, "marshal_load", Draw_marshal_load, 1);
|
751
457
|
rb_define_method(Class_Draw, "primitive", Draw_primitive, 1);
|
752
458
|
|
753
459
|
/*-----------------------------------------------------------------------*/
|
@@ -829,6 +535,8 @@ Init_RMagick2(void)
|
|
829
535
|
rb_define_method(Class_Pixel, "fcmp", Pixel_fcmp, -1);
|
830
536
|
rb_define_method(Class_Pixel, "hash", Pixel_hash, 0);
|
831
537
|
rb_define_method(Class_Pixel, "intensity", Pixel_intensity, 0);
|
538
|
+
rb_define_method(Class_Pixel, "marshal_dump", Pixel_marshal_dump, 0);
|
539
|
+
rb_define_method(Class_Pixel, "marshal_load", Pixel_marshal_load, 1);
|
832
540
|
rb_define_method(Class_Pixel, "to_color", Pixel_to_color, -1);
|
833
541
|
rb_define_method(Class_Pixel, "to_HSL", Pixel_to_HSL, 0); // deprecated
|
834
542
|
rb_define_method(Class_Pixel, "to_hsla", Pixel_to_hsla, 0);
|
@@ -1555,6 +1263,45 @@ Init_RMagick2(void)
|
|
1555
1263
|
ENUMERATOR(XorQuantumOperator)
|
1556
1264
|
#if defined(HAVE_ENUM_POWEVALUATEOPERATOR)
|
1557
1265
|
ENUMERATOR(PowQuantumOperator)
|
1266
|
+
#endif
|
1267
|
+
#if defined(HAVE_ENUM_LOGEVALUATEOPERATOR)
|
1268
|
+
ENUMERATOR(LogQuantumOperator)
|
1269
|
+
#endif
|
1270
|
+
#if defined(HAVE_ENUM_THRESHOLDEVALUATEOPERATOR)
|
1271
|
+
ENUMERATOR(ThresholdQuantumOperator)
|
1272
|
+
#endif
|
1273
|
+
#if defined(HAVE_ENUM_THRESHOLDBLACKEVALUATEOPERATOR)
|
1274
|
+
ENUMERATOR(ThresholdBlackQuantumOperator)
|
1275
|
+
#endif
|
1276
|
+
#if defined(HAVE_ENUM_THRESHOLDWHITEEVALUATEOPERATOR)
|
1277
|
+
ENUMERATOR(ThresholdWhiteQuantumOperator)
|
1278
|
+
#endif
|
1279
|
+
#if defined(HAVE_ENUM_GAUSSIANNOISEEVALUATEOPERATOR)
|
1280
|
+
ENUMERATOR(GaussianNoiseQuantumOperator)
|
1281
|
+
#endif
|
1282
|
+
#if defined(HAVE_ENUM_IMPULSENOISEEVALUATEOPERATOR)
|
1283
|
+
ENUMERATOR(ImpulseNoiseQuantumOperator)
|
1284
|
+
#endif
|
1285
|
+
#if defined(HAVE_ENUM_LAPLACIANNOISEEVALUATEOPERATOR)
|
1286
|
+
ENUMERATOR(LaplacianNoiseQuantumOperator)
|
1287
|
+
#endif
|
1288
|
+
#if defined(HAVE_ENUM_MULTIPLICATIVENOISEEVALUATEOPERATOR)
|
1289
|
+
ENUMERATOR(MultiplicativeNoiseQuantumOperator)
|
1290
|
+
#endif
|
1291
|
+
#if defined(HAVE_ENUM_POISSONNOISEEVALUATEOPERATOR)
|
1292
|
+
ENUMERATOR(PoissonNoiseQuantumOperator)
|
1293
|
+
#endif
|
1294
|
+
#if defined(HAVE_ENUM_UNIFORMNOISEEVALUATEOPERATOR)
|
1295
|
+
ENUMERATOR(UniformNoiseQuantumOperator)
|
1296
|
+
#endif
|
1297
|
+
#if defined(HAVE_ENUM_COSINEEVALUATEOPERATOR)
|
1298
|
+
ENUMERATOR(CosineQuantumOperator)
|
1299
|
+
#endif
|
1300
|
+
#if defined(HAVE_ENUM_SINEEVALUATEOPERATOR)
|
1301
|
+
ENUMERATOR(SineQuantumOperator)
|
1302
|
+
#endif
|
1303
|
+
#if defined(HAVE_ENUM_ADDMODULUSEVALUATEOPERATOR)
|
1304
|
+
ENUMERATOR(AddModulusQuantumOperator)
|
1558
1305
|
#endif
|
1559
1306
|
END_ENUM
|
1560
1307
|
|
@@ -1780,7 +1527,7 @@ test_Magick_version(void)
|
|
1780
1527
|
}
|
1781
1528
|
|
1782
1529
|
rb_raise(rb_eRuntimeError,
|
1783
|
-
"This
|
1530
|
+
"This installation of RMagick was configured with %s %s but %.*s is in use.\n" ,
|
1784
1531
|
MagickPackageName, MagickLibVersionText, x, version_str);
|
1785
1532
|
}
|
1786
1533
|
|
@@ -1812,7 +1559,7 @@ version_constants(void)
|
|
1812
1559
|
rb_define_const(Module_Magick, "Version", str);
|
1813
1560
|
|
1814
1561
|
sprintf(long_version,
|
1815
|
-
"This is %s ($Date:
|
1562
|
+
"This is %s ($Date: 2009/01/12 23:08:35 $) Copyright (C) 2008 by Timothy P. Hunter\n"
|
1816
1563
|
"Built with %s\n"
|
1817
1564
|
"Built for %s\n"
|
1818
1565
|
"Web page: http://rmagick.rubyforge.org\n"
|