rmagick 2.13.2 → 4.2.2

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.

Files changed (380) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +63 -0
  3. data/.editorconfig +17 -0
  4. data/.github/ISSUE_TEMPLATE.md +17 -0
  5. data/.github/workflows/ci.yml +107 -0
  6. data/.gitignore +25 -0
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +37 -0
  9. data/.rubocop_todo.yml +449 -0
  10. data/.yardopts +5 -0
  11. data/CHANGELOG.md +1277 -0
  12. data/CODE_OF_CONDUCT.md +128 -0
  13. data/CONTRIBUTING.md +81 -0
  14. data/Gemfile +4 -0
  15. data/LICENSE +20 -0
  16. data/README.md +324 -0
  17. data/Rakefile +190 -0
  18. data/before_install_linux.sh +69 -0
  19. data/before_install_osx.sh +57 -0
  20. data/deprecated/RMagick.rb +6 -0
  21. data/ext/RMagick/extconf.rb +334 -333
  22. data/ext/RMagick/rmagick.c +129 -127
  23. data/ext/RMagick/rmagick.h +221 -320
  24. data/ext/RMagick/rmdraw.c +458 -767
  25. data/ext/RMagick/rmenum.c +305 -752
  26. data/ext/RMagick/rmfill.c +231 -199
  27. data/ext/RMagick/rmilist.c +437 -478
  28. data/ext/RMagick/rmimage.c +6130 -5342
  29. data/ext/RMagick/rminfo.c +695 -833
  30. data/ext/RMagick/rmkinfo.c +198 -0
  31. data/ext/RMagick/rmmain.c +752 -506
  32. data/ext/RMagick/rmmontage.c +94 -152
  33. data/ext/RMagick/rmpixel.c +619 -425
  34. data/ext/RMagick/rmstruct.c +206 -309
  35. data/ext/RMagick/rmutil.c +514 -344
  36. data/lib/rmagick/version.rb +5 -0
  37. data/lib/rmagick.rb +1 -0
  38. data/lib/rmagick_internal.rb +1922 -0
  39. data/lib/rvg/clippath.rb +35 -39
  40. data/lib/rvg/container.rb +123 -124
  41. data/lib/rvg/deep_equal.rb +45 -49
  42. data/lib/rvg/describable.rb +41 -47
  43. data/lib/rvg/embellishable.rb +380 -411
  44. data/lib/rvg/misc.rb +691 -711
  45. data/lib/rvg/paint.rb +43 -47
  46. data/lib/rvg/pathdata.rb +119 -125
  47. data/lib/rvg/rvg.rb +214 -213
  48. data/lib/rvg/stretchable.rb +153 -162
  49. data/lib/rvg/stylable.rb +111 -117
  50. data/lib/rvg/text.rb +169 -180
  51. data/lib/rvg/transformable.rb +121 -127
  52. data/lib/rvg/units.rb +58 -61
  53. data/rmagick.gemspec +36 -16
  54. metadata +188 -365
  55. data/ChangeLog +0 -773
  56. data/Doxyfile +0 -1514
  57. data/README-Mac-OSX.txt +0 -1
  58. data/README.html +0 -10
  59. data/build_tarball.rake +0 -215
  60. data/doc/comtasks.html +0 -287
  61. data/doc/constants.html +0 -1581
  62. data/doc/css/doc.css +0 -299
  63. data/doc/css/popup.css +0 -34
  64. data/doc/css/ref.css +0 -67
  65. data/doc/draw.html +0 -3269
  66. data/doc/ex/InitialCoords.rb +0 -23
  67. data/doc/ex/NewCoordSys.rb +0 -32
  68. data/doc/ex/OrigCoordSys.rb +0 -18
  69. data/doc/ex/PreserveAspectRatio.rb +0 -205
  70. data/doc/ex/RotateScale.rb +0 -37
  71. data/doc/ex/Skew.rb +0 -38
  72. data/doc/ex/Use01.rb +0 -16
  73. data/doc/ex/Use02.rb +0 -21
  74. data/doc/ex/Use03.rb +0 -16
  75. data/doc/ex/ViewBox.rb +0 -33
  76. data/doc/ex/adaptive_threshold.rb +0 -10
  77. data/doc/ex/add_noise.rb +0 -17
  78. data/doc/ex/affine.rb +0 -48
  79. data/doc/ex/affine_transform.rb +0 -20
  80. data/doc/ex/arc.rb +0 -49
  81. data/doc/ex/arcpath.rb +0 -33
  82. data/doc/ex/arcs01.rb +0 -28
  83. data/doc/ex/arcs02.rb +0 -61
  84. data/doc/ex/average.rb +0 -15
  85. data/doc/ex/axes.rb +0 -64
  86. data/doc/ex/baseline_shift01.rb +0 -18
  87. data/doc/ex/bilevel_channel.rb +0 -9
  88. data/doc/ex/blur_image.rb +0 -12
  89. data/doc/ex/border.rb +0 -10
  90. data/doc/ex/bounding_box.rb +0 -44
  91. data/doc/ex/cbezier1.rb +0 -42
  92. data/doc/ex/cbezier2.rb +0 -42
  93. data/doc/ex/cbezier3.rb +0 -42
  94. data/doc/ex/cbezier4.rb +0 -43
  95. data/doc/ex/cbezier5.rb +0 -43
  96. data/doc/ex/cbezier6.rb +0 -53
  97. data/doc/ex/channel.rb +0 -26
  98. data/doc/ex/charcoal.rb +0 -12
  99. data/doc/ex/chop.rb +0 -29
  100. data/doc/ex/circle.rb +0 -33
  101. data/doc/ex/circle01.rb +0 -17
  102. data/doc/ex/clip_path.rb +0 -60
  103. data/doc/ex/coalesce.rb +0 -60
  104. data/doc/ex/color_fill_to_border.rb +0 -29
  105. data/doc/ex/color_floodfill.rb +0 -28
  106. data/doc/ex/color_histogram.rb +0 -48
  107. data/doc/ex/color_reset.rb +0 -11
  108. data/doc/ex/colorize.rb +0 -16
  109. data/doc/ex/colors.rb +0 -64
  110. data/doc/ex/compose_mask.rb +0 -23
  111. data/doc/ex/composite.rb +0 -135
  112. data/doc/ex/composite_layers.rb +0 -53
  113. data/doc/ex/composite_tiled.rb +0 -23
  114. data/doc/ex/contrast.rb +0 -36
  115. data/doc/ex/crop.rb +0 -31
  116. data/doc/ex/crop_with_gravity.rb +0 -46
  117. data/doc/ex/cubic01.rb +0 -45
  118. data/doc/ex/cubic02.rb +0 -94
  119. data/doc/ex/cycle_colormap.rb +0 -21
  120. data/doc/ex/dissolve.rb +0 -13
  121. data/doc/ex/drawcomp.rb +0 -42
  122. data/doc/ex/drop_shadow.rb +0 -60
  123. data/doc/ex/edge.rb +0 -11
  124. data/doc/ex/ellipse.rb +0 -45
  125. data/doc/ex/ellipse01.rb +0 -22
  126. data/doc/ex/emboss.rb +0 -11
  127. data/doc/ex/enhance.rb +0 -28
  128. data/doc/ex/equalize.rb +0 -11
  129. data/doc/ex/evenodd.rb +0 -43
  130. data/doc/ex/fill_pattern.rb +0 -26
  131. data/doc/ex/flatten_images.rb +0 -36
  132. data/doc/ex/flip.rb +0 -11
  133. data/doc/ex/flop.rb +0 -11
  134. data/doc/ex/font_styles.rb +0 -34
  135. data/doc/ex/fonts.rb +0 -20
  136. data/doc/ex/frame.rb +0 -12
  137. data/doc/ex/gaussian_blur.rb +0 -11
  138. data/doc/ex/get_multiline_type_metrics.rb +0 -42
  139. data/doc/ex/get_pixels.rb +0 -48
  140. data/doc/ex/get_type_metrics.rb +0 -146
  141. data/doc/ex/gradientfill.rb +0 -27
  142. data/doc/ex/grav.rb +0 -46
  143. data/doc/ex/gravity.rb +0 -79
  144. data/doc/ex/group.rb +0 -26
  145. data/doc/ex/hatchfill.rb +0 -27
  146. data/doc/ex/image.rb +0 -46
  147. data/doc/ex/images/Apple.miff +0 -0
  148. data/doc/ex/images/Ballerina.jpg +0 -0
  149. data/doc/ex/images/Ballerina3.jpg +0 -0
  150. data/doc/ex/images/Button_0.gif +0 -0
  151. data/doc/ex/images/Button_1.gif +0 -0
  152. data/doc/ex/images/Button_2.gif +0 -0
  153. data/doc/ex/images/Button_3.gif +0 -0
  154. data/doc/ex/images/Button_4.gif +0 -0
  155. data/doc/ex/images/Button_5.gif +0 -0
  156. data/doc/ex/images/Button_6.gif +0 -0
  157. data/doc/ex/images/Button_7.gif +0 -0
  158. data/doc/ex/images/Button_8.gif +0 -0
  159. data/doc/ex/images/Button_9.gif +0 -0
  160. data/doc/ex/images/Button_A.gif +0 -0
  161. data/doc/ex/images/Button_B.gif +0 -0
  162. data/doc/ex/images/Button_C.gif +0 -0
  163. data/doc/ex/images/Button_D.gif +0 -0
  164. data/doc/ex/images/Button_E.gif +0 -0
  165. data/doc/ex/images/Button_F.gif +0 -0
  166. data/doc/ex/images/Button_G.gif +0 -0
  167. data/doc/ex/images/Button_H.gif +0 -0
  168. data/doc/ex/images/Button_I.gif +0 -0
  169. data/doc/ex/images/Button_J.gif +0 -0
  170. data/doc/ex/images/Button_K.gif +0 -0
  171. data/doc/ex/images/Button_L.gif +0 -0
  172. data/doc/ex/images/Button_M.gif +0 -0
  173. data/doc/ex/images/Button_N.gif +0 -0
  174. data/doc/ex/images/Button_O.gif +0 -0
  175. data/doc/ex/images/Button_P.gif +0 -0
  176. data/doc/ex/images/Button_Q.gif +0 -0
  177. data/doc/ex/images/Button_R.gif +0 -0
  178. data/doc/ex/images/Button_S.gif +0 -0
  179. data/doc/ex/images/Button_T.gif +0 -0
  180. data/doc/ex/images/Button_U.gif +0 -0
  181. data/doc/ex/images/Button_V.gif +0 -0
  182. data/doc/ex/images/Button_W.gif +0 -0
  183. data/doc/ex/images/Button_X.gif +0 -0
  184. data/doc/ex/images/Button_Y.gif +0 -0
  185. data/doc/ex/images/Button_Z.gif +0 -0
  186. data/doc/ex/images/Cheetah.jpg +0 -0
  187. data/doc/ex/images/Coffee.wmf +0 -0
  188. data/doc/ex/images/Flower_Hat.jpg +0 -0
  189. data/doc/ex/images/Gold_Statue.jpg +0 -0
  190. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  191. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  192. data/doc/ex/images/Leaf.miff +0 -0
  193. data/doc/ex/images/No.wmf +0 -0
  194. data/doc/ex/images/Polynesia.jpg +0 -0
  195. data/doc/ex/images/Red_Rocks.jpg +0 -0
  196. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  197. data/doc/ex/images/Shorts.jpg +0 -0
  198. data/doc/ex/images/Snake.wmf +0 -0
  199. data/doc/ex/images/Violin.jpg +0 -0
  200. data/doc/ex/images/Yellow_Rose.miff +0 -0
  201. data/doc/ex/images/big-duck.gif +0 -0
  202. data/doc/ex/images/duck.gif +0 -0
  203. data/doc/ex/images/duck0.gif +0 -0
  204. data/doc/ex/images/duck1.gif +0 -0
  205. data/doc/ex/images/duck10.gif +0 -0
  206. data/doc/ex/images/duck11.gif +0 -0
  207. data/doc/ex/images/duck12.gif +0 -0
  208. data/doc/ex/images/duck13.gif +0 -0
  209. data/doc/ex/images/duck14.gif +0 -0
  210. data/doc/ex/images/duck15.gif +0 -0
  211. data/doc/ex/images/duck2.gif +0 -0
  212. data/doc/ex/images/duck3.gif +0 -0
  213. data/doc/ex/images/duck4.gif +0 -0
  214. data/doc/ex/images/duck5.gif +0 -0
  215. data/doc/ex/images/duck6.gif +0 -0
  216. data/doc/ex/images/duck7.gif +0 -0
  217. data/doc/ex/images/duck8.gif +0 -0
  218. data/doc/ex/images/duck9.gif +0 -0
  219. data/doc/ex/images/graydient230x6.gif +0 -0
  220. data/doc/ex/images/logo400x83.gif +0 -0
  221. data/doc/ex/images/model.miff +0 -0
  222. data/doc/ex/images/notimplemented.gif +0 -0
  223. data/doc/ex/images/smile.miff +0 -0
  224. data/doc/ex/images/spin.gif +0 -0
  225. data/doc/ex/implode.rb +0 -34
  226. data/doc/ex/level.rb +0 -11
  227. data/doc/ex/level_colors.rb +0 -11
  228. data/doc/ex/line.rb +0 -42
  229. data/doc/ex/line01.rb +0 -23
  230. data/doc/ex/mask.rb +0 -36
  231. data/doc/ex/matte_fill_to_border.rb +0 -40
  232. data/doc/ex/matte_floodfill.rb +0 -33
  233. data/doc/ex/matte_replace.rb +0 -40
  234. data/doc/ex/median_filter.rb +0 -28
  235. data/doc/ex/modulate.rb +0 -11
  236. data/doc/ex/mono.rb +0 -23
  237. data/doc/ex/morph.rb +0 -26
  238. data/doc/ex/mosaic.rb +0 -35
  239. data/doc/ex/motion_blur.rb +0 -11
  240. data/doc/ex/negate.rb +0 -11
  241. data/doc/ex/negate_channel.rb +0 -9
  242. data/doc/ex/nested_rvg.rb +0 -21
  243. data/doc/ex/nonzero.rb +0 -43
  244. data/doc/ex/normalize.rb +0 -11
  245. data/doc/ex/oil_paint.rb +0 -11
  246. data/doc/ex/opacity.rb +0 -37
  247. data/doc/ex/ordered_dither.rb +0 -11
  248. data/doc/ex/path.rb +0 -64
  249. data/doc/ex/pattern1.rb +0 -25
  250. data/doc/ex/pattern2.rb +0 -26
  251. data/doc/ex/polaroid.rb +0 -28
  252. data/doc/ex/polygon.rb +0 -24
  253. data/doc/ex/polygon01.rb +0 -23
  254. data/doc/ex/polyline.rb +0 -23
  255. data/doc/ex/polyline01.rb +0 -23
  256. data/doc/ex/posterize.rb +0 -8
  257. data/doc/ex/preview.rb +0 -9
  258. data/doc/ex/qbezierpath.rb +0 -52
  259. data/doc/ex/quad01.rb +0 -36
  260. data/doc/ex/quantize-m.rb +0 -25
  261. data/doc/ex/radial_blur.rb +0 -9
  262. data/doc/ex/raise.rb +0 -8
  263. data/doc/ex/random_threshold_channel.rb +0 -13
  264. data/doc/ex/rect01.rb +0 -15
  265. data/doc/ex/rect02.rb +0 -22
  266. data/doc/ex/rectangle.rb +0 -35
  267. data/doc/ex/reduce_noise.rb +0 -28
  268. data/doc/ex/remap.rb +0 -12
  269. data/doc/ex/remap_images.rb +0 -21
  270. data/doc/ex/resize_to_fill.rb +0 -10
  271. data/doc/ex/resize_to_fit.rb +0 -10
  272. data/doc/ex/roll.rb +0 -9
  273. data/doc/ex/rotate.rb +0 -45
  274. data/doc/ex/rotate_f.rb +0 -14
  275. data/doc/ex/roundrect.rb +0 -34
  276. data/doc/ex/rubyname.rb +0 -30
  277. data/doc/ex/rvg_clippath.rb +0 -14
  278. data/doc/ex/rvg_linecap.rb +0 -43
  279. data/doc/ex/rvg_linejoin.rb +0 -41
  280. data/doc/ex/rvg_opacity.rb +0 -19
  281. data/doc/ex/rvg_pattern.rb +0 -26
  282. data/doc/ex/rvg_stroke_dasharray.rb +0 -12
  283. data/doc/ex/segment.rb +0 -11
  284. data/doc/ex/sepiatone.rb +0 -8
  285. data/doc/ex/shade.rb +0 -11
  286. data/doc/ex/shadow.rb +0 -31
  287. data/doc/ex/shave.rb +0 -15
  288. data/doc/ex/shear.rb +0 -10
  289. data/doc/ex/sketch.rb +0 -18
  290. data/doc/ex/skewx.rb +0 -52
  291. data/doc/ex/skewy.rb +0 -47
  292. data/doc/ex/smile.rb +0 -125
  293. data/doc/ex/solarize.rb +0 -11
  294. data/doc/ex/sparse_color.rb +0 -55
  295. data/doc/ex/splice.rb +0 -9
  296. data/doc/ex/spread.rb +0 -11
  297. data/doc/ex/stegano.rb +0 -55
  298. data/doc/ex/stroke_dasharray.rb +0 -43
  299. data/doc/ex/stroke_fill.rb +0 -11
  300. data/doc/ex/stroke_linecap.rb +0 -44
  301. data/doc/ex/stroke_linejoin.rb +0 -48
  302. data/doc/ex/stroke_width.rb +0 -49
  303. data/doc/ex/swirl.rb +0 -17
  304. data/doc/ex/text.rb +0 -37
  305. data/doc/ex/text01.rb +0 -17
  306. data/doc/ex/text_align.rb +0 -36
  307. data/doc/ex/text_antialias.rb +0 -38
  308. data/doc/ex/text_styles.rb +0 -21
  309. data/doc/ex/text_undercolor.rb +0 -28
  310. data/doc/ex/texture_fill_to_border.rb +0 -34
  311. data/doc/ex/texture_floodfill.rb +0 -32
  312. data/doc/ex/texturefill.rb +0 -25
  313. data/doc/ex/threshold.rb +0 -13
  314. data/doc/ex/to_blob.rb +0 -14
  315. data/doc/ex/translate.rb +0 -39
  316. data/doc/ex/transparent.rb +0 -38
  317. data/doc/ex/transpose.rb +0 -9
  318. data/doc/ex/transverse.rb +0 -9
  319. data/doc/ex/tref01.rb +0 -25
  320. data/doc/ex/triangle01.rb +0 -16
  321. data/doc/ex/trim.rb +0 -24
  322. data/doc/ex/tspan01.rb +0 -18
  323. data/doc/ex/tspan02.rb +0 -19
  324. data/doc/ex/tspan03.rb +0 -21
  325. data/doc/ex/unsharp_mask.rb +0 -28
  326. data/doc/ex/viewex.rb +0 -35
  327. data/doc/ex/vignette.rb +0 -12
  328. data/doc/ex/watermark.rb +0 -28
  329. data/doc/ex/wave.rb +0 -9
  330. data/doc/ex/wet_floor.rb +0 -59
  331. data/doc/ex/writing_mode01.rb +0 -27
  332. data/doc/ex/writing_mode02.rb +0 -26
  333. data/doc/ilist.html +0 -2056
  334. data/doc/image1.html +0 -4680
  335. data/doc/image2.html +0 -3665
  336. data/doc/image3.html +0 -4522
  337. data/doc/imageattrs.html +0 -1638
  338. data/doc/imusage.html +0 -514
  339. data/doc/index.html +0 -416
  340. data/doc/info.html +0 -1499
  341. data/doc/magick.html +0 -565
  342. data/doc/optequiv.html +0 -2435
  343. data/doc/rvg.html +0 -975
  344. data/doc/rvgclip.html +0 -248
  345. data/doc/rvggroup.html +0 -305
  346. data/doc/rvgimage.html +0 -289
  347. data/doc/rvgpattern.html +0 -475
  348. data/doc/rvgshape.html +0 -406
  349. data/doc/rvgstyle.html +0 -270
  350. data/doc/rvgtext.html +0 -465
  351. data/doc/rvgtspan.html +0 -238
  352. data/doc/rvgtut.html +0 -530
  353. data/doc/rvguse.html +0 -145
  354. data/doc/rvgxform.html +0 -294
  355. data/doc/scripts/doc.js +0 -22
  356. data/doc/scripts/stripeTables.js +0 -23
  357. data/doc/struct.html +0 -1339
  358. data/doc/usage.html +0 -1621
  359. data/examples/constitute.rb +0 -7
  360. data/examples/crop_with_gravity.rb +0 -46
  361. data/examples/demo.rb +0 -324
  362. data/examples/describe.rb +0 -44
  363. data/examples/find_similar_region.rb +0 -34
  364. data/examples/histogram.rb +0 -325
  365. data/examples/identify.rb +0 -187
  366. data/examples/image_opacity.rb +0 -29
  367. data/examples/import_export.rb +0 -31
  368. data/examples/pattern_fill.rb +0 -38
  369. data/examples/rotating_text.rb +0 -45
  370. data/examples/spinner.rb +0 -50
  371. data/examples/thumbnail.rb +0 -65
  372. data/examples/vignette.rb +0 -79
  373. data/ext/RMagick/MANIFEST +0 -358
  374. data/lib/RMagick.rb +0 -1962
  375. data/metaconfig +0 -7
  376. data/post-clean.rb +0 -12
  377. data/post-install.rb +0 -50
  378. data/post-setup.rb +0 -254
  379. data/setup.rb +0 -1585
  380. data/uninstall.rb +0 -76
