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
data/ext/RMagick/rmdraw.c CHANGED
@@ -18,19 +18,19 @@ static void destroy_Draw(void *);
18
18
  static VALUE new_DrawOptions(void);
19
19
 
20
20
  /** Method that gets type metrics */
21
- typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *);
21
+ #if defined(IMAGEMAGICK_7)
22
+ typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *, ExceptionInfo *);
23
+ #else
24
+ typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *);
25
+ #endif
22
26
  static VALUE get_type_metrics(int, VALUE *, VALUE, get_type_metrics_func_t);
23
27
 
24
28
 
25
29
  /**
26
- * Set the affine matrix from an Magick::AffineMatrix.
27
- *
28
- * Ruby usage:
29
- * - @verbatim Draw#affine= @endverbatim
30
+ * Set the affine matrix from an {Magick::AffineMatrix}.
30
31
  *
31
- * @param self this object
32
- * @param matrix the affine matrix to set
33
- * @return self
32
+ * @param matrix [Magick::AffineMatrix] the affine matrix
33
+ * @return [Magick::AffineMatrix] the given matrix
34
34
  */
35
35
  VALUE
36
36
  Draw_affine_eq(VALUE self, VALUE matrix)
@@ -40,19 +40,15 @@ Draw_affine_eq(VALUE self, VALUE matrix)
40
40
  rb_check_frozen(self);
41
41
  Data_Get_Struct(self, Draw, draw);
42
42
  Export_AffineMatrix(&draw->info->affine, matrix);
43
- return self;
43
+ return matrix;
44
44
  }
45
45
 
46
46
 
47
47
  /**
48
- * Set the text alignment.
48
+ * Set the text alignment from an {Magick::AlignType}.
49
49
  *
50
- * Ruby usage:
51
- * - @verbatim Draw#align= @endverbatim
52
- *
53
- * @param self this object
54
- * @param align the alignment
55
- * @return self
50
+ * @param align [Magick::AlignType] the text alignment
51
+ * @return [Magick::AlignType] the given align
56
52
  */
57
53
  VALUE
58
54
  Draw_align_eq(VALUE self, VALUE align)
@@ -62,19 +58,15 @@ Draw_align_eq(VALUE self, VALUE align)
62
58
  rb_check_frozen(self);
63
59
  Data_Get_Struct(self, Draw, draw);
64
60
  VALUE_TO_ENUM(align, draw->info->align, AlignType);
65
- return self;
61
+ return align;
66
62
  }
67
63
 
68
64
 
69
65
  /**
70
- * Decorate attribute writer.
66
+ * Set text decorate from an {Magick::DecorationType}.
71
67
  *
72
- * Ruby usage:
73
- * - @verbatim Draw#decorate= @endverbatim
74
- *
75
- * @param self this object
76
- * @param decorate the decorate
77
- * @return self
68
+ * @param decorate [Magick::DecorationType] the decorate type
69
+ * @return [Magick::DecorationType] the given decorate
78
70
  */
79
71
  VALUE
80
72
  Draw_decorate_eq(VALUE self, VALUE decorate)
@@ -84,19 +76,15 @@ Draw_decorate_eq(VALUE self, VALUE decorate)
84
76
  rb_check_frozen(self);
85
77
  Data_Get_Struct(self, Draw, draw);
86
78
  VALUE_TO_ENUM(decorate, draw->info->decorate, DecorationType);
87
- return self;
79
+ return decorate;
88
80
  }
89
81
 
90
82
 
91
83
  /**
92
- * Density attribute writer.
93
- *
94
- * Ruby usage:
95
- * - @verbatim Draw#density= @endverbatim
84
+ * Set density.
96
85
  *
97
- * @param self this object
98
- * @param density the density
99
- * @return self
86
+ * @param density [String] the density
87
+ * @return [String] the given density
100
88
  */
101
89
  VALUE
102
90
  Draw_density_eq(VALUE self, VALUE density)
@@ -105,21 +93,17 @@ Draw_density_eq(VALUE self, VALUE density)
105
93
 
106
94
  rb_check_frozen(self);
107
95
  Data_Get_Struct(self, Draw, draw);
108
- magick_clone_string(&draw->info->density, StringValuePtr(density));
96
+ magick_clone_string(&draw->info->density, StringValueCStr(density));
109
97
 
110
- return self;
98
+ return density;
111
99
  }
112
100
 
113
101
 
114
102
  /**
115
- * Encoding attribute writer.
116
- *
117
- * Ruby usage:
118
- * - @verbatim Draw#encoding= @endverbatim
103
+ * Set text encoding.
119
104
  *
120
- * @param self this object
121
- * @param encoding the encoding
122
- * @return self
105
+ * @param encoding [String] the encoding name
106
+ * @return [String] the given encoding name
123
107
  */
124
108
  VALUE
125
109
  Draw_encoding_eq(VALUE self, VALUE encoding)
@@ -128,21 +112,17 @@ Draw_encoding_eq(VALUE self, VALUE encoding)
128
112
 
129
113
  rb_check_frozen(self);
130
114
  Data_Get_Struct(self, Draw, draw);
131
- magick_clone_string(&draw->info->encoding, StringValuePtr(encoding));
115
+ magick_clone_string(&draw->info->encoding, StringValueCStr(encoding));
132
116
 
133
- return self;
117
+ return encoding;
134
118
  }
135
119
 
136
120
 
137
121
  /**
138
- * Fill attribute writer.
139
- *
140
- * Ruby usage:
141
- * - @verbatim Draw#fill= @endverbatim
122
+ * Set fill color.
142
123
  *
143
- * @param self this object
144
- * @param fill the fill
145
- * @return self
124
+ * @param fill [Magick::Pixel, String] the fill color
125
+ * @return [Magick::Pixel, String] the given fill color
146
126
  */
147
127
  VALUE
148
128
  Draw_fill_eq(VALUE self, VALUE fill)
@@ -151,28 +131,24 @@ Draw_fill_eq(VALUE self, VALUE fill)
151
131
 
152
132
  rb_check_frozen(self);
153
133
  Data_Get_Struct(self, Draw, draw);
154
- Color_to_PixelPacket(&draw->info->fill, fill);
155
- return self;
134
+ Color_to_PixelColor(&draw->info->fill, fill);
135
+ return fill;
156
136
  }
157
137
 
158
138
 
159
139
  /**
160
140
  * Accept an image as a fill pattern.
161
141
  *
162
- * Ruby usage:
163
- * - @verbatim Draw#fill_pattern= @endverbatim
164
- *
165
- * @param self this object
166
- * @param pattern the fill pattern
167
- * @return self
168
- * @see Draw_stroke_pattern_eq
169
- * @see Draw_tile_eq
142
+ * @param pattern [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
143
+ * imagelist, uses the current image.
144
+ * @return [Magick::Image] the given pattern image
145
+ * @see #stroke_pattern=
146
+ * @see #tile=
170
147
  */
171
148
  VALUE
172
149
  Draw_fill_pattern_eq(VALUE self, VALUE pattern)
173
150
  {
174
151
  Draw *draw;
175
- Image *image;
176
152
 
177
153
  rb_check_frozen(self);
178
154
  Data_Get_Struct(self, Draw, draw);
@@ -186,25 +162,23 @@ Draw_fill_pattern_eq(VALUE self, VALUE pattern)
186
162
 
187
163
  if (!NIL_P(pattern))
188
164
  {
165
+ Image *image;
166
+
189
167
  pattern = rm_cur_image(pattern);
190
168
  image = rm_check_destroyed(pattern);
191
169
  // Do not trace creation
192
170
  draw->info->fill_pattern = rm_clone_image(image);
193
171
  }
194
172
 
195
- return self;
173
+ return pattern;
196
174
  }
197
175
 
198
176
 
199
177
  /**
200
- * Font attribute writer.
178
+ * Set the font name.
201
179
  *
202
- * Ruby usage:
203
- * - @verbatim Draw#font= @endverbatim
204
- *
205
- * @param self this object
206
- * @param font the font
207
- * @return self
180
+ * @param font [String] the font name
181
+ * @return [String] the given font name
208
182
  */
209
183
  VALUE
210
184
  Draw_font_eq(VALUE self, VALUE font)
@@ -213,21 +187,17 @@ Draw_font_eq(VALUE self, VALUE font)
213
187
 
214
188
  rb_check_frozen(self);
215
189
  Data_Get_Struct(self, Draw, draw);
216
- magick_clone_string(&draw->info->font, StringValuePtr(font));
190
+ magick_clone_string(&draw->info->font, StringValueCStr(font));
217
191
 
218
- return self;
192
+ return font;
219
193
  }
220
194
 
221
195
 
222
196
  /**
223
- * Font family attribute writer.
197
+ * Set the font family name.
224
198
  *
225
- * Ruby usage:
226
- * - @verbatim Draw#family= @endverbatim
227
- *
228
- * @param self this object
229
- * @param family the family
230
- * @return self
199
+ * @param family [String] the font family name
200
+ * @return [String] the given family name
231
201
  */
232
202
  VALUE
233
203
  Draw_font_family_eq(VALUE self, VALUE family)
@@ -236,21 +206,17 @@ Draw_font_family_eq(VALUE self, VALUE family)
236
206
 
237
207
  rb_check_frozen(self);
238
208
  Data_Get_Struct(self, Draw, draw);
239
- magick_clone_string(&draw->info->family, StringValuePtr(family));
209
+ magick_clone_string(&draw->info->family, StringValueCStr(family));
240
210
 
241
- return self;
211
+ return family;
242
212
  }
243
213
 
244
214
 
245
215
  /**
246
- * Font_stretch attribute writer.
247
- *
248
- * Ruby usage:
249
- * - @verbatim Draw#font_stretch= @endverbatim
216
+ * Set the stretch as spacing between text characters.
250
217
  *
251
- * @param self this object
252
- * @param stretch the font_stretch
253
- * @return self
218
+ * @param stretch [Magick::StretchType] the stretch type
219
+ * @return [Magick::StretchType] the given stretch type
254
220
  */
255
221
  VALUE
256
222
  Draw_font_stretch_eq(VALUE self, VALUE stretch)
@@ -260,19 +226,15 @@ Draw_font_stretch_eq(VALUE self, VALUE stretch)
260
226
  rb_check_frozen(self);
261
227
  Data_Get_Struct(self, Draw, draw);
262
228
  VALUE_TO_ENUM(stretch, draw->info->stretch, StretchType);
263
- return self;
229
+ return stretch;
264
230
  }
265
231
 
266
232
 
267
233
  /**
268
- * Font_style attribute writer.
269
- *
270
- * Ruby usage:
271
- * - @verbatim Draw#font_style= @endverbatim
234
+ * Set font style.
272
235
  *
273
- * @param self this object
274
- * @param style the font_style
275
- * @return self
236
+ * @param style [Magick::StyleType] the font style
237
+ * @return [Magick::StyleType] the given font style
276
238
  */
277
239
  VALUE
278
240
  Draw_font_style_eq(VALUE self, VALUE style)
@@ -282,39 +244,32 @@ Draw_font_style_eq(VALUE self, VALUE style)
282
244
  rb_check_frozen(self);
283
245
  Data_Get_Struct(self, Draw, draw);
284
246
  VALUE_TO_ENUM(style, draw->info->style, StyleType);
285
- return self;
247
+ return style;
286
248
  }
287
249
 
288
250
 
289
251
  /**
290
- * Font_weight attribute writer.
291
- *
292
- * Ruby usage:
293
- * - @verbatim Draw#font_weight= @endverbatim
294
- *
295
- * Notes:
296
- * - The font weight can be one of the font weight constants or a number
297
- * between 100 and 900
252
+ * Set font weight.
298
253
  *
299
- * @param self this object
300
- * @param weight the font_weight
301
- * @return self
254
+ * @param weight [Magick::WeightType, Numeric] the font weight
255
+ * @return [Magick::WeightType, Numeric] the given font weight
256
+ * @note The font weight can be one of the font weight constants or a number between 100 and 900
302
257
  */
303
258
  VALUE
304
259
  Draw_font_weight_eq(VALUE self, VALUE weight)
305
260
  {
306
261
  Draw *draw;
307
- WeightType w;
262
+ size_t w;
308
263
 
309
264
  rb_check_frozen(self);
310
265
  Data_Get_Struct(self, Draw, draw);
311
266
 
312
267
  if (FIXNUM_P(weight))
313
268
  {
314
- w = (WeightType) FIX2INT(weight);
269
+ w = FIX2INT(weight);
315
270
  if (w < 100 || w > 900)
316
271
  {
317
- rb_raise(rb_eArgError, "invalid font weight (%d given)", w);
272
+ rb_raise(rb_eArgError, "invalid font weight (%"RMIuSIZE" given)", w);
318
273
  }
319
274
  draw->info->weight = w;
320
275
  }
@@ -346,32 +301,26 @@ Draw_font_weight_eq(VALUE self, VALUE weight)
346
301
  }
347
302
  }
348
303
 
349
- return self;
304
+ return weight;
350
305
  }
351
306
 
352
307
 
353
308
  /**
354
- * Gravity attribute writer.
355
- *
356
- * Ruby usage:
357
- * - @verbatim Draw#gravity= @endverbatim
358
- *
359
- * Notes:
360
- * - From Magick++'s Image.h header file:
361
- * Gravity affects text placement in bounding area according to rules:
362
- * - NorthWestGravity text bottom-left corner placed at top-left
363
- * - NorthGravity text bottom-center placed at top-center
364
- * - NorthEastGravity text bottom-right corner placed at top-right
365
- * - WestGravity text left-center placed at left-center
366
- * - CenterGravity text center placed at center
367
- * - EastGravity text right-center placed at right-center
368
- * - SouthWestGravity text top-left placed at bottom-left
369
- * - SouthGravity text top-center placed at bottom-center
370
- * - SouthEastGravity text top-right placed at bottom-right
371
- *
372
- * @param self this object
373
- * @param grav the gravity
374
- * @return self
309
+ * Set gravity to draw text.
310
+ * Gravity affects text placement in bounding area according to rules:
311
+ *
312
+ * - +NorthWestGravity+ - text bottom-left corner placed at top-left
313
+ * - +NorthGravity+ - text bottom-center placed at top-center
314
+ * - +NorthEastGravity+ - text bottom-right corner placed at top-right
315
+ * - +WestGravity+ - text left-center placed at left-center
316
+ * - +CenterGravity+ - text center placed at center
317
+ * - +EastGravity+ - text right-center placed at right-center
318
+ * - +SouthWestGravity+ - text top-left placed at bottom-left
319
+ * - +SouthGravity+ - text top-center placed at bottom-center
320
+ * - +SouthEastGravity+ - text top-right placed at bottom-right
321
+ *
322
+ * @param grav [Magick::GravityType] this gravity type
323
+ * @return [Magick::GravityType] the given gravity type
375
324
  */
376
325
  VALUE
377
326
  Draw_gravity_eq(VALUE self, VALUE grav)
@@ -382,103 +331,61 @@ Draw_gravity_eq(VALUE self, VALUE grav)
382
331
  Data_Get_Struct(self, Draw, draw);
383
332
  VALUE_TO_ENUM(grav, draw->info->gravity, GravityType);
384
333
 
385
- return self;
334
+ return grav;
386
335
  }
387
336
 
388
337
 
389
338
  /**
390
- * Space between two letters.
391
- *
392
- * Ruby usage:
393
- * - @verbatim Draw#gravity=float @endverbatim
394
- *
395
- * Notes:
396
- * - New for ImageMagick 6.4.7-8
339
+ * Set kerning as spacing between two letters.
397
340
  *
398
- * @param self this object
399
- * @param kerning the kerning
400
- * @return self
341
+ * @param kerning [Float] the kerning
342
+ * @return [Float] the given kerning
401
343
  */
402
344
  VALUE
403
345
  Draw_kerning_eq(VALUE self, VALUE kerning)
404
346
  {
405
- #if defined(HAVE_ST_KERNING)
406
347
  Draw *draw;
407
348
 
408
349
  rb_check_frozen(self);
409
350
  Data_Get_Struct(self, Draw, draw);
410
351
  draw->info->kerning = NUM2DBL(kerning);
411
- return self;
412
- #else
413
- rm_not_implemented();
414
- return (VALUE)0;
415
- self = self;
416
- kerning = kerning;
417
- #endif
352
+ return kerning;
418
353
  }
419
354
 
420
355
 
421
356
  /**
422
- * Space between two lines.
357
+ * Set spacing between two lines.
423
358
  *
424
- * Ruby usage:
425
- * - @verbatim Draw#interline_spacing= @endverbatim
426
- *
427
- * Notes:
428
- * - New for ImageMagick 6.5.5-8
429
- *
430
- * @param self this object
431
- * @param spacing the spacing
432
- * @return self
359
+ * @param spacing [Float] the spacing
360
+ * @return [Float] the given spacing
433
361
  */
434
362
  VALUE
435
363
  Draw_interline_spacing_eq(VALUE self, VALUE spacing)
436
364
  {
437
- #if defined(HAVE_ST_INTERLINE_SPACING)
438
365
  Draw *draw;
439
366
 
440
367
  rb_check_frozen(self);
441
368
  Data_Get_Struct(self, Draw, draw);
442
369
  draw->info->interline_spacing = NUM2DBL(spacing);
443
- return self;
444
- #else
445
- rm_not_implemented();
446
- return (VALUE)0;
447
- self = self;
448
- spacing = spacing;
449
- #endif
370
+ return spacing;
450
371
  }
451
372
 
452
373
 
453
374
  /**
454
- * Space between two words.
455
- *
456
- * Ruby usage:
457
- * - @verbatim Draw#interword_spacing= @endverbatim
458
- *
459
- * Notes:
460
- * - New for ImageMagick 6.4.8-0
375
+ * Set spacing between two words.
461
376
  *
462
- * @param self this object
463
- * @param spacing the spacing
464
- * @return self
377
+ * @param spacing [Float] the spacing
378
+ * @return [Float] the given spacing
465
379
  */
466
380
  VALUE
467
381
  Draw_interword_spacing_eq(VALUE self, VALUE spacing)
468
382
  {
469
- #if defined(HAVE_ST_INTERWORD_SPACING)
470
383
  Draw *draw;
471
384
 
472
385
  rb_check_frozen(self);
473
386
  Data_Get_Struct(self, Draw, draw);
474
387
  draw->info->interword_spacing = NUM2DBL(spacing);
475
- return self;
476
- #else
477
- rm_not_implemented();
478
- return (VALUE)0;
479
- self = self;
480
- spacing = spacing;
481
- #endif
388
+ return spacing;
482
389
  }
483
390
 
484
391
 
@@ -497,24 +404,27 @@ Draw_interword_spacing_eq(VALUE self, VALUE spacing)
497
404
  static VALUE
498
405
  image_to_str(Image *image)
499
406
  {
500
- volatile VALUE dimg = Qnil;
501
- unsigned char *blob;
502
- size_t length;
503
- Info *info;
504
- ExceptionInfo exception;
407
+ VALUE dimg = Qnil;
505
408
 
506
409
  if (image)
507
410
  {
411
+ unsigned char *blob;
412
+ size_t length;
413
+ Info *info;
414
+ ExceptionInfo *exception;
415
+
508
416
  info = CloneImageInfo(NULL);
509
- GetExceptionInfo(&exception);
510
- blob = ImageToBlob(info, image, &length, &exception);
417
+ exception = AcquireExceptionInfo();
418
+ blob = ImageToBlob(info, image, &length, exception);
511
419
  DestroyImageInfo(info);
512
420
  CHECK_EXCEPTION();
513
- DestroyExceptionInfo(&exception);
421
+ DestroyExceptionInfo(exception);
514
422
  dimg = rb_str_new((char *)blob, (long)length);
515
423
  magick_free((void*)blob);
516
424
  }
517
425
 
426
+ RB_GC_GUARD(dimg);
427
+
518
428
  return dimg;
519
429
  }
520
430
 
@@ -535,17 +445,18 @@ static
535
445
  Image *str_to_image(VALUE str)