@@ -15,16 +15,6 @@
15
15
 
16
16
 
17
17
 
18
- static const char *ComplianceType_name(ComplianceType *);
19
- static VALUE ComplianceType_new(ComplianceType);
20
- static const char *StretchType_name(StretchType);
21
- static VALUE StretchType_new(StretchType);
22
- static const char *StyleType_name(StyleType);
23
- static VALUE StyleType_new(StyleType);
24
-
25
-
26
-
27
-
28
18
  /**
29
19
  * Given a C AffineMatrix, create the equivalent AffineMatrix object.
30
20
  *
@@ -65,7 +55,7 @@ Import_AffineMatrix(AffineMatrix *affine)
65
55
  void
66
56
  Export_AffineMatrix(AffineMatrix *am, VALUE st)
67
57
  {
68
- volatile VALUE values, v;
58
+ VALUE values, v;
69
59
 
70
60
  if (CLASS_OF(st) != Class_AffineMatrix)
71
61
  {
@@ -85,11 +75,14 @@ Export_AffineMatrix(AffineMatrix *am, VALUE st)
85
75
  am->tx = v == Qnil ? 0.0 : NUM2DBL(v);
86
76
  v = rb_ary_entry(values, 5);
87
77
  am->ty = v == Qnil ? 0.0 : NUM2DBL(v);
78
+
79
+ RB_GC_GUARD(values);
80
+ RB_GC_GUARD(v);
88
81
  }
89
82
 
90
83
 
91
84
  /**
92
- * Create a Magick::ChromaticityInfo object from a ChromaticityInfo structure.
85
+ * Create a {Magick::ChromaticityInfo} object from a ChromaticityInfo structure.
93
86
  *
94
87
  * No Ruby usage (internal function)
95
88
  *
@@ -99,18 +92,23 @@ Export_AffineMatrix(AffineMatrix *am, VALUE st)
99
92
  VALUE
100
93
  ChromaticityInfo_new(ChromaticityInfo *ci)
101
94
  {
102
- volatile VALUE red_primary;
103
- volatile VALUE green_primary;
104
- volatile VALUE blue_primary;
105
- volatile VALUE white_point;
95
+ VALUE red_primary;
96
+ VALUE green_primary;
97
+ VALUE blue_primary;
98
+ VALUE white_point;
106
99
 
107
100
  red_primary = Import_PrimaryInfo(&ci->red_primary);
108
101
  green_primary = Import_PrimaryInfo(&ci->green_primary);
109
102
  blue_primary = Import_PrimaryInfo(&ci->blue_primary);
110
103
  white_point = Import_PrimaryInfo(&ci->white_point);
111
104
 
112
- return rb_funcall(Class_Chromaticity, rm_ID_new, 4
113
- , red_primary, green_primary, blue_primary, white_point);
105
+ RB_GC_GUARD(red_primary);
106
+ RB_GC_GUARD(green_primary);
107
+ RB_GC_GUARD(blue_primary);
108
+ RB_GC_GUARD(white_point);
109
+
110
+ return rb_funcall(Class_Chromaticity, rm_ID_new, 4,
111
+ red_primary, green_primary, blue_primary, white_point);
114
112
  }
115
113
 
116
114
 
@@ -126,27 +124,25 @@ ChromaticityInfo_new(ChromaticityInfo *ci)
126
124
  void
127
125
  Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
128
126
  {
129
- volatile VALUE chrom_members;
130
- volatile VALUE red_primary, green_primary, blue_primary, white_point;
131
- volatile VALUE entry_members, x, y;
132
- ID values_id;
127
+ VALUE chrom_members;
128
+ VALUE red_primary, green_primary, blue_primary, white_point;
129
+ VALUE entry_members, x, y;
133
130
 
134
131
  if (CLASS_OF(chrom) != Class_Chromaticity)
135
132
  {
136
133
  rb_raise(rb_eTypeError, "type mismatch: %s given",
137
134
  rb_class2name(CLASS_OF(chrom)));
138
135
  }
139
- values_id = rm_ID_values;
140
136
 
141
137
  // Get the struct members in an array
142
- chrom_members = rb_funcall(chrom, values_id, 0);
138
+ chrom_members = rb_funcall(chrom, rm_ID_values, 0);
143
139
  red_primary = rb_ary_entry(chrom_members, 0);
144
140
  green_primary = rb_ary_entry(chrom_members, 1);
145
141
  blue_primary = rb_ary_entry(chrom_members, 2);
146
142
  white_point = rb_ary_entry(chrom_members, 3);
147
143
 
148
144
  // Get the red_primary PrimaryInfo members in an array
149
- entry_members = rb_funcall(red_primary, values_id, 0);
145
+ entry_members = rb_funcall(red_primary, rm_ID_values, 0);
150
146
  x = rb_ary_entry(entry_members, 0); // red_primary.x
151
147
  ci->red_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
152
148
  y = rb_ary_entry(entry_members, 1); // red_primary.y
@@ -154,7 +150,7 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
154
150
  ci->red_primary.z = 0.0;
155
151
 
156
152
  // Get the green_primary PrimaryInfo members in an array
157
- entry_members = rb_funcall(green_primary, values_id, 0);
153
+ entry_members = rb_funcall(green_primary, rm_ID_values, 0);
158
154
  x = rb_ary_entry(entry_members, 0); // green_primary.x
159
155
  ci->green_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
160
156
  y = rb_ary_entry(entry_members, 1); // green_primary.y
@@ -162,7 +158,7 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
162
158
  ci->green_primary.z = 0.0;
163
159
 
164
160
  // Get the blue_primary PrimaryInfo members in an array
165
- entry_members = rb_funcall(blue_primary, values_id, 0);
161
+ entry_members = rb_funcall(blue_primary, rm_ID_values, 0);
166
162
  x = rb_ary_entry(entry_members, 0); // blue_primary.x
167
163
  ci->blue_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
168
164
  y = rb_ary_entry(entry_members, 1); // blue_primary.y
@@ -170,23 +166,28 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
170
166
  ci->blue_primary.z = 0.0;
171
167
 
172
168
  // Get the white_point PrimaryInfo members in an array
173
- entry_members = rb_funcall(white_point, values_id, 0);
169
+ entry_members = rb_funcall(white_point, rm_ID_values, 0);
174
170
  x = rb_ary_entry(entry_members, 0); // white_point.x
175
171
  ci->white_point.x = x == Qnil ? 0.0 : NUM2DBL(x);
176
172
  y = rb_ary_entry(entry_members, 1); // white_point.y
177
173
  ci->white_point.y = y == Qnil ? 0.0 : NUM2DBL(y);
178
174
  ci->white_point.z = 0.0;
175
+
176
+ RB_GC_GUARD(chrom_members);
177
+ RB_GC_GUARD(red_primary);
178
+ RB_GC_GUARD(green_primary);
179
+ RB_GC_GUARD(blue_primary);
180
+ RB_GC_GUARD(white_point);
181
+ RB_GC_GUARD(entry_members);
182
+ RB_GC_GUARD(x);
183
+ RB_GC_GUARD(y);
179
184
  }
180
185
 
181
186
 
182
187
  /**
183
- * Create a string representation of a Magick::Chromaticity.
188
+ * Return a string representation of a {Magick::Chromaticity} object.
184
189
  *
185
- * Ruby usage:
186
- * - @verbatim Magick::Chromaticity#to_s @endverbatim
187
- *
188
- * @param self this object
189
- * @return the string
190
+ * @return [String] the string
190
191
  */
191
192
  VALUE
192
193
  ChromaticityInfo_to_s(VALUE self)
@@ -195,7 +196,8 @@ ChromaticityInfo_to_s(VALUE self)
195
196
  char buff[200];
196
197
 
197
198
  Export_ChromaticityInfo(&ci, self);
198
- sprintf(buff, "red_primary=(x=%g,y=%g) "
199
+ snprintf(buff, sizeof(buff),
200
+ "red_primary=(x=%g,y=%g) "
199
201
  "green_primary=(x=%g,y=%g) "
200
202
  "blue_primary=(x=%g,y=%g) "
201
203
  "white_point=(x=%g,y=%g) ",
@@ -219,18 +221,22 @@ VALUE
219
221
  Import_ColorInfo(const ColorInfo *ci)
220
222
  {
221
223
  ComplianceType compliance_type;
222
- volatile VALUE name;
223
- volatile VALUE compliance;
224
- volatile VALUE color;
224
+ VALUE name;
225
+ VALUE compliance;
226
+ VALUE color;
225
227
 
226
228
  name = rb_str_new2(ci->name);
227
229
 
228
230
  compliance_type = ci->compliance;
229
- compliance = ComplianceType_new(compliance_type);
230
- color = Pixel_from_MagickPixelPacket(&(ci->color));
231
+ compliance = ComplianceType_find(compliance_type);
232
+ color = Pixel_from_MagickPixel(&(ci->color));
233
+
234
+ RB_GC_GUARD(name);
235
+ RB_GC_GUARD(compliance);
236
+ RB_GC_GUARD(color);
231
237
 
232
- return rb_funcall(Class_Color, rm_ID_new, 3
233
- , name, compliance, color);
238
+ return rb_funcall(Class_Color, rm_ID_new, 3,
239
+ name, compliance, color);
234
240
  }
235
241
 
236
242
 
@@ -245,8 +251,8 @@ Import_ColorInfo(const ColorInfo *ci)
245
251
  void
246
252
  Export_ColorInfo(ColorInfo *ci, VALUE st)
247
253
  {
248
- Pixel *pixel;
249
- volatile VALUE members, m;
254
+ PixelColor pixel;
255
+ VALUE members, m;
250
256
 
251
257
  if (CLASS_OF(st) != Class_Color)
252
258
  {
@@ -261,7 +267,7 @@ Export_ColorInfo(ColorInfo *ci, VALUE st)
261
267
  m = rb_ary_entry(members, 0);
262
268
  if (m != Qnil)
263
269
  {
264
- (void) CloneString((char **)&(ci->name), StringValuePtr(m));
270
+ CloneString((char **)&(ci->name), StringValueCStr(m));
265
271
  }
266
272
  m = rb_ary_entry(members, 1);
267
273
  if (m != Qnil)
@@ -271,45 +277,55 @@ Export_ColorInfo(ColorInfo *ci, VALUE st)
271
277
  m = rb_ary_entry(members, 2);
272
278
  if (m != Qnil)
273
279
  {
274
- Data_Get_Struct(m, Pixel, pixel);
280
+ Color_to_PixelColor(&pixel, m);
275
281
  // For >= 6.3.0, ColorInfo.color is a MagickPixelPacket so we have to
276
282
  // convert the PixelPacket.
277
- GetMagickPixelPacket(NULL, &ci->color);
278
- ci->color.red = (MagickRealType) pixel->red;
279
- ci->color.green = (MagickRealType) pixel->green;
280
- ci->color.blue = (MagickRealType) pixel->blue;
283
+ rm_init_magickpixel(NULL, &ci->color);
284
+ ci->color.red = (MagickRealType) pixel.red;
285
+ ci->color.green = (MagickRealType) pixel.green;
286
+ ci->color.blue = (MagickRealType) pixel.blue;
287
+ #if defined(IMAGEMAGICK_7)
288
+ ci->color.alpha = (MagickRealType) OpaqueAlpha;
289
+ #else
281
290
  ci->color.opacity = (MagickRealType) OpaqueOpacity;
291
+ #endif
282
292
  ci->color.index = (MagickRealType) 0;
283
293
  }
294
+
295
+ RB_GC_GUARD(members);
296
+ RB_GC_GUARD(m);
284
297
  }
285
298
 
286
299
 
287
300
  /**
288
- * Convert either a String color name or a Magick::Pixel to a MagickPixelPacket.
301
+ * Convert either a String color name or a Magick::Pixel to a MagickPixel.
289
302
  *
290
303
  * No Ruby usage (internal function)
291
304
  *
292
305
  * Notes:
293
- * - The channel values in a MagickPixelPacket are doubles.
306
+ * - The channel values in a MagickPixel are doubles.
294
307
  *
295
308
  * @param image the Image
296
- * @param mpp The MagickPixelPacket to modify
309
+ * @param mpp The MagickPixel to modify
297
310
  * @param color the name of the color
298
311
  */
299
312
  void
300
- Color_to_MagickPixelPacket(Image *image, MagickPixelPacket *mpp, VALUE color)
313
+ Color_to_MagickPixel(Image *image, MagickPixel *mpp, VALUE color)
301
314
  {
302
- PixelPacket pp;
315
+ PixelColor pp;
303
316
 
304
317
  // image can be NULL
305
- GetMagickPixelPacket(image, mpp);
318
+ rm_init_magickpixel(image, mpp);
306
319
 
307
- memset(&pp, '\0', sizeof(pp));
308
- Color_to_PixelPacket(&pp, color);
320
+ Color_to_PixelColor(&pp, color);
309
321
  mpp->red = (MagickRealType) pp.red;
310
322
  mpp->green = (MagickRealType) pp.green;
311
323
  mpp->blue = (MagickRealType) pp.blue;
324
+ #if defined(IMAGEMAGICK_7)
325
+ mpp->alpha = (MagickRealType) pp.alpha;
326
+ #else
312
327
  mpp->opacity = (MagickRealType) pp.opacity;
328
+ #endif
313
329
  }
314
330
 
315
331
 
@@ -330,13 +346,9 @@ destroy_ColorInfo(ColorInfo *ci)
330
346
 
331
347
 
332
348
  /**
333
- * Return a string representation of a Magick::Color object.
349
+ * Return a string representation of a {Magick::Color} object.
334
350
  *
335
- * Ruby usage:
336
- * - @verbatim Color#to_s @endverbatim
337
- *
338
- * @param self this object
339
- * @return the string
351
+ * @return [String] the string
340
352
  */
341
353
  VALUE
342
354
  Color_to_s(VALUE self)
@@ -346,90 +358,26 @@ Color_to_s(VALUE self)
346
358
 
347
359
  Export_ColorInfo(&ci, self);
348
360
 
349
- sprintf(buff, "name=%s, compliance=%s, "
350
- #if (QuantumDepth == 32 || QuantumDepth == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
351
- "color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.opacity=%Lg ",
361
+ snprintf(buff, sizeof(buff),
362
+ "name=%s, compliance=%s, "
363
+ #if (MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
364
+ "color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.alpha=%Lg ",
352
365
  #else
353
- "color.red=%g, color.green=%g, color.blue=%g, color.opacity=%g ",
366
+ "color.red=%g, color.green=%g, color.blue=%g, color.alpha=%g ",
354
367
  #endif
355
368
  ci.name,
356
369
  ComplianceType_name(&ci.compliance),
357
- ci.color.red, ci.color.green, ci.color.blue, ci.color.opacity);
370
+ ci.color.red, ci.color.green, ci.color.blue,
371
+ #if defined(IMAGEMAGICK_7)
372
+ ci.color.alpha);
373
+ #else
374
+ QuantumRange - ci.color.opacity);
375
+ #endif
358
376
 
359
377
  destroy_ColorInfo(&ci);
360
378
  return rb_str_new2(buff);
361
379
  }
362
380
 
363
-
364
- /**
365
- * Return the string representation of a ComplianceType value.
366
- *
367
- * No Ruby usage (internal function)
368
- *
369
- * Notes:
370
- * - xMagick will OR multiple compliance types so we have to arbitrarily pick
371
- * one name.
372
- * - Set the compliance argument to the selected value.
373
- *
374
- * @param c the ComplianceType value
375
- * @return the string
376
- */
377
- static const char *
378
- ComplianceType_name(ComplianceType *c)
379
- {
380
- if ((*c & (SVGCompliance|X11Compliance|XPMCompliance))
381
- == (SVGCompliance|X11Compliance|XPMCompliance))
382
- {
383
- return "AllCompliance";
384
- }
385
- else if (*c & SVGCompliance)
386
- {
387
- *c = SVGCompliance;
388
- return "SVGCompliance";
389
- }
390
- else if (*c & X11Compliance)
391
- {
392
- *c = X11Compliance;
393
- return "X11Compliance";
394
- }
395
- else if (*c & XPMCompliance)
396
- {
397
- *c = XPMCompliance;
398
- return "XPMCompliance";
399
- }
400
- else if (*c == NoCompliance)
401
- {
402
- *c = NoCompliance;
403
- return "NoCompliance";
404
- }
405
- else
406
- {
407
- *c = UndefinedCompliance;
408
- return "UndefinedCompliance";
409
- }
410
- }
411
-
412
-
413
- /**
414
- * Construct a ComplianceType enum object for the specified value.
415
- *
416
- * No Ruby usage (internal function)
417
- *
418
- * @param compliance the C ComplianceType value
419
- * @return the Ruby ComplianceType enum object
420
- */
421
- static VALUE
422
- ComplianceType_new(ComplianceType compliance)
423
- {
424
- const char *name;
425
-
426
- // Turn off undefined bits
427
- compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
428
- name = ComplianceType_name(&compliance);
429
- return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
430
- }
431
-
432
-
433
381
  /**
434
382
  * Convert a TypeInfo structure to a Magick::Font.
435
383
  *
@@ -441,23 +389,33 @@ ComplianceType_new(ComplianceType compliance)
441
389
  VALUE
442
390
  Import_TypeInfo(const TypeInfo *ti)
443
391
  {
444
- volatile VALUE name, description, family;
445
- volatile VALUE style, stretch, weight;
446
- volatile VALUE encoding, foundry, format;
392
+ VALUE name, description, family;
393
+ VALUE style, stretch, weight;
394
+ VALUE encoding, foundry, format;
447
395
 
448
396
  name = rb_str_new2(ti->name);
449
397
  family = rb_str_new2(ti->family);
450
- style = StyleType_new(ti->style);
451
- stretch = StretchType_new(ti->stretch);
398
+ style = StyleType_find(ti->style);
399
+ stretch = StretchType_find(ti->stretch);
452
400
  weight = ULONG2NUM(ti->weight);
453
401
  description = ti->description ? rb_str_new2(ti->description) : Qnil;
454
402
  encoding = ti->encoding ? rb_str_new2(ti->encoding) : Qnil;
455
403
  foundry = ti->foundry ? rb_str_new2(ti->foundry) : Qnil;
456
404
  format = ti->format ? rb_str_new2(ti->format) : Qnil;
457
405
 
458
- return rb_funcall(Class_Font, rm_ID_new, 9
459
- , name, description, family, style
460
- , stretch, weight, encoding, foundry, format);
406
+ RB_GC_GUARD(name);
407
+ RB_GC_GUARD(description);
408
+ RB_GC_GUARD(family);
409
+ RB_GC_GUARD(style);
410
+ RB_GC_GUARD(stretch);
411
+ RB_GC_GUARD(weight);
412
+ RB_GC_GUARD(encoding);
413
+ RB_GC_GUARD(foundry);
414
+ RB_GC_GUARD(format);
415
+
416
+ return rb_funcall(Class_Font, rm_ID_new, 9,
417
+ name, description, family, style,
418
+ stretch, weight, encoding, foundry, format);
461
419
  }
462
420
 
463
421
 
@@ -472,7 +430,7 @@ Import_TypeInfo(const TypeInfo *ti)
472
430
  void
473
431
  Export_TypeInfo(TypeInfo *ti, VALUE st)
474
432
  {
475
- volatile VALUE members, m;
433
+ VALUE members, m;
476
434
 
477
435
  if (CLASS_OF(st) != Class_Font)
478
436
  {
@@ -486,31 +444,34 @@ Export_TypeInfo(TypeInfo *ti, VALUE st)
486
444
  m = rb_ary_entry(members, 0);
487
445
  if (m != Qnil)
488
446
  {
489
- (void) CloneString((char **)&(ti->name), StringValuePtr(m));
447
+ CloneString((char **)&(ti->name), StringValueCStr(m));
490
448
  }
491
449
  m = rb_ary_entry(members, 1);
492
450
  if (m != Qnil)
493
451
  {
494
- (void) CloneString((char **)&(ti->description), StringValuePtr(m));
452
+ CloneString((char **)&(ti->description), StringValueCStr(m));
495
453
  }
496
454
  m = rb_ary_entry(members, 2);
497
455
  if (m != Qnil)
498
456
  {
499
- (void) CloneString((char **)&(ti->family), StringValuePtr(m));
457
+ CloneString((char **)&(ti->family), StringValueCStr(m));
500
458
  }
501
- m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(m);
502
- m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(m);
459
+ m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(Enum_to_i(m));
460
+ m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(Enum_to_i(m));
503
461
  m = rb_ary_entry(members, 5); ti->weight = m == Qnil ? 0 : FIX2INT(m);
504
462
 
505
463
  m = rb_ary_entry(members, 6);
506
464
  if (m != Qnil)
507
- (void) CloneString((char **)&(ti->encoding), StringValuePtr(m));
465
+ CloneString((char **)&(ti->encoding), StringValueCStr(m));
508
466
  m = rb_ary_entry(members, 7);
509
467
  if (m != Qnil)
510
- (void) CloneString((char **)&(ti->foundry), StringValuePtr(m));
468
+ CloneString((char **)&(ti->foundry), StringValueCStr(m));
511
469
  m = rb_ary_entry(members, 8);
512
470
  if (m != Qnil)
513
- (void) CloneString((char **)&(ti->format), StringValuePtr(m));
471
+ CloneString((char **)&(ti->format), StringValueCStr(m));
472
+
473
+ RB_GC_GUARD(members);
474
+ RB_GC_GUARD(m);
514
475
  }
515
476
 
516
477
 
@@ -541,12 +502,9 @@ destroy_TypeInfo(TypeInfo *ti)
541
502
 
542
503
 
543
504
  /**
544
- * Implement the Font#to_s method.
505
+ * Return a string representation of a {Magick::Font} object.
545
506
  *
546
- * No Ruby usage (internal function)
547
- *
548
- * @param self this object
549
- * @return the string
507
+ * @return [String] the string
550
508
  */
551
509
  VALUE
552
510
  Font_to_s(VALUE self)
@@ -566,11 +524,12 @@ Font_to_s(VALUE self)
566
524
  strcpy(weight, "BoldWeight");
567
525
  break;
568
526
  default:
569
- sprintf(weight, "%lu", ti.weight);
527
+ snprintf(weight, sizeof(weight), "%"RMIuSIZE"", ti.weight);
570
528
  break;
571
529
  }