536
446
  {
537
447
  Image *image = NULL;
538
- Info *info;
539
- ExceptionInfo exception;
540
448
 
541
449
  if (str != Qnil)
542
450
  {
451
+ Info *info;
452
+ ExceptionInfo *exception;
453
+
543
454
  info = CloneImageInfo(NULL);
544
- GetExceptionInfo(&exception);
545
- image = BlobToImage(info, RSTRING_PTR(str), RSTRING_LEN(str), &exception);
455
+ exception = AcquireExceptionInfo();
456
+ image = BlobToImage(info, RSTRING_PTR(str), RSTRING_LEN(str), exception);
546
457
  DestroyImageInfo(info);
547
458
  CHECK_EXCEPTION();
548
- DestroyExceptionInfo(&exception);
459
+ DestroyExceptionInfo(exception);
549
460
  }
550
461
 
551
462
  return image;
@@ -553,21 +464,16 @@ Image *str_to_image(VALUE str)
553
464
 
554
465
 
555
466
  /**
556
- * Custom marshal for Draw objects.
467
+ * Dump custom marshal for Draw objects.
557
468
  *
558
- * Ruby usage:
559
- * - @verbatim Draw#marshal_dump @endverbatim
469
+ * - Instead of trying to replicate Ruby's support for cross-system
470
+ * marshalling, exploit it. Convert the Draw fields to Ruby objects and
471
+ * store them in a hash. Let Ruby marshal the hash.
472
+ * - Commented out code that dumps/loads fields that are used internally by
473
+ * ImageMagick and shouldn't be marshaled. I left the code as placeholders
474
+ * so I'll know which fields have been deliberately omitted.
560
475
  *
561
- * Notes:
562
- * - Instead of trying to replicate Ruby's support for cross-system
563
- * marshalling, exploit it. Convert the Draw fields to Ruby objects and
564
- * store them in a hash. Let Ruby marshal the hash.
565
- * - Commented out code that dumps/loads fields that are used internally by
566
- * ImageMagick and shouldn't be marshaled. I left the code as placeholders
567
- * so I'll know which fields have been deliberately omitted.
568
- *
569
- * @param self this object
570
- * @return the marshalled object (as a Ruby hash)
476
+ * @return [Hash] the marshalled object
571
477
  * @todo Handle gradients when christy gets the new gradient support added (23Dec08)
572
478
  */
573
479
  VALUE
@@ -592,8 +498,8 @@ Draw_marshal_dump(VALUE self)
592
498
  // rb_hash_aset(ddraw, CSTR2SYM("viewbox"), Import_RectangleInfo(&draw->info->viewbox)); internal
593
499
  rb_hash_aset(ddraw, CSTR2SYM("affine"), Import_AffineMatrix(&draw->info->affine));
594
500
  rb_hash_aset(ddraw, CSTR2SYM("gravity"), INT2FIX(draw->info->gravity));
595
- rb_hash_aset(ddraw, CSTR2SYM("fill"), Pixel_from_PixelPacket(&draw->info->fill));
596
- rb_hash_aset(ddraw, CSTR2SYM("stroke"), Pixel_from_PixelPacket(&draw->info->stroke));
501
+ rb_hash_aset(ddraw, CSTR2SYM("fill"), Pixel_from_PixelColor(&draw->info->fill));
502
+ rb_hash_aset(ddraw, CSTR2SYM("stroke"), Pixel_from_PixelColor(&draw->info->stroke));
597
503
  rb_hash_aset(ddraw, CSTR2SYM("stroke_width"), rb_float_new(draw->info->stroke_width));
598
504
  // rb_hash_aset(ddraw, CSTR2SYM("gradient"), Qnil); // not used yet
599
505
  rb_hash_aset(ddraw, CSTR2SYM("fill_pattern"), image_to_str(draw->info->fill_pattern));
@@ -620,61 +526,54 @@ Draw_marshal_dump(VALUE self)
620
526
  rb_hash_aset(ddraw, CSTR2SYM("pointsize"), rb_float_new(draw->info->pointsize));
621
527
  rb_hash_aset(ddraw, CSTR2SYM("density"), MAGICK_STRING_TO_OBJ(draw->info->density));
622
528
  rb_hash_aset(ddraw, CSTR2SYM("align"), INT2FIX(draw->info->align));
623
- rb_hash_aset(ddraw, CSTR2SYM("undercolor"), Pixel_from_PixelPacket(&draw->info->undercolor));
624
- // rb_hash_aset(ddraw, CSTR2SYM("border_color"), Pixel_from_PixelPacket(&draw->info->border_color)); Montage and Polaroid
529
+ rb_hash_aset(ddraw, CSTR2SYM("undercolor"), Pixel_from_PixelColor(&draw->info->undercolor));
530
+ // rb_hash_aset(ddraw, CSTR2SYM("border_color"), Pixel_from_PixelColor(&draw->info->border_color)); Montage and Polaroid
625
531
  // rb_hash_aset(ddraw, CSTR2SYM("server_name"), MAGICK_STRING_TO_OBJ(draw->info->server_name));
626
532
  // rb_hash_aset(ddraw, CSTR2SYM("dash_pattern"), dash_pattern_to_array(draw->info->dash_pattern)); internal
627
533
  // rb_hash_aset(ddraw, CSTR2SYM("clip_mask"), MAGICK_STRING_TO_OBJ(draw->info->clip_mask)); internal
628
534
  // rb_hash_aset(ddraw, CSTR2SYM("bounds"), Import_SegmentInfo(&draw->info->bounds)); internal
629
535
  rb_hash_aset(ddraw, CSTR2SYM("clip_units"), INT2FIX(draw->info->clip_units));
536
+ #if defined(IMAGEMAGICK_7)
537
+ rb_hash_aset(ddraw, CSTR2SYM("alpha"), QUANTUM2NUM(draw->info->alpha));
538
+ #else
630
539
  rb_hash_aset(ddraw, CSTR2SYM("opacity"), QUANTUM2NUM(draw->info->opacity));
540
+ #endif
631
541
  // rb_hash_aset(ddraw, CSTR2SYM("render"), draw->info->render ? Qtrue : Qfalse); internal
632
542
  // rb_hash_aset(ddraw, CSTR2SYM("element_reference"), Qnil); // not used yet
633
543
  // rb_hash_aset(ddraw, CSTR2SYM("debug"), draw->info->debug ? Qtrue : Qfalse);
634
- #if defined(HAVE_ST_KERNING)
635
544
  rb_hash_aset(ddraw, CSTR2SYM("kerning"), rb_float_new(draw->info->kerning));
636
- #endif
637
- #if defined(HAVE_ST_INTERWORD_SPACING)
638
545
  rb_hash_aset(ddraw, CSTR2SYM("interword_spacing"), rb_float_new(draw->info->interword_spacing));
639
- #endif
640
546
 
641
547
  // Non-DrawInfo fields
642
548
  rb_hash_aset(ddraw, CSTR2SYM("primitives"), draw->primitives);
643
- // rb_hash_aset(ddraw, CSTR2SYM("shadow_color"), Pixel_from_PixelPacket(&draw->shadow_color)); Polaroid-only
549
+ // rb_hash_aset(ddraw, CSTR2SYM("shadow_color"), Pixel_from_PixelColor(&draw->shadow_color)); Polaroid-only
644
550
 
645
551
  return ddraw;
646
552
  }
647
553
 
648
554
 
649
555
  /**
650
- * Support Marsal.load.
556
+ * Load the marshalled object
651
557
  *
652
- * Ruby usage:
653
- * - @verbatim Draw#marshal_load @endverbatim
654
- *
655
- * Notes:
656
- * - On entry all fields are all-bits-0
657
- *
658
- * @param self this object
659
- * @param ddraw the marshalled object
660
- * @return self, once marshalled
558
+ * @param ddraw [Hash] the marshalled object
559
+ * @return [Magick::Draw] self, once marshalled
661
560
  */
662
561
  VALUE
663
562
  Draw_marshal_load(VALUE self, VALUE ddraw)
664
563
  {
665
564
  Draw *draw;
666
- Pixel *pixel;
667
- volatile VALUE val;
565
+ VALUE val;
668
566
 
669
567
  Data_Get_Struct(self, Draw, draw);
670
-
671
- draw->info = magick_malloc(sizeof(DrawInfo));
672
- if (!draw->info)
568
+
569
+ if (draw->info == NULL)
673
570
  {
674
- rb_raise(rb_eNoMemError, "not enough memory to continue");
675
- }
676
- GetDrawInfo(NULL, draw->info);
571
+ ImageInfo *image_info;
677
572
 
573
+ image_info = CloneImageInfo(NULL);
574
+ draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
575
+ DestroyImageInfo(image_info);
576
+ }
678
577
  OBJ_TO_MAGICK_STRING(draw->info->geometry, rb_hash_aref(ddraw, CSTR2SYM("geometry")));
679
578
 
680
579
  //val = rb_hash_aref(ddraw, CSTR2SYM("viewbox"));
@@ -686,12 +585,10 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
686
585
  draw->info->gravity = (GravityType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("gravity")));
687
586
 
688
587
  val = rb_hash_aref(ddraw, CSTR2SYM("fill"));
689
- Data_Get_Struct(val, Pixel, pixel);
690
- draw->info->fill = *pixel;
588
+ Color_to_PixelColor(&draw->info->fill, val);
691
589
 
692
590
  val = rb_hash_aref(ddraw, CSTR2SYM("stroke"));
693
- Data_Get_Struct(val, Pixel, pixel);
694
- draw->info->stroke = *pixel;
591
+ Color_to_PixelColor(&draw->info->stroke, val);
695
592
 
696
593
  draw->info->stroke_width = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("stroke_width")));
697
594
  draw->info->fill_pattern = str_to_image(rb_hash_aref(ddraw, CSTR2SYM("fill_pattern")));
@@ -711,33 +608,30 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
711
608
  draw->info->align = (AlignType) FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("align")));
712
609
 
713
610
  val = rb_hash_aref(ddraw, CSTR2SYM("undercolor"));
714
- Data_Get_Struct(val, Pixel, pixel);
715
- draw->info->undercolor = *pixel;
611
+ Color_to_PixelColor(&draw->info->undercolor, val);
716
612
 
717
613
  draw->info->clip_units = FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units")));
614
+ #if defined(IMAGEMAGICK_7)
615
+ draw->info->alpha = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("alpha")));
616
+ #else
718
617
  draw->info->opacity = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("opacity")));
719
- #if defined(HAVE_ST_KERNING)
720
- draw->info->kerning = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("kerning")));
721
618
  #endif
722
- #if defined(HAVE_ST_INTERWORD_SPACING)
619
+ draw->info->kerning = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("kerning")));
723
620
  draw->info->interword_spacing = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("interword_spacing")));
724
- #endif
725
621
 
726
622
  draw->primitives = rb_hash_aref(ddraw, CSTR2SYM("primitives"));
727
623
 
624
+ RB_GC_GUARD(val);
625
+
728
626
  return self;
729
627
  }
730
628
 
731
629
 
732
630
  /**
733
- * Pointsize attribute writer.
631
+ * Set point size to draw text.
734
632
  *
735
- * Ruby usage:
736
- * - @verbatim Draw#pointsize= @endverbatim
737
- *
738
- * @param self this object
739
- * @param pointsize the pointsize
740
- * @return self
633
+ * @param pointsize [Float] the pointsize
634
+ * @return [Float] the given pointsize
741
635
  */