572
530
 
573
- sprintf(buff, "name=%s, description=%s, "
531
+ snprintf(buff, sizeof(buff),
532
+ "name=%s, description=%s, "
574
533
  "family=%s, style=%s, stretch=%s, weight=%s, "
575
534
  "encoding=%s, foundry=%s, format=%s",
576
535
  ti.name,
@@ -600,8 +559,8 @@ Font_to_s(VALUE self)
600
559
  VALUE
601
560
  Import_PointInfo(PointInfo *p)
602
561
  {
603
- return rb_funcall(Class_Point, rm_ID_new, 2
604
- , INT2FIX(p->x), INT2FIX(p->y));
562
+ return rb_funcall(Class_Point, rm_ID_new, 2,
563
+ INT2FIX(p->x), INT2FIX(p->y));
605
564
  }
606
565
 
607
566
 
@@ -616,7 +575,7 @@ Import_PointInfo(PointInfo *p)
616
575
  void
617
576
  Export_PointInfo(PointInfo *pi, VALUE sp)
618
577
  {
619
- volatile VALUE members, m;
578
+ VALUE members, m;
620
579
 
621
580
  if (CLASS_OF(sp) != Class_Point)
622
581
  {
@@ -628,6 +587,9 @@ Export_PointInfo(PointInfo *pi, VALUE sp)
628
587
  pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
629
588
  m = rb_ary_entry(members, 1);
630
589
  pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
590
+
591
+ RB_GC_GUARD(members);
592
+ RB_GC_GUARD(m);
631
593
  }
632
594
 
633
595
 
@@ -642,8 +604,8 @@ Export_PointInfo(PointInfo *pi, VALUE sp)
642
604
  VALUE
643
605
  Import_PrimaryInfo(PrimaryInfo *p)
644
606
  {
645
- return rb_funcall(Class_Primary, rm_ID_new, 3
646
- , INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
607
+ return rb_funcall(Class_Primary, rm_ID_new, 3,
608
+ INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
647
609
  }
648
610
 
649
611
 
@@ -658,7 +620,7 @@ Import_PrimaryInfo(PrimaryInfo *p)
658
620
  void
659
621
  Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
660
622
  {
661
- volatile VALUE members, m;
623
+ VALUE members, m;
662
624
 
663
625
  if (CLASS_OF(sp) != Class_Primary)
664
626
  {
@@ -672,17 +634,16 @@ Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
672
634
  pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
673
635
  m = rb_ary_entry(members, 2);
674
636
  pi->z = m == Qnil ? 0.0 : NUM2DBL(m);
637
+
638
+ RB_GC_GUARD(members);
639
+ RB_GC_GUARD(m);
675
640
  }
676
641
 
677
642
 
678
643
  /**
679
- * Create a string representation of a Magick::PrimaryInfo.
680
- *
681
- * Ruby usage:
682
- * - @verbatim Magick::PrimaryInfo#to_s @endverbatim
644
+ * Return a string representation of a {Magick::PrimaryInfo} object.
683
645
  *
684
- * @param self this object
685
- * @return the string
646
+ * @return [String] the string
686
647
  */
687
648
  VALUE
688
649
  PrimaryInfo_to_s(VALUE self)
@@ -691,7 +652,7 @@ PrimaryInfo_to_s(VALUE self)
691
652
  char buff[100];
692
653
 
693
654
  Export_PrimaryInfo(&pi, self);
694
- sprintf(buff, "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
655
+ snprintf(buff, sizeof(buff), "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
695
656
  return rb_str_new2(buff);
696
657
  }
697
658
 
@@ -707,16 +668,22 @@ PrimaryInfo_to_s(VALUE self)
707
668
  VALUE
708
669
  Import_RectangleInfo(RectangleInfo *rect)
709
670
  {
710
- volatile VALUE width;
711
- volatile VALUE height;
712
- volatile VALUE x, y;
671
+ VALUE width;
672
+ VALUE height;
673
+ VALUE x, y;
713
674
 
714
675
  width = UINT2NUM(rect->width);
715
676
  height = UINT2NUM(rect->height);
716
677
  x = INT2NUM(rect->x);
717
678
  y = INT2NUM(rect->y);
718
- return rb_funcall(Class_Rectangle, rm_ID_new, 4
719
- , width, height, x, y);
679
+
680
+ RB_GC_GUARD(width);
681
+ RB_GC_GUARD(height);
682
+ RB_GC_GUARD(x);
683
+ RB_GC_GUARD(y);
684
+
685
+ return rb_funcall(Class_Rectangle, rm_ID_new, 4,
686
+ width, height, x, y);
720
687
  }
721
688
 
722
689
 
@@ -731,7 +698,7 @@ Import_RectangleInfo(RectangleInfo *rect)
731
698
  void
732
699
  Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
733
700
  {
734
- volatile VALUE members, m;
701
+ VALUE members, m;
735
702
 
736
703
  if (CLASS_OF(sr) != Class_Rectangle)
737
704
  {
@@ -747,17 +714,16 @@ Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
747
714
  rect->x = m == Qnil ? 0 : NUM2LONG (m);
748
715
  m = rb_ary_entry(members, 3);
749
716
  rect->y = m == Qnil ? 0 : NUM2LONG (m);
717
+
718
+ RB_GC_GUARD(members);
719
+ RB_GC_GUARD(m);
750
720
  }
751
721
 
752
722
 
753
723
  /**
754
- * Create a string representation of a Magick::Rectangle.
755
- *
756
- * Ruby usage:
757
- * - @verbatim Magick::Rectangle#to_s @endverbatim
724
+ * Return a string representation of a {Magick::Rectangle} object.
758
725
  *
759
- * @param self this object
760
- * @return the string
726
+ * @return [String] the string
761
727
  */
762
728
  VALUE
763
729
  RectangleInfo_to_s(VALUE self)
@@ -766,8 +732,8 @@ RectangleInfo_to_s(VALUE self)
766
732
  char buff[100];
767
733
 
768
734
  Export_RectangleInfo(&rect, self);
769
- sprintf(buff, "width=%lu, height=%lu, x=%ld, y=%ld"
770
- , rect.width, rect.height, rect.x, rect.y);
735
+ snprintf(buff, sizeof(buff), "width=%"RMIuSIZE", height=%"RMIuSIZE", x=%"RMIdSIZE", y=%"RMIdSIZE"",
736
+ rect.width, rect.height, rect.x, rect.y);
771
737
  return rb_str_new2(buff);
772
738
  }
773
739
 
@@ -783,12 +749,18 @@ RectangleInfo_to_s(VALUE self)
783
749
  VALUE
784
750
  Import_SegmentInfo(SegmentInfo *segment)
785
751
  {
786
- volatile VALUE x1, y1, x2, y2;
752
+ VALUE x1, y1, x2, y2;
787
753
 
788
754
  x1 = rb_float_new(segment->x1);
789
755
  y1 = rb_float_new(segment->y1);
790
756
  x2 = rb_float_new(segment->x2);
791
757
  y2 = rb_float_new(segment->y2);
758
+
759
+ RB_GC_GUARD(x1);
760
+ RB_GC_GUARD(y1);
761
+ RB_GC_GUARD(x2);
762
+ RB_GC_GUARD(y2);
763
+
792
764
  return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
793
765
  }
794
766
 
@@ -804,7 +776,7 @@ Import_SegmentInfo(SegmentInfo *segment)
804
776
  void
805
777
  Export_SegmentInfo(SegmentInfo *segment, VALUE s)
806
778
  {
807
- volatile VALUE members, m;
779
+ VALUE members, m;
808
780
 
809
781
  if (CLASS_OF(s) != Class_Segment)
810
782
  {
@@ -821,17 +793,16 @@ Export_SegmentInfo(SegmentInfo *segment, VALUE s)
821
793
  segment->x2 = m == Qnil ? 0.0 : NUM2DBL(m);
822
794
  m = rb_ary_entry(members, 3);
823
795
  segment->y2 = m == Qnil ? 0.0 : NUM2DBL(m);
796
+
797
+ RB_GC_GUARD(members);
798
+ RB_GC_GUARD(m);
824
799
  }
825
800
 
826
801
 
827
802
  /**
828
- * Create a string representation of a Magick::Segment.
829
- *
830
- * Ruby usage:
831
- * - @verbatim Magick::SegmentInfo#to_s @endverbatim
803
+ * Return a string representation of a {Magick::Segment} object.
832
804
  *
833
- * @param self this object
834
- * @return the string
805
+ * @return [String] the string
835
806
  */
836
807
  VALUE
837
808
  SegmentInfo_to_s(VALUE self)
@@ -840,98 +811,12 @@ SegmentInfo_to_s(VALUE self)
840
811
  char buff[100];
841
812
 
842
813
  Export_SegmentInfo(&segment, self);
843
- sprintf(buff, "x1=%g, y1=%g, x2=%g, y2=%g"
844
- , segment.x1, segment.y1, segment.x2, segment.y2);
814
+ snprintf(buff, sizeof(buff), "x1=%g, y1=%g, x2=%g, y2=%g",
815
+ segment.x1, segment.y1, segment.x2, segment.y2);
845
816
  return rb_str_new2(buff);
846
817
  }
847
818
 
848
819
 
849
- /**
850
- * Return the string representation of a StretchType value.
851
- *
852
- * No Ruby usage (internal function)
853
- *
854
- * @param stretch the StretchType value
855
- * @return the string
856
- */
857
- static const char *
858
- StretchType_name(StretchType stretch)
859
- {
860
- switch (stretch)
861
- {
862
- ENUM_TO_NAME(UndefinedStretch)
863
- ENUM_TO_NAME(NormalStretch)
864
- ENUM_TO_NAME(UltraCondensedStretch)
865
- ENUM_TO_NAME(ExtraCondensedStretch)
866
- ENUM_TO_NAME(CondensedStretch)
867
- ENUM_TO_NAME(SemiCondensedStretch)
868
- ENUM_TO_NAME(SemiExpandedStretch)
869
- ENUM_TO_NAME(ExpandedStretch)
870
- ENUM_TO_NAME(ExtraExpandedStretch)
871
- ENUM_TO_NAME(UltraExpandedStretch)
872
- ENUM_TO_NAME(AnyStretch)
873
- }
874
-
875
- return "UndefinedStretch";
876
- }
877
-
878
-
879
- /**
880
- * Construct a StretchType enum for a specified StretchType value.
881
- *
882
- * No Ruby usage (internal function)
883
- *
884
- * @param stretch the C StretchType value
885
- * @return a Ruby StretchType enum
886
- */
887
- static VALUE
888
- StretchType_new(StretchType stretch)
889
- {
890
- const char *name = StretchType_name(stretch);
891
- return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
892
- }
893
-
894
-
895
- /**
896
- * Return the string representation of a StyleType value.
897
- *
898
- * No Ruby usage (internal function)
899
- *
900
- * @param style the StyleType value
901
- * @return the string
902
- */
903
- static const char *
904
- StyleType_name(StyleType style)
905
- {
906
- switch (style)
907
- {
908
- ENUM_TO_NAME(UndefinedStyle)
909
- ENUM_TO_NAME(NormalStyle)
910
- ENUM_TO_NAME(ItalicStyle)
911
- ENUM_TO_NAME(ObliqueStyle)
912
- ENUM_TO_NAME(AnyStyle)
913
- }
914
-
915
- return "UndefinedStyle";
916
- }
917
-
918
-
919
- /**
920
- * Construct a StyleType enum for a specified StyleType value.
921
- *
922
- * No Ruby usage (internal function)
923
- *
924
- * @param style the C StyleType value
925
- * @return a Ruby StyleType enum
926
- */
927
- static VALUE
928
- StyleType_new(StyleType style)
929
- {
930
- const char *name = StyleType_name(style);
931
- return rm_enum_new(Class_StyleType, ID2SYM(rb_intern(name)), INT2FIX(style));
932
- }
933
-
934
-
935
820
  /**
936
821
  * Convert a TypeMetric structure to a Magick::TypeMetric.
937
822
  *
@@ -943,10 +828,10 @@ StyleType_new(StyleType style)
943
828
  VALUE
944
829
  Import_TypeMetric(TypeMetric *tm)
945
830
  {
946
- volatile VALUE pixels_per_em;
947
- volatile VALUE ascent, descent;
948
- volatile VALUE width, height, max_advance;
949
- volatile VALUE bounds, underline_position, underline_thickness;
831
+ VALUE pixels_per_em;
832
+ VALUE ascent, descent;
833
+ VALUE width, height, max_advance;
834
+ VALUE bounds, underline_position, underline_thickness;
950
835
 
951
836
  pixels_per_em = Import_PointInfo(&tm->pixels_per_em);
952
837
  ascent = rb_float_new(tm->ascent);
@@ -958,10 +843,20 @@ Import_TypeMetric(TypeMetric *tm)
958
843
  underline_position = rb_float_new(tm->underline_position);
959
844
  underline_thickness = rb_float_new(tm->underline_position);
960
845
 
961
- return rb_funcall(Class_TypeMetric, rm_ID_new, 9
962
- , pixels_per_em, ascent, descent, width
963
- , height, max_advance, bounds
964
- , underline_position, underline_thickness);
846
+ RB_GC_GUARD(pixels_per_em);
847
+ RB_GC_GUARD(ascent);
848
+ RB_GC_GUARD(descent);
849
+ RB_GC_GUARD(width);
850
+ RB_GC_GUARD(height);
851
+ RB_GC_GUARD(max_advance);
852
+ RB_GC_GUARD(bounds);
853
+ RB_GC_GUARD(underline_position);
854
+ RB_GC_GUARD(underline_thickness);
855
+
856
+ return rb_funcall(Class_TypeMetric, rm_ID_new, 9,
857
+ pixels_per_em, ascent, descent, width,
858
+ height, max_advance, bounds,
859
+ underline_position, underline_thickness);
965
860
  }
966
861
 
967
862
 
@@ -976,8 +871,8 @@ Import_TypeMetric(TypeMetric *tm)
976
871
  void
977
872
  Export_TypeMetric(TypeMetric *tm, VALUE st)
978
873
  {
979
- volatile VALUE members, m;
980
- volatile VALUE pixels_per_em;
874
+ VALUE members, m;
875
+ VALUE pixels_per_em;
981
876
 
982
877
  if (CLASS_OF(st) != Class_TypeMetric)
983
878
  {
@@ -1007,41 +902,43 @@ Export_TypeMetric(TypeMetric *tm, VALUE st)
1007
902
  tm->underline_position = m == Qnil ? 0.0 : NUM2DBL(m);
1008
903
  m = rb_ary_entry(members, 8);
1009
904
  tm->underline_thickness = m == Qnil ? 0.0 : NUM2DBL(m);
905
+
906
+ RB_GC_GUARD(members);
907
+ RB_GC_GUARD(m);
908
+ RB_GC_GUARD(pixels_per_em);
1010
909
  }
1011
910
 
1012
911
 
1013
912
  /**
1014
- * Create a string representation of a Magick::TypeMetric.
1015
- *
1016
- * Ruby usage:
1017
- * - @verbatim Magick::TypeMetric#to_s @endverbatim
913
+ * Return a string representation of a {Magick::TypeMetric} object.
1018
914
  *
1019
- * @param self this object
1020
- * @return the string
915
+ * @return [String] the string
1021
916
  */
1022
917
  VALUE
1023
918
  TypeMetric_to_s(VALUE self)
1024
919
  {
1025
- volatile VALUE str;
920
+ VALUE str;
1026
921
  TypeMetric tm;
1027
922
  char temp[200];
1028
923
  int len;
1029
924
 
1030
925
  Export_TypeMetric(&tm, self);
1031
926
 
1032
- len = sprintf(temp, "pixels_per_em=(x=%g,y=%g) ", tm.pixels_per_em.x, tm.pixels_per_em.y);
927
+ len = snprintf(temp, sizeof(temp), "pixels_per_em=(x=%g,y=%g) ", tm.pixels_per_em.x, tm.pixels_per_em.y);
1033
928
  str = rb_str_new(temp, len);
1034
- len = sprintf(temp, "ascent=%g descent=%g ",tm.ascent, tm.descent);
929
+ len = snprintf(temp, sizeof(temp), "ascent=%g descent=%g ",tm.ascent, tm.descent);
1035
930
  rb_str_cat(str, temp, len);
1036
- len = sprintf(temp, "width=%g height=%g max_advance=%g ", tm.width, tm.height, tm.max_advance);
931
+ len = snprintf(temp, sizeof(temp), "width=%g height=%g max_advance=%g ", tm.width, tm.height, tm.max_advance);
1037
932
  rb_str_cat(str, temp, len);
1038
- len = sprintf(temp, "bounds.x1=%g bounds.y1=%g ", tm.bounds.x1, tm.bounds.y1);
933
+ len = snprintf(temp, sizeof(temp), "bounds.x1=%g bounds.y1=%g ", tm.bounds.x1, tm.bounds.y1);
1039
934
  rb_str_cat(str, temp, len);
1040
- len = sprintf(temp, "bounds.x2=%g bounds.y2=%g ", tm.bounds.x2, tm.bounds.y2);
935
+ len = snprintf(temp, sizeof(temp), "bounds.x2=%g bounds.y2=%g ", tm.bounds.x2, tm.bounds.y2);
1041
936
  rb_str_cat(str, temp, len);
1042
- len = sprintf(temp, "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
937
+ len = snprintf(temp, sizeof(temp), "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
1043
938
  rb_str_cat(str, temp, len);
1044
939
 
940
+ RB_GC_GUARD(str);
941
+
1045
942
  return str;
1046
943
  }
1047
944