742
636
  VALUE
743
637
  Draw_pointsize_eq(VALUE self, VALUE pointsize)
@@ -747,24 +641,15 @@ Draw_pointsize_eq(VALUE self, VALUE pointsize)
747
641
  rb_check_frozen(self);
748
642
  Data_Get_Struct(self, Draw, draw);
749
643
  draw->info->pointsize = NUM2DBL(pointsize);
750
- return self;
644
+ return pointsize;
751
645
  }
752
646
 
753
647
 
754
648
  /**
755
- * Set rotation attribute value.
756
- *
757
- * Ruby usage:
758
- * - @verbatim Magick::Draw#rotation= @endverbatim
649
+ * Set rotation. The argument should be in degrees.
759
650
  *
760
- * Notes:
761
- * - Argument should be in degrees
762
- * - Taken from Magick++'s Magick::Image::annotate method.
763
- * Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
764
- *
765
- * @param self this object
766
- * @param deg the number of degrees
767
- * @return self
651
+ * @param deg [Float] the number of degrees
652
+ * @return [Float] the given degrees
768
653
  */
769
654
  VALUE
770
655
  Draw_rotation_eq(VALUE self, VALUE deg)
@@ -779,39 +664,30 @@ Draw_rotation_eq(VALUE self, VALUE deg)
779
664
  degrees = NUM2DBL(deg);
780
665
  if (fabs(degrees) > DBL_EPSILON)
781
666
  {
782
- affine.sx=1.0;
783
- affine.rx=0.0;
784
- affine.ry=0.0;
785
- affine.sy=1.0;
786
- affine.tx=0.0;
787
- affine.ty=0.0;
788
-
789
- current = draw->info->affine;
790
- affine.sx=cos(DegreesToRadians(fmod(degrees,360.0)));
791
- affine.rx=sin(DegreesToRadians(fmod(degrees,360.0)));
792
- affine.ry=(-sin(DegreesToRadians(fmod(degrees,360.0))));
793
- affine.sy=cos(DegreesToRadians(fmod(degrees,360.0)));
794
-
795
- draw->info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
796
- draw->info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
797
- draw->info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
798
- draw->info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
799
- draw->info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
667
+ current = draw->info->affine;
668
+ affine.sx = cos(DegreesToRadians(fmod(degrees, 360.0)));
669
+ affine.rx = sin(DegreesToRadians(fmod(degrees, 360.0)));
670
+ affine.tx = 0.0;
671
+ affine.ry = (-sin(DegreesToRadians(fmod(degrees, 360.0))));
672
+ affine.sy = cos(DegreesToRadians(fmod(degrees, 360.0)));
673
+ affine.ty = 0.0;
674
+
675
+ draw->info->affine.sx = current.sx*affine.sx+current.ry*affine.rx;
676
+ draw->info->affine.rx = current.rx*affine.sx+current.sy*affine.rx;
677
+ draw->info->affine.ry = current.sx*affine.ry+current.ry*affine.sy;
678
+ draw->info->affine.sy = current.rx*affine.ry+current.sy*affine.sy;
679
+ draw->info->affine.tx = current.sx*affine.tx+current.ry*affine.ty+current.tx;
800
680
  }
801
681
 
802
- return self;
682
+ return deg;
803
683
  }
804
684
 
805
685
 
806
686
  /**
807
- * Stroke attribute writer.
808
- *
809
- * Ruby usage:
810
- * - @verbatim Draw#stroke= @endverbatim
687
+ * Set stroke.
811
688
  *
812
- * @param self this object
813
- * @param stroke the stroke
814
- * @return self
689
+ * @param stroke [Magick::Pixel, String] the stroke
690
+ * @return [Magick::Pixel, String] the given stroke
815
691
  */
816
692
  VALUE
817
693
  Draw_stroke_eq(VALUE self, VALUE stroke)
@@ -820,27 +696,23 @@ Draw_stroke_eq(VALUE self, VALUE stroke)
820
696
 
821
697
  rb_check_frozen(self);
822
698
  Data_Get_Struct(self, Draw, draw);
823
- Color_to_PixelPacket(&draw->info->stroke, stroke);
824
- return self;
699
+ Color_to_PixelColor(&draw->info->stroke, stroke);
700
+ return stroke;
825
701
  }
826
702
 
827
703
 
828
704
  /**
829
705
  * Accept an image as a stroke pattern.
830
706
  *
831
- * Ruby usage:
832
- * - @verbatim Draw#stroke_pattern= @endverbatim
833
- *
834
- * @param self this object
835
- * @param pattern the pattern
836
- * @return self
837
- * @see Draw_fill_pattern_eq
707
+ * @param pattern [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
708
+ * imagelist, uses the current image.
709
+ * @return [Magick::Image] the given pattern
710
+ * @see #fill_pattern
838
711
  */
839
712
  VALUE
840
713
  Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
841
714
  {
842
715
  Draw *draw;
843
- Image *image;
844
716
 
845
717
  rb_check_frozen(self);
846
718
  Data_Get_Struct(self, Draw, draw);
@@ -854,6 +726,8 @@ Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
854
726
 
855
727
  if (!NIL_P(pattern))
856
728
  {
729
+ Image *image;
730
+
857
731
  // DestroyDrawInfo destroys the clone
858
732
  pattern = rm_cur_image(pattern);
859
733
  image = rm_check_destroyed(pattern);
@@ -861,19 +735,15 @@ Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
861
735
  draw->info->stroke_pattern = rm_clone_image(image);
862
736
  }
863
737
 
864
- return self;
738
+ return pattern;
865
739
  }
866
740
 
867
741
 
868
742
  /**
869
- * Stroke_width attribute writer.
870
- *
871
- * Ruby usage:
872
- * - @verbatim Draw#stroke_width= @endverbatim
743
+ * Set stroke width.
873
744
  *
874
- * @param self this object
875
- * @param stroke_width the stroke_width
876
- * @return self
745
+ * @param stroke_width [Float] the stroke width
746
+ * @return [Float] the given stroke width
877
747
  */
878
748
  VALUE
879
749
  Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
@@ -883,19 +753,15 @@ Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
883
753
  rb_check_frozen(self);
884
754
  Data_Get_Struct(self, Draw, draw);
885
755
  draw->info->stroke_width = NUM2DBL(stroke_width);
886
- return self;
756
+ return stroke_width;
887
757
  }
888
758
 
889
759
 
890
760
  /**
891
- * Text_antialias attribute writer.
892
- *
893
- * Ruby usage:
894
- * - @verbatim Draw#text_antialias= @endverbatim
761
+ * Set whether to enable text antialias.
895
762
  *
896
- * @param self this object
897
- * @param text_antialias the text_antialias
898
- * @return self
763
+ * @param text_antialias [Boolean] true if enable text antialias
764
+ * @return [Boolean] the given value
899
765
  */
900
766
  VALUE
901
767
  Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
@@ -905,19 +771,15 @@ Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
905
771
  rb_check_frozen(self);
906
772
  Data_Get_Struct(self, Draw, draw);
907
773
  draw->info->text_antialias = (MagickBooleanType) RTEST(text_antialias);
908
- return self;
774
+ return text_antialias;
909
775
  }
910
776
 
911
777
 
912
778
  /**
913
- * Tile attribute writer.
779
+ * Accept an image as a fill pattern. This is alias of {Draw#fill_pattern=}.
914
780
  *
915
- * Ruby usage:
916
- * - @verbatim Draw#tile= @endverbatim
917
- *
918
- * @param self this object
919
- * @param image the image to tile
920
- * @return self
781
+ * @param image [Magick::Image] the image to tile
782
+ * @return [Magick::Image] the given image
921
783
  */
922
784
  VALUE
923
785
  Draw_tile_eq(VALUE self, VALUE image)
@@ -927,14 +789,10 @@ Draw_tile_eq(VALUE self, VALUE image)
927
789
 
928
790
 
929
791
  /**
930
- * Undercolor attribute writer.
792
+ * Set undercolor.
931
793
  *
932
- * Ruby usage:
933
- * - @verbatim Draw#undercolor= @endverbatim
934
- *
935
- * @param self this object
936
- * @param undercolor the undercolor
937
- * @return self
794
+ * @param undercolor [Magick::Pixel, String] the undercolor
795
+ * @return [Magick::Pixel, String] the given undercolor
938
796
  */
939
797
  VALUE
940
798
  Draw_undercolor_eq(VALUE self, VALUE undercolor)
@@ -943,29 +801,25 @@ Draw_undercolor_eq(VALUE self, VALUE undercolor)
943
801
 
944
802
  rb_check_frozen(self);
945
803
  Data_Get_Struct(self, Draw, draw);
946
- Color_to_PixelPacket(&draw->info->undercolor, undercolor);
947
- return self;
804
+ Color_to_PixelColor(&draw->info->undercolor, undercolor);
805
+ return undercolor;
948
806
  }
949
807
 
950
808
 
951
809
  /**
952
810
  * Annotates an image with text.
953
811
  *
954
- * Ruby usage:
955
- * - @verbatim Draw#annotate(img, w, h, x, y, text) <{optional parms}> @endverbatim
956
- *
957
- * Notes:
958
- * - Additional Draw attribute methods may be called in the optional block,
959
- * which is executed in the context of an Draw object.
960
- *
961
- * @param self this object
962
- * @param image_arg the image
963
- * @param width_arg the width
964
- * @param height_arg the height
965
- * @param x_arg x position
966
- * @param y_arg y position
967
- * @param text the annotation text
968
- * @return self
812
+ * - Additional Draw attribute methods may be called in the optional block,
813
+ * which is executed in the context of an Draw object.
814
+ *
815
+ * @param image_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
816
+ * imagelist, uses the current image.
817
+ * @param width_arg [Numeric] the width
818
+ * @param height_arg [Numeric] the height
819
+ * @param x_arg [Numeric] x position
820
+ * @param y_arg [Numeric] y position
821
+ * @param text [String] the annotation text
822
+ * @return [Magick::Draw] self
969
823
  */
970
824
  VALUE Draw_annotate(
971
825
  VALUE self,
@@ -981,7 +835,11 @@ VALUE Draw_annotate(
981
835
  unsigned long width, height;
982
836
  long x, y;
983
837
  AffineMatrix keep;
984
- char geometry_str[50];
838
+ char geometry_str[100];
839
+ char *embed_text;
840
+ #if defined(IMAGEMAGICK_7)
841
+ ExceptionInfo *exception;
842
+ #endif
985
843
 
986
844
  // Save the affine matrix in case it is modified by
987
845
  // Draw#rotation=
@@ -995,13 +853,38 @@ VALUE Draw_annotate(
995
853
  // allowing the app a chance to modify the object's attributes
996
854
  if (rb_block_given_p())
997
855
  {
998
- (void)rb_obj_instance_eval(0, NULL, self);
856
+ if (rb_proc_arity(rb_block_proc()) == 0)
857
+ {
858
+ // Run the block in self's context
859
+ rb_obj_instance_eval(0, NULL, self);
860
+ }
861
+ else
862
+ {
863
+ rb_yield(self);
864
+ }
999
865
  }
1000
866
 
1001
867
  // Translate & store in Draw structure
1002
- draw->info->text = InterpretImageProperties(NULL, image, StringValuePtr(text));
868
+ embed_text = StringValueCStr(text);
869
+ #if defined(IMAGEMAGICK_7)
870
+ exception = AcquireExceptionInfo();
871
+ draw->info->text = InterpretImageProperties(NULL, image, embed_text, exception);
872
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
873
+ {
874
+ if (draw->info->text)
875
+ {
876
+ magick_free(draw->info->text);
877
+ }
878
+ rm_raise_exception(exception);
879
+ }
880
+ #else
881
+ draw->info->text = InterpretImageProperties(NULL, image, embed_text);
882
+ #endif
1003
883
  if (!draw->info->text)
1004
884
  {
885
+ #if defined(IMAGEMAGICK_7)
886
+ DestroyExceptionInfo(exception);
887
+ #endif
1005
888
  rb_raise(rb_eArgError, "no text");
1006
889
  }
1007
890
 
@@ -1014,24 +897,33 @@ VALUE Draw_annotate(
1014
897
 
1015
898
  if (width == 0 && height == 0)
1016
899
  {
1017
- sprintf(geometry_str, "%+ld%+ld", x, y);
900
+ snprintf(geometry_str, sizeof(geometry_str), "%+ld%+ld", x, y);
1018
901
  }
1019
902
 
1020
903
  // WxH is non-zero
1021
904
  else
1022
905
  {
1023
- sprintf(geometry_str, "%lux%lu%+ld%+ld", width, height, x, y);
906
+ snprintf(geometry_str, sizeof(geometry_str), "%lux%lu%+ld%+ld", width, height, x, y);
1024
907
  }
1025
908
 
1026
909
  magick_clone_string(&draw->info->geometry, geometry_str);
1027
910
 
1028
- (void) AnnotateImage(image, draw->info);
911
+ #if defined(IMAGEMAGICK_7)
912
+ AnnotateImage(image, draw->info, exception);
913
+ #else
914
+ AnnotateImage(image, draw->info);
915
+ #endif
1029
916
 
1030
917
  magick_free(draw->info->text);
1031
918
  draw->info->text = NULL;
1032
919
  draw->info->affine = keep;
1033
920
 
921
+ #if defined(IMAGEMAGICK_7)
922
+ CHECK_EXCEPTION();
923
+ DestroyExceptionInfo(exception);
924
+ #else
1034
925
  rm_check_image_exception(image, RetainOnError);
926
+ #endif
1035
927
 
1036
928
  return self;
1037
929
  }
@@ -1040,18 +932,12 @@ VALUE Draw_annotate(
1040
932
  /**
1041
933
  * Clones this object.
1042
934
  *
1043
- * Ruby usage:
1044
- * - @verbatim Draw#clone @endverbatim
1045
- *
1046
- * @param self this object
1047
- * @return the clone
1048
- * @see Draw_dup
1049
- * @see Draw_init_copy
935
+ * @return [Magick::Draw] the cloned object
1050
936
  */
1051
937
  VALUE
1052
938
  Draw_clone(VALUE self)
1053
939
  {
1054
- volatile VALUE clone;
940
+ VALUE clone;
1055
941
 
1056
942
  clone = Draw_dup(self);
1057
943
  if (OBJ_FROZEN(self))
@@ -1059,35 +945,44 @@ Draw_clone(VALUE self)
1059
945
  OBJ_FREEZE(clone);
1060
946
  }
1061
947
 
948
+ RB_GC_GUARD(clone);
949
+
1062
950
  return clone;
1063
951
  }
1064
952
 
1065
953
 
1066
954
  /**
1067
- * Implement the "image" drawing primitive.
1068
- *
1069
- * Ruby usage:
1070
- * - @verbatim Draw#composite(x,y,width,height,img) @endverbatim
1071
- * - @verbatim Draw#composite(x,y,width,height,img,operator) @endverbatim
1072
- *
1073
- * Notes:
1074
- * - Default operator is overComposite
1075
- * - The "img" argument can be either an ImageList object or an Image
955
+ * Draw the image.
956
+ *
957
+ * @overload composite(x, y, width, height, image)
958
+ * @param x [Float] x position
959
+ * @param y [Float] y position
960
+ * @param width [Float] the width
961
+ * @param height [Float] the height
962
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
963
+ * imagelist, uses the current image.
964
+ *
965
+ * @overload composite(x, y, width, height, image, operator = Magick::OverCompositeOp)
966
+ * - The "image" argument can be either an ImageList object or an Image
1076
967
  * argument.
1077
- *
1078
- * @param argc number of input arguments
1079
- * @param argv array of input arguments
1080
- * @param self this object
1081
- * @return self
968
+ * @param x [Float] x position
969
+ * @param y [Float] y position
970
+ * @param width [Float] the width
971
+ * @param height [Float] the height
972
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
973
+ * imagelist, uses the current image.
974
+ * @param operator [Magick::CompositeOperator] the operator
975
+ *
976
+ * @return [Magick::Draw] self
1082
977
  */
1083
978
  VALUE
1084
979
  Draw_composite(int argc, VALUE *argv, VALUE self)
1085
980
  {
1086
981
  Draw *draw;
1087
- const char *op = "Over";
982
+ const char *op;
1088
983
  double x, y, width, height;
1089
- CompositeOperator cop = OverCompositeOp;
1090
- volatile VALUE image;
984
+ CompositeOperator cop;
985
+ VALUE image;
1091
986
  Image *comp_img;
1092
987
  struct TmpFile_Name *tmpfile_name;
1093
988
  char name[MaxTextExtent];
@@ -1101,243 +996,46 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
1101
996
 
1102
997
  // Retrieve the image to composite
1103
998
  image = rm_cur_image(argv[4]);
1104
- (void) rm_check_destroyed(image);
999
+ comp_img = rm_check_destroyed(image);
1105
1000
 
1106
1001
  x = NUM2DBL(argv[0]);
1107
1002
  y = NUM2DBL(argv[1]);
1108
1003
  width = NUM2DBL(argv[2]);
1109
1004
  height = NUM2DBL(argv[3]);
1110
1005
 
1111
- // The default composition operator is "Over".
1006
+ cop = OverCompositeOp;
1112
1007
  if (argc == 6)
1113
1008
  {
1114
1009
  VALUE_TO_ENUM(argv[5], cop, CompositeOperator);
1010
+ }
1115
1011
 
1116
- switch (cop)
1117
- {
1118
- case AddCompositeOp:
1119
- op = "Add";
1120
- break;
1121
- case AtopCompositeOp:
1122
- op = "Atop";
1123
- break;
1124
- case BlendCompositeOp:
1125
- op = "Blend";
1126
- break;
1127
- #if defined(HAVE_ENUM_BLURCOMPOSITEOP)
1128
- case BlurCompositeOp:
1129
- op = "Blur";
1130
- break;
1131
- #endif
1132
- case BumpmapCompositeOp:
1133
- op = "Bumpmap";
1134
- break;
1135
- case ChangeMaskCompositeOp:
1136
- op = "ChangeMask";
1137
- break;
1138
- case ClearCompositeOp:
1139
- op = "Clear";
1140
- break;
1141
- case ColorBurnCompositeOp:
1142
- op = "ColorBurn";
1143
- break;
1144
- case ColorDodgeCompositeOp:
1145
- op = "ColorDodge";
1146
- break;
1147
- case ColorizeCompositeOp:
1148
- op = "Colorize";
1149
- break;
1150
- case CopyCompositeOp:
1151
- op = "Copy";
1152
- break;
1153
- case CopyBlackCompositeOp:
1154
- op = "CopyBlack";
1155
- break;
1156
- case CopyBlueCompositeOp:
1157
- op = "CopyBlue";
1158
- break;
1159
- case CopyCyanCompositeOp:
1160
- op = "CopyCyan";
1161
- break;
1162
- case CopyGreenCompositeOp:
1163
- op = "CopyGreen";
1164
- break;
1165
- case CopyMagentaCompositeOp:
1166
- op = "CopyMagenta";
1167
- break;
1168
- case CopyOpacityCompositeOp:
1169
- op = "CopyOpacity";
1170
- break;
1171
- case CopyRedCompositeOp:
1172
- op = "CopyRed";
1173
- break;
1174
- case CopyYellowCompositeOp:
1175
- op = "CopyYellow";
1176
- break;
1177
- case DarkenCompositeOp:
1178
- op = "Darken";
1179
- break;
1180
- #if defined(HAVE_ENUM_DISTORTCOMPOSITEOP)
1181
- case DistortCompositeOp:
1182
- op = "Distort";
1183
- break;
1184
- #endif
1185
- case DivideCompositeOp:
1186
- op = "Divide";
1187
- break;
1188
- case DstCompositeOp:
1189
- op = "Dst";
1190
- break;
1191
- case DstAtopCompositeOp:
1192
- op = "DstAtop";
1193
- break;
1194
- case DstInCompositeOp:
1195
- op = "DstIn";
1196
- break;
1197
- case DstOutCompositeOp:
1198
- op = "DstOut";
1199
- break;
1200
- case DstOverCompositeOp:
1201
- op = "DstOver";
1202
- break;
1203
- case DifferenceCompositeOp:
1204
- op = "Difference";
1205
- break;
1206
- case DisplaceCompositeOp:
1207
- op = "Displace";
1208
- break;
1209
- case DissolveCompositeOp:
1210
- op = "Dissolve";
1211
- break;
1212
- case ExclusionCompositeOp:
1213
- op = "Exclusion";
1214
- break;
1215
- case HardLightCompositeOp:
1216
- op = "HardLight";
1217
- break;
1218
- case HueCompositeOp:
1219
- op = "Hue";
1220
- break;
1221
- case InCompositeOp:
1222
- op = "In";
1223
- break;
1224
- case LightenCompositeOp:
1225
- op = "Lighten";
1226
- break;
1227
- #if defined(HAVE_ENUM_LINEARBURNCOMPOSITEOP)
1228
- case LinearBurnCompositeOp:
1229
- op = "LinearBurn";
1230
- break;
1231
- #endif
1232
- #if defined(HAVE_ENUM_LINEARDODGECOMPOSITEOP)
1233
- case LinearDodgeCompositeOp:
1234
- op = "LinearDodge";
1235
- break;
1236
- #endif
1237
- case LinearLightCompositeOp:
1238
- op = "LinearLight";
1239
- break;
1240
- case LuminizeCompositeOp:
1241
- op = "Luminize";
1242
- break;
1243
- case MinusCompositeOp:
1244
- op = "Minus";
1245
- break;
1246
- case ModulateCompositeOp:
1247
- op = "Modulate";
1248
- break;
1249
- case MultiplyCompositeOp:
1250
- op = "Multiply";
1251
- break;
1252
- case OutCompositeOp:
1253
- op = "Out";
1254
- break;
1255
- case OverCompositeOp:
1256
- op = "Over";
1257
- break;
1258
- case OverlayCompositeOp:
1259
- op = "Overlay";
1260
- break;
1261
- #if defined(HAVE_ENUM_PEGTOPLIGHTCOMPOSITEOP)
1262
- case PegtopLightCompositeOp:
1263
- op = "PegtopLight";
1264
- break;
1265
- #endif
1266
- #if defined(HAVE_ENUM_PINLIGHTCOMPOSITEOP)
1267
- case PinLightCompositeOp:
1268
- op = "PinLight";
1269
- break;
1270
- #endif
1271
- case PlusCompositeOp:
1272
- op = "Plus";
1273
- break;
1274
- case ReplaceCompositeOp:
1275
- op = "Replace";
1276
- break;
1277
- case SaturateCompositeOp:
1278
- op = "Saturate";
1279
- break;
1280
- case ScreenCompositeOp:
1281
- op = "Screen";
1282
- break;
1283
- case SoftLightCompositeOp:
1284
- op = "SoftLight";
1285
- break;
1286
- case SrcCompositeOp:
1287
- op = "Src";
1288
- break;
1289
- case SrcAtopCompositeOp:
1290
- op = "SrcAtop";
1291
- break;
1292
- case SrcInCompositeOp:
1293
- op = "SrcIn";
1294
- break;
1295
- case SrcOutCompositeOp:
1296
- op = "SrcOut";
1297
- break;
1298
- case SrcOverCompositeOp:
1299
- op = "SrcOver";
1300
- break;
1301
- case SubtractCompositeOp:
1302
- op = "Subtract";
1303
- break;
1304
- case ThresholdCompositeOp:
1305
- op = "Threshold";
1306
- break;
1307
- #if defined(HAVE_ENUM_VIVIDLIGHTCOMPOSITEOP)
1308
- case VividLightCompositeOp:
1309
- op = "VividLight";
1310
- break;
1311
- #endif
1312
- case XorCompositeOp:
1313
- op = "Xor";
1314
- break;
1315
- default:
1316
- rb_raise(rb_eArgError, "unknown composite operator (%d)", cop);
1317
- break;
1318
- }
1012
+ op = CommandOptionToMnemonic(MagickComposeOptions, cop);
1013
+ if (rm_strcasecmp("Unrecognized", op) == 0)
1014
+ {
1015
+ rb_raise(rb_eArgError, "unknown composite operator (%d)", cop);
1319
1016
  }
1320
1017
 
1321
1018
  Data_Get_Struct(self, Draw, draw);
1322
1019
 
1323
1020
  // Create a temp copy of the composite image
1324
- Data_Get_Struct(image, Image, comp_img);
1325
- rm_write_temp_image(comp_img, name);
1021
+ rm_write_temp_image(comp_img, name, sizeof(name));
1326
1022
 
1327
1023
  // Add the temp filename to the filename array.
1328
1024
  // Use Magick storage since we need to keep the list around
1329
1025
  // until destroy_Draw is called.
1330
- tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name)+strlen(name));
1026
+ tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name) + rm_strnlen_s(name, sizeof(name)));
1331
1027
  strcpy(tmpfile_name->name, name);
1332
1028
  tmpfile_name->next = draw->tmpfile_ary;
1333
1029
  draw->tmpfile_ary = tmpfile_name;
1334
1030
 
1335
1031
  // Form the drawing primitive
1336
- (void) sprintf(primitive, "image %s %g,%g,%g,%g '%s'", op, x, y, width, height, name);
1032
+ snprintf(primitive, sizeof(primitive), "image %s %g,%g,%g,%g '%s'", op, x, y, width, height, name);
1337
1033
 
1338
1034
 
1339
1035
  // Send "primitive" to self.
1340
- (void) rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
1036
+ rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
1037
+
1038
+ RB_GC_GUARD(image);
1341
1039
 
1342
1040
  return self;
1343
1041
  }
@@ -1346,18 +1044,18 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
1346
1044
  /**
1347
1045
  * Execute the stored drawing primitives on the current image.
1348
1046
  *
1349
- * Ruby usage:
1350
- * - @verbatim Draw#draw(i) @endverbatim
1351
- *
1352
- * @param self this object
1353
- * @param image_arg the image argument
1354
- * @return self
1047
+ * @param image_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1048
+ * imagelist, uses the current image.
1049
+ * @return [Magick::Draw] self
1355
1050
  */
1356
1051
  VALUE
1357
1052
  Draw_draw(VALUE self, VALUE image_arg)
1358
1053
  {
1359
1054
  Draw *draw;
1360
1055
  Image *image;
1056
+ #if defined(IMAGEMAGICK_7)
1057
+ ExceptionInfo *exception;
1058
+ #endif
1361
1059
 
1362
1060
  image_arg = rm_cur_image(image_arg);
1363
1061
  image = rm_check_frozen(image_arg);
@@ -1369,45 +1067,47 @@ Draw_draw(VALUE self, VALUE image_arg)
1369
1067
  }
1370
1068
 
1371
1069
  // Point the DrawInfo structure at the current set of primitives.
1372
- magick_clone_string(&(draw->info->primitive), StringValuePtr(draw->primitives));
1070
+ magick_clone_string(&(draw->info->primitive), StringValueCStr(draw->primitives));
1373
1071
 
1374
- (void) DrawImage(image, draw->info);
1375
- rm_check_image_exception(image, RetainOnError);
1072
+ #if defined(IMAGEMAGICK_7)
1073
+ exception = AcquireExceptionInfo();
1074
+ DrawImage(image, draw->info, exception);
1075
+ #else
1076
+ DrawImage(image, draw->info);
1077
+ #endif
1376
1078
 
1377
1079
  magick_free(draw->info->primitive);
1378
1080
  draw->info->primitive = NULL;
1379
1081
 
1082
+ #if defined(IMAGEMAGICK_7)
1083
+ CHECK_EXCEPTION();
1084
+ DestroyExceptionInfo(exception);
1085
+ #else
1086
+ rm_check_image_exception(image, RetainOnError);
1087
+ #endif
1088
+
1380
1089
  return self;
1381
1090
  }
1382
1091
 
1383
1092
 
1384
1093
  /**
1385
- * Copy a Draw object.
1094
+ * Duplicate a Draw object.
1386
1095
  *
1387
- * Ruby usage:
1388
- * - @verbatim Draw#dup @endverbatim
1389
- *
1390
- * Notes:
1391
- * - Constructs a new Draw object, then calls initialize_copy.
1096
+ * - Constructs a new Draw object, then calls initialize_copy.
1392
1097
  *
1393
- * @param self this object
1394
- * @return the duplicate
1395
- * @see Draw_clone
1396
- * @see Draw_init_copy
1098
+ * @return [Magick::Draw] the duplicated object
1397
1099
  */
1398
1100
  VALUE
1399
1101
  Draw_dup(VALUE self)
1400
1102
  {
1401
1103
  Draw *draw;
1402
- volatile VALUE dup;
1104
+ VALUE dup;
1403
1105
 
1404
1106
  draw = ALLOC(Draw);
1405
1107
  memset(draw, 0, sizeof(Draw));
1406
1108
  dup = Data_Wrap_Struct(CLASS_OF(self), mark_Draw, destroy_Draw, draw);
1407
- if (rb_obj_tainted(self))
1408
- {
1409
- (void)rb_obj_taint(dup);
1410
- }
1109
+ RB_GC_GUARD(dup);
1110
+
1411
1111
  return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
1412
1112
  }
1413
1113
 
@@ -1415,19 +1115,19 @@ Draw_dup(VALUE self)
1415
1115
  /**
1416
1116
  * Returns measurements for a given font and text string.
1417
1117
  *
1418
- * Ruby usage:
1419
- * - @verbatim Draw#get_type_metrics(text) @endverbatim
1420
- * - @verbatim Draw#get_type_metrics(image, text) @endverbatim
1118
+ * - If the image argument has been omitted, use a dummy image, but make sure
1119
+ * the text has none of the special characters that refer to image
1120
+ * attributes.
1421
1121
  *
1422
- * Notes:
1423
- * - If the image argument has been omitted, use a dummy image, but make sure
1424
- * the text has none of the special characters that refer to image
1425
- * attributes.
1122
+ * @overload get_type_metrics(text)
1123
+ * @param text [String] The string to be rendered.
1426
1124
  *
1427
- * @param argc number of input arguments
1428
- * @param argv array of input arguments
1429
- * @param self this object
1430
- * @return the duplicate
1125
+ * @overload get_type_metrics(image, text)
1126
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1127
+ * imagelist, uses the current image.
1128
+ * @param text [String] The string to be rendered.
1129
+ *
1130
+ * @return [Magick::TypeMetric] The information for a specific string if rendered on a image.
1431
1131
  */
1432
1132
  VALUE
1433
1133
  Draw_get_type_metrics(
@@ -1442,19 +1142,19 @@ Draw_get_type_metrics(
1442
1142
  /**
1443
1143
  * Returns measurements for a given font and text string.
1444
1144
  *
1445
- * Ruby usage:
1446
- * - @verbatim Draw#get_multiline_type_metrics(text) @endverbatim
1447
- * - @verbatim Draw#get_multiline_type_metrics(image, text) @endverbatim
1145
+ * - If the image argument has been omitted, use a dummy image, but make sure
1146
+ * the text has none of the special characters that refer to image
1147
+ * attributes.
1448
1148
  *
1449
- * Notes:
1450
- * - If the image argument has been omitted, use a dummy image, but make sure
1451
- * the text has none of the special characters that refer to image
1452
- * attributes.
1149
+ * @overload get_multiline_type_metrics(text)
1150
+ * @param text [String] The string to be rendered.
1453
1151
  *
1454
- * @param argc number of input arguments
1455
- * @param argv array of input arguments
1456
- * @param self this object
1457
- * @return the duplicate
1152
+ * @overload Draw#get_multiline_type_metrics(image, text)
1153
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1154
+ * imagelist, uses the current image.
1155
+ * @param text [String] The string to be rendered.
1156
+ *
1157
+ * @return [Magick::TypeMetric] The information for a specific string if rendered on a image.
1458
1158
  */
1459
1159
  VALUE
1460
1160
  Draw_get_multiline_type_metrics(
@@ -1469,14 +1169,8 @@ Draw_get_multiline_type_metrics(
1469
1169
  /**
1470
1170
  * Initialize clone, dup methods.
1471
1171
  *
1472
- * Ruby usage:
1473
- * - @verbatim Draw#initialize_copy @endverbatim
1474
- *
1475
- * @param self this object
1476
1172
  * @param orig the original object
1477
- * @return self
1478
- * @see Draw_clone
1479
- * @see Draw_dup
1173
+ * @return [Magick::Draw] self
1480
1174
  */
1481
1175
  VALUE Draw_init_copy(VALUE self, VALUE orig)
1482
1176
  {
@@ -1503,17 +1197,13 @@ VALUE Draw_init_copy(VALUE self, VALUE orig)
1503
1197
  /**
1504
1198
  * Initialize Draw object.
1505
1199
  *
1506
- * Ruby usage:
1507
- * - @verbatim Draw#initialize <{ info initializers }> @endverbatim
1508
- *
1509
- * @param self this object
1510
- * @return self
1200
+ * @return [Magick::Draw] self
1511
1201
  */
1512
1202
  VALUE
1513
1203
  Draw_initialize(VALUE self)
1514
1204
  {
1515
1205
  Draw *draw, *draw_options;
1516
- volatile VALUE options;
1206
+ VALUE options;
1517
1207
 
1518
1208
  Data_Get_Struct(self, Draw, draw);
1519
1209
 
@@ -1522,6 +1212,8 @@ Draw_initialize(VALUE self)
1522
1212
  draw->info = draw_options->info;
1523
1213
  draw_options->info = NULL;
1524
1214
 
1215
+ RB_GC_GUARD(options);
1216
+
1525
1217
  return self;
1526
1218
  }
1527
1219
 
@@ -1529,12 +1221,8 @@ Draw_initialize(VALUE self)
1529
1221
  /**
1530
1222
  * Display the primitives.
1531
1223
  *
1532
- * Ruby usage:
1533
- * - @verbatim Draw#inspect @endverbatim
1534
- *
1535
- * @param self this object
1536
- * @return the draw primitives or the Ruby string "(no primitives defined)" if
1537
- * they are not defined
1224
+ * @return [String] the draw primitives or the Ruby string "(no primitives defined)"
1225
+ * if they are not defined
1538
1226
  */
1539
1227
  VALUE
1540
1228
  Draw_inspect(VALUE self)
@@ -1549,23 +1237,19 @@ Draw_inspect(VALUE self)
1549
1237
  /**
1550
1238
  * Create a new Draw object.
1551
1239
  *
1552
- * Ruby usage:
1553
- * - @verbatim Draw.new @endverbatim
1554
- * - @verbatim Draw.allocate @endverbatim
1555
- *
1556
- * @param class the Ruby Draw class
1557
- * @return a new Draw object
1558
- * @throw ImageMagickError if no memory
1240
+ * @return [Magick::Draw] a new Draw object
1559
1241
  */
1560
1242
  VALUE Draw_alloc(VALUE class)
1561
1243
  {
1562
1244
  Draw *draw;
1563
- volatile VALUE draw_obj;
1245
+ VALUE draw_obj;
1564
1246
 
1565
1247
  draw = ALLOC(Draw);
1566
1248
  memset(draw, 0, sizeof(Draw));
1567
1249
  draw_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw);
1568
1250
 
1251
+ RB_GC_GUARD(draw_obj);
1252
+
1569
1253
  return draw_obj;
1570
1254
  }
1571
1255
 
@@ -1573,12 +1257,8 @@ VALUE Draw_alloc(VALUE class)
1573
1257
  /**
1574
1258
  * Add a drawing primitive to the list of primitives in the Draw object.
1575
1259
  *
1576
- * Ruby usage:
1577
- * - @verbatim Draw#primitive @endverbatim
1578
- *
1579
- * @param self this object
1580
- * @param primitive the primitive to add
1581
- * @return self
1260
+ * @param primitive [String] the primitive to add
1261
+ * @return [Magick::Draw] self
1582
1262
  */
1583
1263
  VALUE
1584
1264
  Draw_primitive(VALUE self, VALUE primitive)
@@ -1632,17 +1312,18 @@ static void
1632
1312
  destroy_Draw(void *drawptr)
1633
1313
  {
1634
1314
  Draw *draw = (Draw *)drawptr;
1635
- struct TmpFile_Name *tmpfile_name;
1636
1315
 
1637
1316
  if (draw->info)
1638
1317
  {
1639
- (void) DestroyDrawInfo(draw->info);
1318
+ DestroyDrawInfo(draw->info);
1640
1319
  draw->info = NULL;
1641
1320
  }
1642
1321
 
1643
1322
  // Erase any temporary image files.
1644
1323
  while (draw->tmpfile_ary)
1645
1324
  {
1325
+ struct TmpFile_Name *tmpfile_name;
1326
+
1646
1327
  tmpfile_name = draw->tmpfile_ary;
1647
1328
  draw->tmpfile_ary = draw->tmpfile_ary->next;
1648
1329
  rm_delete_temp_image(tmpfile_name->name);
@@ -1670,27 +1351,23 @@ new_DrawOptions(void)
1670
1351
  /**
1671
1352
  * Create a DrawOptions object.
1672
1353
  *
1673
- * Ruby usage:
1674
- * - @verbatim DrawOptions#allocate @endverbatim
1675
- * - @verbatim DrawOptions#new @endverbatim
1354
+ * - The DrawOptions class is the same as the Draw class except is has only
1355
+ * the attribute writer functions
1676
1356
  *
1677
- * Notes:
1678
- * - The DrawOptions class is the same as the Draw class except is has only
1679
- * the attribute writer functions
1680
- *
1681
- * @param class the Ruby DrawOptions class
1682
- * @return a new DrawOptions object
1357
+ * @return [Magick::Image::DrawOptions] a new DrawOptions object
1683
1358
  */
1684
1359
  VALUE
1685
1360
  DrawOptions_alloc(VALUE class)
1686
1361
  {
1687
1362
  Draw *draw_options;
1688
- volatile VALUE draw_options_obj;
1363
+ VALUE draw_options_obj;
1689
1364
 
1690
1365
  draw_options = ALLOC(Draw);
1691
1366
  memset(draw_options, 0, sizeof(Draw));
1692
1367
  draw_options_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw_options);
1693
1368
 
1369
+ RB_GC_GUARD(draw_options_obj);
1370
+
1694
1371
  return draw_options_obj;
1695
1372
  }
1696
1373
 
@@ -1698,11 +1375,7 @@ DrawOptions_alloc(VALUE class)
1698
1375
  /**
1699
1376
  * Initialize a DrawOptions object.
1700
1377
  *
1701
- * Ruby usage:
1702
- * - @verbatim DrawOptions#initialize @endverbatim
1703
- *
1704
- * @param self this object
1705
- * @return self
1378
+ * @return [Magick::Image::DrawOptions] self
1706
1379
  */
1707
1380
  VALUE
1708
1381
  DrawOptions_initialize(VALUE self)
@@ -1710,7 +1383,7 @@ DrawOptions_initialize(VALUE self)
1710
1383
  Draw *draw_options;
1711
1384
 
1712
1385
  Data_Get_Struct(self, Draw, draw_options);
1713
- draw_options->info = magick_malloc(sizeof(DrawInfo));
1386
+ draw_options->info = AcquireDrawInfo();
1714
1387
  if (!draw_options->info)
1715
1388
  {
1716
1389
  rb_raise(rb_eNoMemError, "not enough memory to continue");
@@ -1720,8 +1393,15 @@ DrawOptions_initialize(VALUE self)
1720
1393
 
1721
1394
  if (rb_block_given_p())
1722
1395
  {
1723
- // Run the block in self's context
1724
- (void) rb_obj_instance_eval(0, NULL, self);
1396
+ if (rb_proc_arity(rb_block_proc()) == 0)
1397
+ {
1398
+ // Run the block in self's context
1399
+ rb_obj_instance_eval(0, NULL, self);
1400
+ }
1401
+ else
1402
+ {
1403
+ rb_yield(self);
1404
+ }
1725
1405
  }
1726
1406
 
1727
1407
  return self;
@@ -1729,23 +1409,17 @@ DrawOptions_initialize(VALUE self)
1729
1409
 
1730
1410
 
1731
1411
  /**
1732
- * Allocate a new Magick::PolaroidOptions object.
1412
+ * Allocate a new Magick::Image::PolaroidOptions object.
1733
1413
  *
1734
- * Ruby usage:
1735
- * - @verbatim Magick::PolaroidOptions#allocate @endverbatim
1736
- * - @verbatim Magick::PolaroidOptions#new @endverbatim
1737
- *
1738
- * Notes:
1739
- * - Internally a PolaroidOptions object is the same as a Draw object. The
1740
- * methods are implemented by Draw methods in rmdraw.c.
1414
+ * - Internally a PolaroidOptions object is the same as a Draw object. The
1415
+ * methods are implemented by Draw methods in rmdraw.c.
1741
1416
  *
1742
- * @param class the Ruby PoloradoidOptions class
1743
- * @return a new DrawOptions object
1417
+ * @return [Magick::Image::PolaroidOptions] a new PolaroidOptions object
1744
1418
  */
1745
1419
  VALUE
1746
1420
  PolaroidOptions_alloc(VALUE class)
1747
1421
  {
1748
- volatile VALUE polaroid_obj;
1422
+ VALUE polaroid_obj;
1749
1423
  ImageInfo *image_info;
1750
1424
  Draw *draw;
1751
1425
 
@@ -1754,43 +1428,53 @@ PolaroidOptions_alloc(VALUE class)
1754
1428
  draw = ALLOC(Draw);
1755
1429
  memset(draw, 0, sizeof(*draw));
1756
1430
 
1757
- draw->info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
1758
- (void)(void) DestroyImageInfo(image_info);
1431
+ draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
1432
+ (void) DestroyImageInfo(image_info);
1759
1433
 
1760
1434
  polaroid_obj = Data_Wrap_Struct(class, NULL, destroy_Draw, draw);
1761
1435
 
1436
+ RB_GC_GUARD(polaroid_obj);
1437
+
1762
1438
  return polaroid_obj;
1763
1439
  }
1764
1440
 
1765
1441
 
1766
1442
  /**
1767
- * Yield to an optional block.
1768
- *
1769
- * Ruby usage:
1770
- * - @verbatim Magick::PolaroidOptions#initialize @endverbatim
1443
+ * Initialize a PolaroidOptions object.
1771
1444
  *
1772
- * @param self this object
1773
- * @return self
1445
+ * @yield [self]
1446
+ * @yieldparam self [Magick::Image::PolaroidOptions] self
1447
+ * @return [Magick::Image::PolaroidOptions] self
1774
1448
  */
1775
1449
  VALUE
1776
1450
  PolaroidOptions_initialize(VALUE self)
1777
1451
  {
1778
1452
  Draw *draw;
1779
- ExceptionInfo exception;
1453
+ ExceptionInfo *exception;
1780
1454
 
1781
1455
  // Default shadow color
1782
1456
  Data_Get_Struct(self, Draw, draw);
1783
1457
 
1784
- GetExceptionInfo(&exception);
1785
- (void) QueryColorDatabase("gray75", &draw->shadow_color, &exception);
1786
- CHECK_EXCEPTION()
1787
- (void) QueryColorDatabase("#dfdfdf", &draw->info->border_color, &exception);
1458
+ exception = AcquireExceptionInfo();
1459
+ QueryColorCompliance("gray75", AllCompliance, &draw->shadow_color, exception);
1460
+ CHECK_EXCEPTION();
1461
+ QueryColorCompliance("#dfdfdf", AllCompliance, &draw->info->border_color, exception);
1462
+ CHECK_EXCEPTION();
1463
+ DestroyExceptionInfo(exception);
1788
1464
 
1789
1465
  if (rb_block_given_p())
1790
1466
  {
1791
- // Run the block in self's context
1792
- (void) rb_obj_instance_eval(0, NULL, self);
1467
+ if (rb_proc_arity(rb_block_proc()) == 0)
1468
+ {
1469
+ // Run the block in self's context
1470
+ rb_obj_instance_eval(0, NULL, self);
1471
+ }
1472
+ else
1473
+ {
1474
+ rb_yield(self);
1475
+ }
1793
1476
  }
1477
+
1794
1478
  return self;
1795
1479
  }
1796
1480
 
@@ -1812,42 +1496,36 @@ rm_polaroid_new(void)
1812
1496
  /**
1813
1497
  * Set the shadow color attribute.
1814
1498
  *
1815
- * Ruby usage:
1816
- * - @verbatim PolaroidOptions#shadow_color= @endverbatim
1817
- *
1818
- * @param self this object
1819
- * @param shadow the shadow color
1820
- * @return self
1499
+ * @param shadow [Magick::Pixel, String] the shadow color
1500
+ * @return [Magick::Pixel, String] the given shadow color
1821
1501
  */
1822
1502
  VALUE
1823
1503
  PolaroidOptions_shadow_color_eq(VALUE self, VALUE shadow)
1824
1504
  {
1825
1505
  Draw *draw;
1826
1506
 
1507
+ rb_check_frozen(self);
1827
1508
  Data_Get_Struct(self, Draw, draw);
1828
- Color_to_PixelPacket(&draw->shadow_color, shadow);
1829
- return self;
1509
+ Color_to_PixelColor(&draw->shadow_color, shadow);
1510
+ return shadow;
1830
1511
  }
1831
1512
 
1832
1513
 
1833
1514
  /**
1834
- * Set the border color attribute.
1515
+ * Set the border color.
1835
1516
  *
1836
- * Ruby usage:
1837
- * - @verbatim PolaroidOptions#border_color= @endverbatim
1838
- *
1839
- * @param self this object
1840
- * @param border the border color
1841
- * @return self
1517
+ * @param border [Magick::Pixel, String] the border color
1518
+ * @return [Magick::Pixel, String] the given border color
1842
1519
  */
1843
1520
  VALUE
1844
1521
  PolaroidOptions_border_color_eq(VALUE self, VALUE border)
1845
1522
  {
1846
1523
  Draw *draw;
1847
1524
 
1525
+ rb_check_frozen(self);
1848
1526
  Data_Get_Struct(self, Draw, draw);
1849
- Color_to_PixelPacket(&draw->info->border_color, border);
1850
- return self;
1527
+ Color_to_PixelColor(&draw->info->border_color, border);
1528
+ return border;
1851
1529
  }
1852
1530
 
1853
1531
 
@@ -1863,30 +1541,33 @@ static VALUE
1863
1541
  get_dummy_tm_img(VALUE klass)
1864
1542
  {
1865
1543
  #define DUMMY_IMG_CLASS_VAR "@@_dummy_img_"
1866
- volatile VALUE dummy_img = 0;
1867
- Info *info;
1868
- Image *image;
1544
+ VALUE dummy_img = 0;
1869
1545
 
1870
1546
  if (rb_cvar_defined(klass, rb_intern(DUMMY_IMG_CLASS_VAR)) != Qtrue)
1871
1547
  {
1548
+ Info *info;
1549
+ Image *image;
1872
1550
 
1873
1551
  info = CloneImageInfo(NULL);
1874
1552
  if (!info)
1875
1553
  {
1876
1554
  rb_raise(rb_eNoMemError, "not enough memory to continue");
1877
1555
  }
1878
- image = AcquireImage(info);
1556
+ image = rm_acquire_image(info);
1557
+ DestroyImageInfo(info);
1558
+
1879
1559
  if (!image)
1880
1560
  {
1881
1561
  rb_raise(rb_eNoMemError, "not enough memory to continue");
1882
1562
  }
1883
- (void) DestroyImageInfo(info);
1884
1563
  dummy_img = rm_image_new(image);
1885
1564
 
1886
1565
  rb_cv_set(klass, DUMMY_IMG_CLASS_VAR, dummy_img);
1887
1566
  }
1888
1567
  dummy_img = rb_cv_get(klass, DUMMY_IMG_CLASS_VAR);
1889
1568
 
1569
+ RB_GC_GUARD(dummy_img);
1570
+
1890
1571
  return dummy_img;
1891
1572
  }
1892
1573
 
@@ -1914,42 +1595,21 @@ get_type_metrics(
1914
1595
  VALUE self,
1915
1596
  get_type_metrics_func_t getter)
1916
1597
  {
1917
- static char attrs[] = "OPbcdefghiklmnopqrstuwxyz[@#%";
1918
- #define ATTRS_L ((int)(sizeof(attrs)-1))
1919
1598
  Image *image;
1920
1599
  Draw *draw;
1921
- volatile VALUE t;
1600
+ VALUE t;
1922
1601
  TypeMetric metrics;
1923
1602
  char *text = NULL;
1924
1603
  long text_l;
1925
- long x;
1926
1604
  unsigned int okay;
1605
+ #if defined(IMAGEMAGICK_7)
1606
+ ExceptionInfo *exception;
1607
+ #endif
1927
1608
 
1928
1609
  switch (argc)
1929
1610
  {
1930
1611
  case 1: // use default image
1931
1612
  text = rm_str2cstr(argv[0], &text_l);
1932
-
1933
- for (x = 0; x < text_l; x++)
1934
- {
1935
- // Ensure text string doesn't refer to image attributes.
1936
- if (text[x] == '%' && x < text_l-1)
1937
- {
1938
- int y;
1939
- char spec = text[x+1];
1940
-
1941
- for (y = 0; y < ATTRS_L; y++)
1942
- {
1943
- if (spec == attrs[y])
1944
- {
1945
- rb_raise(rb_eArgError,
1946
- "text string contains image attribute reference `%%%c'",
1947
- spec);
1948
- }
1949
- }
1950
- }
1951
- }
1952
-
1953
1613
  Data_Get_Struct(get_dummy_tm_img(CLASS_OF(self)), Image, image);
1954
1614
  break;
1955
1615
  case 2:
@@ -1968,24 +1628,55 @@ get_type_metrics(
1968
1628
  }
1969
1629
 
1970
1630
  Data_Get_Struct(self, Draw, draw);
1631
+ #if defined(IMAGEMAGICK_7)
1632
+ exception = AcquireExceptionInfo();
1633
+ draw->info->text = InterpretImageProperties(NULL, image, text, exception);
1634
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
1635
+ {
1636
+ if (draw->info->text)
1637
+ {
1638
+ magick_free(draw->info->text);
1639
+ }
1640
+ rm_raise_exception(exception);
1641
+ }
1642
+ #else
1971
1643
  draw->info->text = InterpretImageProperties(NULL, image, text);
1644
+ #endif
1972
1645
  if (!draw->info->text)
1973
1646
  {
1647
+ #if defined(IMAGEMAGICK_7)
1648
+ DestroyExceptionInfo(exception);
1649
+ #endif
1974
1650
  rb_raise(rb_eArgError, "no text to measure");
1975
1651
  }
1976
1652
 
1653
+ #if defined(IMAGEMAGICK_7)
1654
+ okay = (*getter)(image, draw->info, &metrics, exception);
1655
+ #else
1977
1656
  okay = (*getter)(image, draw->info, &metrics);
1657
+ #endif
1978
1658
 
1979
1659
  magick_free(draw->info->text);
1980
1660
  draw->info->text = NULL;
1981
1661
 
1982
1662
  if (!okay)
1983
1663
  {
1664
+ #if defined(IMAGEMAGICK_7)
1665
+ CHECK_EXCEPTION();
1666
+ DestroyExceptionInfo(exception);
1667
+ #else
1984
1668
  rm_check_image_exception(image, RetainOnError);
1669
+ #endif
1985
1670
 
1986
1671
  // Shouldn't get here...
1987
1672
  rb_raise(rb_eRuntimeError, "Can't measure text. Are the fonts installed? "
1988
1673
  "Is the FreeType library installed?");
1989
1674
  }
1675
+ #if defined(IMAGEMAGICK_7)
1676
+ DestroyExceptionInfo(exception);
1677
+ #endif
1678
+
1679
+ RB_GC_GUARD(t);
1680
+
1990
1681
  return Import_TypeMetric(&metrics);
1991
1682
  }