rmagick 2.16.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (441) hide show
  1. checksums.yaml +5 -5
  2. data/.devcontainer/Dockerfile +14 -0
  3. data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
  4. data/.devcontainer/devcontainer.json +11 -0
  5. data/.devcontainer/setup-repo.sh +10 -0
  6. data/.devcontainer/setup-user.sh +45 -0
  7. data/.editorconfig +3 -0
  8. data/.github/ISSUE_TEMPLATE.md +17 -0
  9. data/.github/workflows/ci.yml +157 -0
  10. data/.gitignore +9 -1
  11. data/.rspec +1 -0
  12. data/.rubocop.yml +37 -340
  13. data/.rubocop_todo.yml +456 -0
  14. data/.yardopts +5 -0
  15. data/CHANGELOG.md +536 -0
  16. data/CODE_OF_CONDUCT.md +122 -7
  17. data/CONTRIBUTING.md +37 -6
  18. data/Gemfile +18 -4
  19. data/README.md +319 -0
  20. data/Rakefile +83 -98
  21. data/before_install_linux.sh +65 -28
  22. data/before_install_osx.sh +58 -2
  23. data/ext/RMagick/extconf.rb +310 -393
  24. data/ext/RMagick/{rmagick.c → rmagick.cpp} +119 -127
  25. data/ext/RMagick/rmagick.h +290 -363
  26. data/ext/RMagick/rmagick_gvl.h +224 -0
  27. data/ext/RMagick/rmdraw.cpp +1696 -0
  28. data/ext/RMagick/rmenum.cpp +796 -0
  29. data/ext/RMagick/{rmfill.c → rmfill.cpp} +287 -197
  30. data/ext/RMagick/rmilist.cpp +1275 -0
  31. data/ext/RMagick/rmimage.cpp +16459 -0
  32. data/ext/RMagick/{rminfo.c → rminfo.cpp} +738 -910
  33. data/ext/RMagick/rmkinfo.cpp +210 -0
  34. data/ext/RMagick/rmmain.cpp +1923 -0
  35. data/ext/RMagick/rmmontage.cpp +474 -0
  36. data/ext/RMagick/rmpixel.cpp +1322 -0
  37. data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +104 -284
  38. data/ext/RMagick/{rmutil.c → rmutil.cpp} +500 -433
  39. data/lib/rmagick/version.rb +5 -4
  40. data/lib/rmagick.rb +2 -0
  41. data/lib/rmagick_internal.rb +397 -459
  42. data/lib/rvg/clippath.rb +3 -4
  43. data/lib/rvg/container.rb +30 -22
  44. data/lib/rvg/deep_equal.rb +11 -11
  45. data/lib/rvg/describable.rb +2 -2
  46. data/lib/rvg/embellishable.rb +67 -68
  47. data/lib/rvg/misc.rb +139 -142
  48. data/lib/rvg/paint.rb +2 -1
  49. data/lib/rvg/pathdata.rb +7 -8
  50. data/lib/rvg/rvg.rb +49 -46
  51. data/lib/rvg/stretchable.rb +22 -28
  52. data/lib/rvg/stylable.rb +12 -10
  53. data/lib/rvg/text.rb +169 -165
  54. data/lib/rvg/transformable.rb +17 -16
  55. data/lib/rvg/units.rb +5 -5
  56. data/rmagick.gemspec +7 -41
  57. data/sig/rmagick/_draw_common_methods.rbs +64 -0
  58. data/sig/rmagick/_image_common_methods.rbs +389 -0
  59. data/sig/rmagick/draw.rbs +38 -0
  60. data/sig/rmagick/draw_attribute.rbs +28 -0
  61. data/sig/rmagick/enum.rbs +814 -0
  62. data/sig/rmagick/error.rbs +11 -0
  63. data/sig/rmagick/fill.rbs +21 -0
  64. data/sig/rmagick/geometry.rbs +14 -0
  65. data/sig/rmagick/image.rbs +194 -0
  66. data/sig/rmagick/image_list.rbs +181 -0
  67. data/sig/rmagick/iptc.rbs +101 -0
  68. data/sig/rmagick/kernel_info.rbs +12 -0
  69. data/sig/rmagick/optional_method_arguments.rbs +10 -0
  70. data/sig/rmagick/pixel.rbs +46 -0
  71. data/sig/rmagick/struct.rbs +90 -0
  72. data/sig/rmagick.rbs +43 -0
  73. data/sig/rvg/clippath.rbs +34 -0
  74. data/sig/rvg/container.rbs +78 -0
  75. data/sig/rvg/deep_equal.rbs +48 -0
  76. data/sig/rvg/describable.rbs +30 -0
  77. data/sig/rvg/embellishable.rbs +226 -0
  78. data/sig/rvg/misc.rbs +145 -0
  79. data/sig/rvg/paint.rbs +55 -0
  80. data/sig/rvg/pathdata.rbs +77 -0
  81. data/sig/rvg/rvg.rbs +125 -0
  82. data/sig/rvg/stretchable.rbs +56 -0
  83. data/sig/rvg/stylable.rbs +66 -0
  84. data/sig/rvg/text.rbs +118 -0
  85. data/sig/rvg/transformable.rbs +59 -0
  86. data/sig/rvg/units.rbs +33 -0
  87. metadata +68 -428
  88. data/.hound.yml +0 -2
  89. data/.simplecov +0 -27
  90. data/.travis.yml +0 -74
  91. data/Doxyfile +0 -1514
  92. data/README.textile +0 -251
  93. data/deprecated/RMagick.rb +0 -6
  94. data/doc/.cvsignore +0 -1
  95. data/doc/comtasks.html +0 -287
  96. data/doc/constants.html +0 -1581
  97. data/doc/css/doc.css +0 -299
  98. data/doc/css/popup.css +0 -34
  99. data/doc/css/ref.css +0 -67
  100. data/doc/draw.html +0 -3272
  101. data/doc/ex/InitialCoords.rb +0 -22
  102. data/doc/ex/NewCoordSys.rb +0 -30
  103. data/doc/ex/OrigCoordSys.rb +0 -16
  104. data/doc/ex/PreserveAspectRatio.rb +0 -204
  105. data/doc/ex/RotateScale.rb +0 -36
  106. data/doc/ex/Skew.rb +0 -38
  107. data/doc/ex/Use01.rb +0 -15
  108. data/doc/ex/Use02.rb +0 -20
  109. data/doc/ex/Use03.rb +0 -16
  110. data/doc/ex/ViewBox.rb +0 -31
  111. data/doc/ex/adaptive_threshold.rb +0 -9
  112. data/doc/ex/add_noise.rb +0 -16
  113. data/doc/ex/affine.rb +0 -48
  114. data/doc/ex/affine_transform.rb +0 -20
  115. data/doc/ex/arc.rb +0 -49
  116. data/doc/ex/arcpath.rb +0 -32
  117. data/doc/ex/arcs01.rb +0 -28
  118. data/doc/ex/arcs02.rb +0 -59
  119. data/doc/ex/average.rb +0 -15
  120. data/doc/ex/axes.rb +0 -64
  121. data/doc/ex/baseline_shift01.rb +0 -17
  122. data/doc/ex/bilevel_channel.rb +0 -8
  123. data/doc/ex/blur_image.rb +0 -12
  124. data/doc/ex/border.rb +0 -10
  125. data/doc/ex/bounding_box.rb +0 -42
  126. data/doc/ex/cbezier1.rb +0 -41
  127. data/doc/ex/cbezier2.rb +0 -41
  128. data/doc/ex/cbezier3.rb +0 -41
  129. data/doc/ex/cbezier4.rb +0 -42
  130. data/doc/ex/cbezier5.rb +0 -42
  131. data/doc/ex/cbezier6.rb +0 -53
  132. data/doc/ex/channel.rb +0 -25
  133. data/doc/ex/charcoal.rb +0 -12
  134. data/doc/ex/chop.rb +0 -29
  135. data/doc/ex/circle.rb +0 -33
  136. data/doc/ex/circle01.rb +0 -16
  137. data/doc/ex/clip_path.rb +0 -60
  138. data/doc/ex/coalesce.rb +0 -57
  139. data/doc/ex/color_fill_to_border.rb +0 -29
  140. data/doc/ex/color_floodfill.rb +0 -28
  141. data/doc/ex/color_histogram.rb +0 -47
  142. data/doc/ex/color_reset.rb +0 -11
  143. data/doc/ex/colorize.rb +0 -16
  144. data/doc/ex/colors.rb +0 -64
  145. data/doc/ex/compose_mask.rb +0 -22
  146. data/doc/ex/composite.rb +0 -133
  147. data/doc/ex/composite_layers.rb +0 -53
  148. data/doc/ex/composite_tiled.rb +0 -21
  149. data/doc/ex/contrast.rb +0 -36
  150. data/doc/ex/crop.rb +0 -31
  151. data/doc/ex/crop_with_gravity.rb +0 -42
  152. data/doc/ex/cubic01.rb +0 -43
  153. data/doc/ex/cubic02.rb +0 -91
  154. data/doc/ex/cycle_colormap.rb +0 -21
  155. data/doc/ex/dissolve.rb +0 -12
  156. data/doc/ex/drawcomp.rb +0 -42
  157. data/doc/ex/drop_shadow.rb +0 -60
  158. data/doc/ex/edge.rb +0 -11
  159. data/doc/ex/ellipse.rb +0 -45
  160. data/doc/ex/ellipse01.rb +0 -21
  161. data/doc/ex/emboss.rb +0 -11
  162. data/doc/ex/enhance.rb +0 -28
  163. data/doc/ex/equalize.rb +0 -11
  164. data/doc/ex/evenodd.rb +0 -42
  165. data/doc/ex/fill_pattern.rb +0 -23
  166. data/doc/ex/flatten_images.rb +0 -36
  167. data/doc/ex/flip.rb +0 -11
  168. data/doc/ex/flop.rb +0 -11
  169. data/doc/ex/font_styles.rb +0 -32
  170. data/doc/ex/fonts.rb +0 -20
  171. data/doc/ex/frame.rb +0 -12
  172. data/doc/ex/gaussian_blur.rb +0 -11
  173. data/doc/ex/get_multiline_type_metrics.rb +0 -41
  174. data/doc/ex/get_pixels.rb +0 -47
  175. data/doc/ex/get_type_metrics.rb +0 -141
  176. data/doc/ex/gradientfill.rb +0 -27
  177. data/doc/ex/grav.rb +0 -45
  178. data/doc/ex/gravity.rb +0 -80
  179. data/doc/ex/group.rb +0 -26
  180. data/doc/ex/hatchfill.rb +0 -27
  181. data/doc/ex/image.rb +0 -44
  182. data/doc/ex/images/Apple.miff +0 -0
  183. data/doc/ex/images/Ballerina.jpg +0 -0
  184. data/doc/ex/images/Ballerina3.jpg +0 -0
  185. data/doc/ex/images/Button_0.gif +0 -0
  186. data/doc/ex/images/Button_1.gif +0 -0
  187. data/doc/ex/images/Button_2.gif +0 -0
  188. data/doc/ex/images/Button_3.gif +0 -0
  189. data/doc/ex/images/Button_4.gif +0 -0
  190. data/doc/ex/images/Button_5.gif +0 -0
  191. data/doc/ex/images/Button_6.gif +0 -0
  192. data/doc/ex/images/Button_7.gif +0 -0
  193. data/doc/ex/images/Button_8.gif +0 -0
  194. data/doc/ex/images/Button_9.gif +0 -0
  195. data/doc/ex/images/Button_A.gif +0 -0
  196. data/doc/ex/images/Button_B.gif +0 -0
  197. data/doc/ex/images/Button_C.gif +0 -0
  198. data/doc/ex/images/Button_D.gif +0 -0
  199. data/doc/ex/images/Button_E.gif +0 -0
  200. data/doc/ex/images/Button_F.gif +0 -0
  201. data/doc/ex/images/Button_G.gif +0 -0
  202. data/doc/ex/images/Button_H.gif +0 -0
  203. data/doc/ex/images/Button_I.gif +0 -0
  204. data/doc/ex/images/Button_J.gif +0 -0
  205. data/doc/ex/images/Button_K.gif +0 -0
  206. data/doc/ex/images/Button_L.gif +0 -0
  207. data/doc/ex/images/Button_M.gif +0 -0
  208. data/doc/ex/images/Button_N.gif +0 -0
  209. data/doc/ex/images/Button_O.gif +0 -0
  210. data/doc/ex/images/Button_P.gif +0 -0
  211. data/doc/ex/images/Button_Q.gif +0 -0
  212. data/doc/ex/images/Button_R.gif +0 -0
  213. data/doc/ex/images/Button_S.gif +0 -0
  214. data/doc/ex/images/Button_T.gif +0 -0
  215. data/doc/ex/images/Button_U.gif +0 -0
  216. data/doc/ex/images/Button_V.gif +0 -0
  217. data/doc/ex/images/Button_W.gif +0 -0
  218. data/doc/ex/images/Button_X.gif +0 -0
  219. data/doc/ex/images/Button_Y.gif +0 -0
  220. data/doc/ex/images/Button_Z.gif +0 -0
  221. data/doc/ex/images/Cheetah.jpg +0 -0
  222. data/doc/ex/images/Coffee.wmf +0 -0
  223. data/doc/ex/images/Flower_Hat.jpg +0 -0
  224. data/doc/ex/images/Gold_Statue.jpg +0 -0
  225. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  226. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  227. data/doc/ex/images/Leaf.miff +0 -0
  228. data/doc/ex/images/No.wmf +0 -0
  229. data/doc/ex/images/Polynesia.jpg +0 -0
  230. data/doc/ex/images/Red_Rocks.jpg +0 -0
  231. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  232. data/doc/ex/images/Shorts.jpg +0 -0
  233. data/doc/ex/images/Snake.wmf +0 -0
  234. data/doc/ex/images/Violin.jpg +0 -0
  235. data/doc/ex/images/Yellow_Rose.miff +0 -0
  236. data/doc/ex/images/big-duck.gif +0 -0
  237. data/doc/ex/images/duck.gif +0 -0
  238. data/doc/ex/images/duck0.gif +0 -0
  239. data/doc/ex/images/duck1.gif +0 -0
  240. data/doc/ex/images/duck10.gif +0 -0
  241. data/doc/ex/images/duck11.gif +0 -0
  242. data/doc/ex/images/duck12.gif +0 -0
  243. data/doc/ex/images/duck13.gif +0 -0
  244. data/doc/ex/images/duck14.gif +0 -0
  245. data/doc/ex/images/duck15.gif +0 -0
  246. data/doc/ex/images/duck2.gif +0 -0
  247. data/doc/ex/images/duck3.gif +0 -0
  248. data/doc/ex/images/duck4.gif +0 -0
  249. data/doc/ex/images/duck5.gif +0 -0
  250. data/doc/ex/images/duck6.gif +0 -0
  251. data/doc/ex/images/duck7.gif +0 -0
  252. data/doc/ex/images/duck8.gif +0 -0
  253. data/doc/ex/images/duck9.gif +0 -0
  254. data/doc/ex/images/graydient230x6.gif +0 -0
  255. data/doc/ex/images/image_with_profile.jpg +0 -0
  256. data/doc/ex/images/logo400x83.gif +0 -0
  257. data/doc/ex/images/model.miff +0 -0
  258. data/doc/ex/images/notimplemented.gif +0 -0
  259. data/doc/ex/images/smile.miff +0 -0
  260. data/doc/ex/images/spin.gif +0 -0
  261. data/doc/ex/implode.rb +0 -34
  262. data/doc/ex/level.rb +0 -11
  263. data/doc/ex/level_colors.rb +0 -11
  264. data/doc/ex/line.rb +0 -41
  265. data/doc/ex/line01.rb +0 -21
  266. data/doc/ex/mask.rb +0 -35
  267. data/doc/ex/matte_fill_to_border.rb +0 -39
  268. data/doc/ex/matte_floodfill.rb +0 -32
  269. data/doc/ex/matte_replace.rb +0 -39
  270. data/doc/ex/median_filter.rb +0 -28
  271. data/doc/ex/modulate.rb +0 -11
  272. data/doc/ex/mono.rb +0 -23
  273. data/doc/ex/morph.rb +0 -25
  274. data/doc/ex/mosaic.rb +0 -35
  275. data/doc/ex/motion_blur.rb +0 -11
  276. data/doc/ex/negate.rb +0 -11
  277. data/doc/ex/negate_channel.rb +0 -9
  278. data/doc/ex/nested_rvg.rb +0 -21
  279. data/doc/ex/nonzero.rb +0 -42
  280. data/doc/ex/normalize.rb +0 -11
  281. data/doc/ex/oil_paint.rb +0 -11
  282. data/doc/ex/opacity.rb +0 -37
  283. data/doc/ex/ordered_dither.rb +0 -11
  284. data/doc/ex/path.rb +0 -63
  285. data/doc/ex/pattern1.rb +0 -25
  286. data/doc/ex/pattern2.rb +0 -26
  287. data/doc/ex/polaroid.rb +0 -27
  288. data/doc/ex/polygon.rb +0 -23
  289. data/doc/ex/polygon01.rb +0 -21
  290. data/doc/ex/polyline.rb +0 -22
  291. data/doc/ex/polyline01.rb +0 -21
  292. data/doc/ex/posterize.rb +0 -8
  293. data/doc/ex/preview.rb +0 -8
  294. data/doc/ex/qbezierpath.rb +0 -52
  295. data/doc/ex/quad01.rb +0 -34
  296. data/doc/ex/quantize-m.rb +0 -25
  297. data/doc/ex/radial_blur.rb +0 -9
  298. data/doc/ex/raise.rb +0 -8
  299. data/doc/ex/random_threshold_channel.rb +0 -13
  300. data/doc/ex/rect01.rb +0 -14
  301. data/doc/ex/rect02.rb +0 -20
  302. data/doc/ex/rectangle.rb +0 -34
  303. data/doc/ex/reduce_noise.rb +0 -28
  304. data/doc/ex/remap.rb +0 -11
  305. data/doc/ex/remap_images.rb +0 -19
  306. data/doc/ex/resize_to_fill.rb +0 -8
  307. data/doc/ex/resize_to_fit.rb +0 -8
  308. data/doc/ex/roll.rb +0 -9
  309. data/doc/ex/rotate.rb +0 -44
  310. data/doc/ex/rotate_f.rb +0 -14
  311. data/doc/ex/roundrect.rb +0 -33
  312. data/doc/ex/rubyname.rb +0 -30
  313. data/doc/ex/rvg_clippath.rb +0 -12
  314. data/doc/ex/rvg_linecap.rb +0 -42
  315. data/doc/ex/rvg_linejoin.rb +0 -40
  316. data/doc/ex/rvg_opacity.rb +0 -18
  317. data/doc/ex/rvg_pattern.rb +0 -26
  318. data/doc/ex/rvg_stroke_dasharray.rb +0 -11
  319. data/doc/ex/segment.rb +0 -11
  320. data/doc/ex/sepiatone.rb +0 -7
  321. data/doc/ex/shade.rb +0 -11
  322. data/doc/ex/shadow.rb +0 -30
  323. data/doc/ex/shave.rb +0 -15
  324. data/doc/ex/shear.rb +0 -10
  325. data/doc/ex/sketch.rb +0 -17
  326. data/doc/ex/skewx.rb +0 -51
  327. data/doc/ex/skewy.rb +0 -47
  328. data/doc/ex/smile.rb +0 -125
  329. data/doc/ex/solarize.rb +0 -11
  330. data/doc/ex/sparse_color.rb +0 -54
  331. data/doc/ex/splice.rb +0 -8
  332. data/doc/ex/spread.rb +0 -11
  333. data/doc/ex/stegano.rb +0 -55
  334. data/doc/ex/stroke_dasharray.rb +0 -42
  335. data/doc/ex/stroke_fill.rb +0 -10
  336. data/doc/ex/stroke_linecap.rb +0 -44
  337. data/doc/ex/stroke_linejoin.rb +0 -48
  338. data/doc/ex/stroke_width.rb +0 -49
  339. data/doc/ex/swirl.rb +0 -17
  340. data/doc/ex/text.rb +0 -37
  341. data/doc/ex/text01.rb +0 -16
  342. data/doc/ex/text_align.rb +0 -36
  343. data/doc/ex/text_antialias.rb +0 -37
  344. data/doc/ex/text_styles.rb +0 -19
  345. data/doc/ex/text_undercolor.rb +0 -28
  346. data/doc/ex/texture_fill_to_border.rb +0 -34
  347. data/doc/ex/texture_floodfill.rb +0 -32
  348. data/doc/ex/texturefill.rb +0 -24
  349. data/doc/ex/threshold.rb +0 -13
  350. data/doc/ex/to_blob.rb +0 -13
  351. data/doc/ex/translate.rb +0 -39
  352. data/doc/ex/transparent.rb +0 -38
  353. data/doc/ex/transpose.rb +0 -9
  354. data/doc/ex/transverse.rb +0 -9
  355. data/doc/ex/tref01.rb +0 -24
  356. data/doc/ex/triangle01.rb +0 -15
  357. data/doc/ex/trim.rb +0 -23
  358. data/doc/ex/tspan01.rb +0 -17
  359. data/doc/ex/tspan02.rb +0 -17
  360. data/doc/ex/tspan03.rb +0 -19
  361. data/doc/ex/unsharp_mask.rb +0 -28
  362. data/doc/ex/viewex.rb +0 -33
  363. data/doc/ex/vignette.rb +0 -12
  364. data/doc/ex/watermark.rb +0 -27
  365. data/doc/ex/wave.rb +0 -9
  366. data/doc/ex/wet_floor.rb +0 -58
  367. data/doc/ex/writing_mode01.rb +0 -26
  368. data/doc/ex/writing_mode02.rb +0 -26
  369. data/doc/ilist.html +0 -2056
  370. data/doc/image1.html +0 -4680
  371. data/doc/image2.html +0 -3665
  372. data/doc/image3.html +0 -4522
  373. data/doc/imageattrs.html +0 -1638
  374. data/doc/imusage.html +0 -514
  375. data/doc/index.html +0 -416
  376. data/doc/info.html +0 -1499
  377. data/doc/magick.html +0 -565
  378. data/doc/optequiv.html +0 -2435
  379. data/doc/rvg.html +0 -975
  380. data/doc/rvgclip.html +0 -248
  381. data/doc/rvggroup.html +0 -305
  382. data/doc/rvgimage.html +0 -289
  383. data/doc/rvgpattern.html +0 -475
  384. data/doc/rvgshape.html +0 -406
  385. data/doc/rvgstyle.html +0 -270
  386. data/doc/rvgtext.html +0 -465
  387. data/doc/rvgtspan.html +0 -238
  388. data/doc/rvgtut.html +0 -530
  389. data/doc/rvguse.html +0 -145
  390. data/doc/rvgxform.html +0 -294
  391. data/doc/scripts/doc.js +0 -22
  392. data/doc/scripts/stripeTables.js +0 -23
  393. data/doc/struct.html +0 -1339
  394. data/doc/usage.html +0 -1621
  395. data/examples/constitute.rb +0 -7
  396. data/examples/crop_with_gravity.rb +0 -42
  397. data/examples/demo.rb +0 -324
  398. data/examples/describe.rb +0 -43
  399. data/examples/find_similar_region.rb +0 -34
  400. data/examples/histogram.rb +0 -321
  401. data/examples/identify.rb +0 -185
  402. data/examples/image_opacity.rb +0 -29
  403. data/examples/import_export.rb +0 -31
  404. data/examples/pattern_fill.rb +0 -38
  405. data/examples/rotating_text.rb +0 -44
  406. data/examples/spinner.rb +0 -49
  407. data/examples/thumbnail.rb +0 -64
  408. data/examples/vignette.rb +0 -78
  409. data/ext/RMagick/rmdraw.c +0 -2022
  410. data/ext/RMagick/rmenum.c +0 -1235
  411. data/ext/RMagick/rmilist.c +0 -1270
  412. data/ext/RMagick/rmimage.c +0 -15427
  413. data/ext/RMagick/rmmain.c +0 -1741
  414. data/ext/RMagick/rmmontage.c +0 -519
  415. data/ext/RMagick/rmpixel.c +0 -1114
  416. data/spec/rmagick/ImageList1_spec.rb +0 -24
  417. data/spec/rmagick/draw_spec.rb +0 -156
  418. data/spec/rmagick/image/blue_shift_spec.rb +0 -16
  419. data/spec/rmagick/image/composite_spec.rb +0 -140
  420. data/spec/rmagick/image/constitute_spec.rb +0 -15
  421. data/spec/rmagick/image/dispatch_spec.rb +0 -18
  422. data/spec/rmagick/image/from_blob_spec.rb +0 -14
  423. data/spec/rmagick/image/ping_spec.rb +0 -14
  424. data/spec/rmagick/image/properties_spec.rb +0 -29
  425. data/spec/spec_helper.rb +0 -4
  426. data/test/Image1.rb +0 -565
  427. data/test/Image2.rb +0 -1304
  428. data/test/Image3.rb +0 -1030
  429. data/test/ImageList1.rb +0 -806
  430. data/test/ImageList2.rb +0 -385
  431. data/test/Image_attributes.rb +0 -697
  432. data/test/Import_Export.rb +0 -121
  433. data/test/Info.rb +0 -345
  434. data/test/Magick.rb +0 -321
  435. data/test/Pixel.rb +0 -116
  436. data/test/Preview.rb +0 -57
  437. data/test/cmyk.icm +0 -0
  438. data/test/srgb.icm +0 -0
  439. data/test/test_all_basic.rb +0 -38
  440. data/test/tmpnam_test.rb +0 -50
  441. data/wercker.yml +0 -10
@@ -5,22 +5,28 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rminfo.c
9
- * @version $Id: rminfo.c,v 1.79 2009/12/20 02:33:33 baror Exp $
8
+ * @file rminfo.cpp
9
+ * @version $Id: rminfo.cpp,v 1.79 2009/12/20 02:33:33 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
12
12
 
13
13
  #include "rmagick.h"
14
14
 
15
+ static void Info_free(void *infoptr);
16
+ static size_t Info_memsize(const void *infoptr);
15
17
 
16
-
18
+ const rb_data_type_t rm_info_data_type = {
19
+ "Magick::Image::Info",
20
+ { NULL, Info_free, Info_memsize, },
21
+ 0, 0,
22
+ RUBY_TYPED_FROZEN_SHAREABLE,
23
+ };
17
24
 
18
25
 
19
26
  /**
20
27
  * Return the value of the specified option.
21
28
  *
22
- * Ruby usage:
23
- * - @verbatim Info#get_option(key) @endverbatim
29
+ * No Ruby usage (internal function)
24
30
  *
25
31
  * @param self this object
26
32
  * @param key the option key
@@ -32,7 +38,7 @@ get_option(VALUE self, const char *key)
32
38
  Info *info;
33
39
  const char *value;
34
40
 
35
- Data_Get_Struct(self, Info, info);
41
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
36
42
 
37
43
  value = GetImageOption(info, key);
38
44
  if (value)
@@ -46,32 +52,32 @@ get_option(VALUE self, const char *key)
46
52
  * Set the specified option to this value. If the value is nil just unset any
47
53
  * current value.
48
54
  *
49
- * Ruby usage:
50
- * - @verbatim Info#set_option(key,string) @endverbatim
55
+ * No Ruby usage (internal function)
51
56
  *
52
57
  * @param self this object
53
58
  * @param key the option key
54
59
  * @param string the value
55
- * @return self
60
+ * @return string
56
61
  */
57
62
  static VALUE
58
63
  set_option(VALUE self, const char *key, VALUE string)
59
64
  {
60
65
  Info *info;
61
- char *value;
62
66
 
63
- Data_Get_Struct(self, Info, info);
67
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
64
68
 
65
69
  if (NIL_P(string))
66
70
  {
67
- (void) RemoveImageOption(info, key);
71
+ DeleteImageOption(info, key);
68
72
  }
69
73
  else
70
74
  {
71
- value = StringValuePtr(string);
72
- (void) SetImageOption(info, key, value);
75
+ char *value;
76
+
77
+ value = StringValueCStr(string);
78
+ SetImageOption(info, key, value);
73
79
  }
74
- return self;
80
+ return string;
75
81
  }
76
82
 
77
83
 
@@ -81,43 +87,43 @@ set_option(VALUE self, const char *key, VALUE string)
81
87
  * No Ruby usage (internal function)
82
88
  *
83
89
  * Notes:
84
- * - Call QueryColorDatabase to validate color name.
90
+ * - Call QueryColorCompliance to validate color name.
85
91
  *
86
92
  * @param self this object
87
93
  * @param option the option
88
94
  * @param color the color name
89
- * @return self
95
+ * @return color
90
96
  */
91
97
  static VALUE set_color_option(VALUE self, const char *option, VALUE color)
92
98
  {
93
99
  Info *info;
94
- char *name;
95
- PixelPacket pp;
96
- ExceptionInfo *exception;
100
+ PixelColor pp;
97
101
  MagickBooleanType okay;
98
102
 
99
- Data_Get_Struct(self, Info, info);
103
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
100
104
 
101
105
  if (NIL_P(color))
102
106
  {
103
- (void) RemoveImageOption(info, option);
107
+ DeleteImageOption(info, option);
104
108
  }
105
109
  else
106
110
  {
111
+ char *name;
112
+ ExceptionInfo *exception;
113
+
114
+ name = StringValueCStr(color);
107
115
  exception = AcquireExceptionInfo();
108
- name = StringValuePtr(color);
109
- okay = QueryColorDatabase(name, &pp, exception);
110
- (void) DestroyExceptionInfo(exception);
116
+ okay = QueryColorCompliance(name, AllCompliance, &pp, exception);
117
+ DestroyExceptionInfo(exception);
111
118
  if (!okay)
112
119
  {
113
120
  rb_raise(rb_eArgError, "invalid color name `%s'", name);
114
121
  }
115
122
 
116
- (void) RemoveImageOption(info, option);
117
- (void) SetImageOption(info, option, name);
123
+ SetImageOption(info, option, name);
118
124
  }
119
125
 
120
- return self;
126
+ return color;
121
127
  }
122
128
 
123
129
 
@@ -140,7 +146,7 @@ static VALUE get_dbl_option(VALUE self, const char *option)
140
146
  double d;
141
147
  long n;
142
148
 
143
- Data_Get_Struct(self, Info, info);
149
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
144
150
 
145
151
  value = GetImageOption(info, option);
146
152
  if (!value)
@@ -165,94 +171,91 @@ static VALUE get_dbl_option(VALUE self, const char *option)
165
171
  * @param self this object
166
172
  * @param option the option name
167
173
  * @param value the value
168
- * @return self
174
+ * @return value
169
175
  */
170
176
  static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
171
177
  {
172
178
  Info *info;
173
- char buff[50];
174
- double d;
175
- long n;
176
- int len;
177
179
 
178
- Data_Get_Struct(self, Info, info);
180
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
179
181
 
180
182
  if (NIL_P(value))
181
183
  {
182
- (void) RemoveImageOption(info, option);
184
+ DeleteImageOption(info, option);
183
185
  }
184
186
  else
185
187
  {
188
+ char buff[50];
189
+ double d;
190
+ int len;
191
+ long n;
192
+
186
193
  d = NUM2DBL(value);
187
194
  n = floor(d);
188
195
  if (d == n)
189
196
  {
190
- len = sprintf(buff, "%-10ld", n);
197
+ len = snprintf(buff, sizeof(buff), "%-10ld", n);
191
198
  }
192
199
  else
193
200
  {
194
- len = sprintf(buff, "%-10.2f", d);
201
+ len = snprintf(buff, sizeof(buff), "%-10.2f", d);
195
202
  }
196
203
  memset(buff+len, '\0', sizeof(buff)-len);
197
- (void) RemoveImageOption(info, option);
198
- (void) SetImageOption(info, option, buff);
204
+ SetImageOption(info, option, buff);
199
205
  }
200
206
 
201
- return self;
207
+ return value;
202
208
  }
203
209
 
204
210
 
205
- #if 0
206
211
  /**
207
- * Convert a PixelPacket to a hex-format color name.
212
+ * Get antialias value
208
213
  *
209
- * No Ruby usage (internal function)
210
- *
211
- * @param pp the pixel packet
212
- * @param name pointer to the name
213
- * @return the name
214
+ * @return [Boolean] true if antialias is enabled
214
215
  */
215
- static char *pixel_packet_to_hexname(PixelPacket *pp, char *name)
216
+ VALUE
217
+ Info_antialias(VALUE self)
216
218
  {
217
- MagickPixelPacket mpp;
218
-
219
- GetMagickPixelPacket(NULL, &mpp);
220
- rm_set_magick_pixel_packet(pp, &mpp);
221
- (void) GetColorTuple(&mpp, MagickTrue, name);
222
- return name;
219
+ IMPLEMENT_TYPED_ATTR_READER(Info, antialias, boolean, &rm_info_data_type);
223
220
  }
224
- #endif
225
-
226
221
 
227
- DEF_ATTR_ACCESSOR(Info, antialias, bool)
222
+ /**
223
+ * Set antialias value
224
+ *
225
+ * @param val [Boolean] true or false
226
+ * @return [Boolean] the given value
227
+ */
228
+ VALUE
229
+ Info_antialias_eq(VALUE self, VALUE val)
230
+ {
231
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, antialias, boolean, &rm_info_data_type);
232
+ }
228
233
 
229
234
  /** Maximum length of a format (@see Info_aref) */
230
235
  #define MAX_FORMAT_LEN 60
231
236
 
232
237
  /**
233
- * Get the value of an option set by Info[]=
238
+ * Get the value of the specified option for the specified format.
234
239
  *
235
- * Ruby usage:
236
- * - @verbatim Info[format, key] @endverbatim
237
- * - @verbatim Info[key] @endverbatim
240
+ * - The 2 argument form is the original form. Added support for a single
241
+ * argument after ImageMagick started using Set/GetImageOption for options
242
+ * that aren't represented by fields in the ImageInfo structure.
238
243
  *
239
- * Notes:
240
- * - The 2 argument form is the original form. Added support for a single
241
- * argument after ImageMagick started using Set/GetImageOption for options
242
- * that aren't represented by fields in the ImageInfo structure.
244
+ * @overload [](format, key)
245
+ * @param format [String] An image format name such as "ps" or "tiff".
246
+ * @param key [String] A string that identifies the option.
243
247
  *
244
- * @param argc number of input arguments
245
- * @param argv array of input arguments
246
- * @param self this object
247
- * @return the option value
248
- * @see Info_aset
248
+ * @overload [](key)
249
+ * @param key [String] A string that identifies the option.
250
+ *
251
+ * @return [String] The value of the option.
249
252
  */
250
253
  VALUE
251
254
  Info_aref(int argc, VALUE *argv, VALUE self)
252
255
  {
253
256
  Info *info;
254
257
  char *format_p, *key_p;
255
- long format_l, key_l;
258
+ size_t format_l, key_l;
256
259
  const char *value;
257
260
  char fkey[MaxTextExtent];
258
261
 
@@ -266,12 +269,11 @@ Info_aref(int argc, VALUE *argv, VALUE self)
266
269
  rb_raise(rb_eArgError, "can't reference %.60s:%.1024s - too long", format_p, key_p);
267
270
  }
268
271
 
269
- sprintf(fkey, "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
272
+ snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
270
273
  break;
271
274
 
272
275
  case 1:
273
- strncpy(fkey, StringValuePtr(argv[0]), sizeof(fkey)-1);
274
- fkey[sizeof(fkey)-1] = '\0';
276
+ strlcpy(fkey, StringValueCStr(argv[0]), sizeof(fkey));
275
277
  break;
276
278
 
277
279
  default:
@@ -280,7 +282,7 @@ Info_aref(int argc, VALUE *argv, VALUE self)
280
282
 
281
283
  }
282
284
 
283
- Data_Get_Struct(self, Info, info);
285
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
284
286
  value = GetImageOption(info, fkey);
285
287
  if (!value)
286
288
  {
@@ -292,26 +294,23 @@ Info_aref(int argc, VALUE *argv, VALUE self)
292
294
 
293
295
 
294
296
  /**
295
- * Call SetImageOption
297
+ * Define an option. An alternative to {Info#define}.
298
+ * Use this method to set options for reading or writing certain image formats.
296
299
  *
297
- * Ruby usage:
298
- * - @verbatim Info[format, key]= @endverbatim
299
- * - @verbatim Info[key]= @endverbatim
300
+ * - Essentially the same function as {Info#define} but paired with {Info#[]}
301
+ * - If the value is nil it is equivalent to {Info#undefine}.
300
302
  *
301
- * Notes:
302
- * - Essentially the same function as Info_define but paired with Info_aref
303
- * - If the value is nil it is equivalent to Info_undefine.
304
- * - The 2 argument form is the original form. Added support for a single
305
- * argument after ImageMagick started using Set/GetImageOption for options
306
- * that aren't represented by fields in the ImageInfo structure.
307
- *
308
- * @param argc number of input arguments
309
- * @param argv array of input arguments
310
- * @param self this object
311
- * @return self
312
- * @see Info_aref
313
- * @see Info_define
314
- * @see Info_undefine
303
+ * @overload []=(format, key)
304
+ * @param format [String] An image format name such as "ps" or "tiff".
305
+ * @param key [String] A string that identifies the option.
306
+ *
307
+ * @overload []=(key)
308
+ * @param key [String] A string that identifies the option.
309
+ *
310
+ * @return [Magick::Image::Info] self
311
+ * @see #[]
312
+ * @see #define
313
+ * @see #undefine
315
314
  */
316
315
  VALUE
317
316
  Info_aset(int argc, VALUE *argv, VALUE self)
@@ -319,12 +318,10 @@ Info_aset(int argc, VALUE *argv, VALUE self)
319
318
  Info *info;
320
319
  VALUE value;
321
320
  char *format_p, *key_p, *value_p = NULL;
322
- long format_l, key_l;
321
+ size_t format_l, key_l;
323
322
  char ckey[MaxTextExtent];
324
- unsigned int okay;
325
323
 
326
-
327
- Data_Get_Struct(self, Info, info);
324
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
328
325
 
329
326
  switch (argc)
330
327
  {
@@ -337,14 +334,13 @@ Info_aset(int argc, VALUE *argv, VALUE self)
337
334
  rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
338
335
  }
339
336
 
340
- (void) sprintf(ckey, "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
337
+ snprintf(ckey, sizeof(ckey), "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
341
338
 
342
339
  value = argv[2];
343
340
  break;
344
341
 
345
342
  case 2:
346
- strncpy(ckey, StringValuePtr(argv[0]), sizeof(ckey)-1);
347
- ckey[sizeof(ckey)-1] = '\0';
343
+ strlcpy(ckey, StringValueCStr(argv[0]), sizeof(ckey));
348
344
 
349
345
  value = argv[1];
350
346
  break;
@@ -356,15 +352,16 @@ Info_aset(int argc, VALUE *argv, VALUE self)
356
352
 
357
353
  if (NIL_P(value))
358
354
  {
359
- (void) RemoveImageOption(info, ckey);
355
+ DeleteImageOption(info, ckey);
360
356
  }
361
357
  else
362
358
  {
359
+ unsigned int okay;
360
+
363
361
  /* Allow any argument that supports to_s */
364
- value = rm_to_s(value);
365
- value_p = StringValuePtr(value);
362
+ value = rb_String(value);
363
+ value_p = StringValueCStr(value);
366
364
 
367
- (void) RemoveImageOption(info, ckey);
368
365
  okay = SetImageOption(info, ckey, value_p);
369
366
  if (!okay)
370
367
  {
@@ -380,13 +377,9 @@ Info_aset(int argc, VALUE *argv, VALUE self)
380
377
 
381
378
 
382
379
  /**
383
- * Get the attenuate attribute.
380
+ * Get the attenuate value.
384
381
  *
385
- * Ruby usage:
386
- * - @verbatim Info#attenuate @endverbatim
387
- *
388
- * @param self this object
389
- * @return the attenuate
382
+ * @return [Float] the attenuate
390
383
  */
391
384
  VALUE
392
385
  Info_attenuate(VALUE self)
@@ -396,14 +389,10 @@ Info_attenuate(VALUE self)
396
389
 
397
390
 
398
391
  /**
399
- * Set the attenuate attribute.
392
+ * Set the attenuate value.
400
393
  *
401
- * Ruby usage:
402
- * - @verbatim Info#attenuate= @endverbatim
403
- *
404
- * @param self this object
405
- * @param value the attenuate
406
- * @return self
394
+ * @param value [Float] the attenuate
395
+ * @return [Float] the attenuate
407
396
  */
408
397
  VALUE
409
398
  Info_attenuate_eq(VALUE self, VALUE value)
@@ -413,170 +402,139 @@ Info_attenuate_eq(VALUE self, VALUE value)
413
402
 
414
403
 
415
404
  /**
416
- * Get the authenticate attribute.
417
- *
418
- * Ruby usage:
419
- * - @verbatim Info#authenticate @endverbatim
405
+ * Get the authenticate value.
420
406
  *
421
- * @param self this object
422
- * @return the authenticate
407
+ * @return [String] the authenticate
423
408
  */
424
409
  VALUE
425
410
  Info_authenticate(VALUE self)
426
411
  {
427
412
  Info *info;
428
413
 
429
- Data_Get_Struct(self, Info, info);
430
- if (info->authenticate)
431
- {
432
- return rb_str_new2(info->authenticate);
433
- }
434
- else
435
- {
436
- return Qnil;
437
- }
414
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
415
+ #if defined(IMAGEMAGICK_7)
416
+ return C_str_to_R_str(GetImageOption(info, "authenticate"));
417
+ #else
418
+ return C_str_to_R_str(info->authenticate);
419
+ #endif
438
420
  }
439
421
 
440
422
 
441
423
  /**
442
- * Set the authenticate attribute.
424
+ * Set the authenticate value.
443
425
  *
444
- * Ruby usage:
445
- * - @verbatim Info#authenticate= @endverbatim
446
- *
447
- * @param self this object
448
- * @param passwd the authenticating password
449
- * @return self
426
+ * @param passwd_arg [String] the authenticating password
427
+ * @return [String] the given value
450
428
  */
451
429
  VALUE
452
- Info_authenticate_eq(VALUE self, VALUE passwd)
430
+ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
453
431
  {
454
432
  Info *info;
455
- char *passwd_p = NULL;
456
- long passwd_l = 0;
433
+ char *passwd = NULL;
457
434
 
458
- Data_Get_Struct(self, Info, info);
435
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
459
436
 
460
- if (!NIL_P(passwd))
437
+ if (!NIL_P(passwd_arg))
461
438
  {
462
- passwd_p = rm_str2cstr(passwd, &passwd_l);
439
+ passwd = StringValueCStr(passwd_arg);
463
440
  }
464
441
 
442
+ #if defined(IMAGEMAGICK_7)
443
+ if (passwd)
444
+ {
445
+ SetImageOption(info, "authenticate", passwd);
446
+ }
447
+ else
448
+ {
449
+ RemoveImageOption(info, "authenticate");
450
+ }
451
+ #else
465
452
  if (info->authenticate)
466
453
  {
467
454
  magick_free(info->authenticate);
468
455
  info->authenticate = NULL;
469
456
  }
470
- if (passwd_l > 0)
457
+ if (passwd)
471
458
  {
472
- magick_clone_string(&info->authenticate, passwd_p);
459
+ magick_clone_string(&info->authenticate, passwd);
473
460
  }
461
+ #endif
474
462
 
475
- return self;
463
+ return passwd_arg;
476
464
  }
477
465
 
478
466
 
479
467
  /**
480
468
  * Return the name of the background color as a String
481
469
  *
482
- * Ruby usage:
483
- * - @verbatim Info#background_color @endverbatim
484
- *
485
- * @param self this object
486
- * @return the name of the background color
487
- * @see Image_background_color
470
+ * @return [String] the name of the background color
471
+ * @see Image#background_color
488
472
  */
489
473
  VALUE
490
474
  Info_background_color(VALUE self)
491
475
  {
492
476
  Info *info;
493
477
 
494
- Data_Get_Struct(self, Info, info);
495
- return rm_pixelpacket_to_color_name_info(info, &info->background_color);
478
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
479
+ return rm_pixelcolor_to_color_name_info(info, &info->background_color);
496
480
  }
497
481
 
498
482
 
499
483
  /**
500
484
  * Set the background color.
501
485
  *
502
- * Ruby usage:
503
- * - @verbatim Info#background_color= @endverbatim
504
- *
505
- * Notes:
506
- * - Color should be a string
507
- *
508
- * @param self this object
509
- * @param bc_arg the background color
510
- * @return self
511
- * @throw ArgumentError
486
+ * @param bc_arg [Magick::Pixel, String] the background color
487
+ * @return [Magick::Pixel, String] the given color
512
488
  */
513
489
  VALUE
514
490
  Info_background_color_eq(VALUE self, VALUE bc_arg)
515
491
  {
516
492
  Info *info;
517
- //char colorname[MaxTextExtent];
518
493
 
519
- Data_Get_Struct(self, Info, info);
520
- Color_to_PixelPacket(&info->background_color, bc_arg);
521
- //SetImageOption(info, "background", pixel_packet_to_hexname(&info->background_color, colorname));
522
- return self;
494
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
495
+ Color_to_PixelColor(&info->background_color, bc_arg);
496
+
497
+ return bc_arg;
523
498
  }
524
499
 
525
500
  /**
526
501
  * Return the name of the border color as a String.
527
502
  *
528
- * Ruby usage:
529
- * - @verbatim Info#border_color @endverbatim
530
- *
531
- * @param self this object
532
- * @return the border color
533
- * @see Image_border_color
503
+ * @return [String] the border color name
504
+ * @see Image#border_color
534
505
  */
535
506
  VALUE
536
507
  Info_border_color(VALUE self)
537
508
  {
538
509
  Info *info;
539
510
 
540
- Data_Get_Struct(self, Info, info);
541
- return rm_pixelpacket_to_color_name_info(info, &info->border_color);
511
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
512
+ return rm_pixelcolor_to_color_name_info(info, &info->border_color);
542
513
  }
543
514
 
544
515
  /**
545
516
  * set the border color
546
517
  *
547
- * Ruby usage:
548
- * - @verbatim Info#border_color= @endverbatim
549
- *
550
- * Notes:
551
- * - Color should be a string
552
- *
553
- * @param self this object
554
- * @param bc_arg the border color
555
- * @return self
556
- * @throw ArgumentError
518
+ * @param bc_arg [Magick::Pixel, String] the border color
519
+ * @return [Magick::Pixel, String] the given color
557
520
  */
558
521
  VALUE
559
522
  Info_border_color_eq(VALUE self, VALUE bc_arg)
560
523
  {
561
524
  Info *info;
562
- //char colorname[MaxTextExtent];
563
525
 
564
- Data_Get_Struct(self, Info, info);
565
- Color_to_PixelPacket(&info->border_color, bc_arg);
566
- //SetImageOption(info, "bordercolor", pixel_packet_to_hexname(&info->border_color, colorname));
567
- return self;
526
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
527
+ Color_to_PixelColor(&info->border_color, bc_arg);
528
+
529
+ return bc_arg;
568
530
  }
569
531
 
570
532
 
571
533
 
572
534
  /**
573
- * Emulate the -caption option.
535
+ * Get a caption of image
574
536
  *
575
- * Ruby usage:
576
- * - @verbatim Info#caption @endverbatim
577
- *
578
- * @param self this object
579
- * @return the caption
537
+ * @return [String] the caption
580
538
  */
581
539
  VALUE
582
540
  Info_caption(VALUE self)
@@ -587,14 +545,10 @@ Info_caption(VALUE self)
587
545
 
588
546
 
589
547
  /**
590
- * Emulate the -caption option.
548
+ * Assigns a caption to an image.
591
549
  *
592
- * Ruby usage:
593
- * - @verbatim Info#caption= @endverbatim
594
- *
595
- * @param self this object
596
- * @param caption the caption
597
- * @return self
550
+ * @param caption [String] the caption
551
+ * @return [String] the given value
598
552
  */
599
553
  VALUE
600
554
  Info_caption_eq(VALUE self, VALUE caption)
@@ -606,19 +560,13 @@ Info_caption_eq(VALUE self, VALUE caption)
606
560
  /**
607
561
  * Set the channels
608
562
  *
609
- * Ruby usage:
610
- * - @verbatim Info#channel @endverbatim
611
- * - @verbatim Info#channel(channel) @endverbatim
612
- * - @verbatim Info#channel(channel, ...) @endverbatim
563
+ * @overload channel(channel = Magick::AllChannels)
564
+ * @param channel [Magick::ChannelType] the channel
613
565
  *
614
- * Notes:
615
- * - Default channel is AllChannels
616
- * - Thanks to Douglas Sellers.
566
+ * @overload channel(*channels)
567
+ * @param channels [Magick::ChannelType] the multiple arguments of channel
617
568
  *
618
- * @param argc number of input arguments
619
- * @param argv array of input arguments
620
- * @param self this object
621
- * @return self
569
+ * @return [Magick::Image::Info] self
622
570
  */
623
571
  VALUE
624
572
  Info_channel(int argc, VALUE *argv, VALUE self)
@@ -634,7 +582,7 @@ Info_channel(int argc, VALUE *argv, VALUE self)
634
582
  raise_ChannelType_error(argv[argc-1]);
635
583
  }
636
584
 
637
- Data_Get_Struct(self, Info, info);
585
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
638
586
 
639
587
  info->channel = channels;
640
588
  return self;
@@ -644,98 +592,93 @@ Info_channel(int argc, VALUE *argv, VALUE self)
644
592
  /**
645
593
  * Get the colorspace type.
646
594
  *
647
- * Ruby usage:
648
- * - @verbatim Info#colorspace @endverbatim
649
- *
650
- * @param self this object
651
- * @return the colorspace type
595
+ * @return [Magick::ColorspaceType] the colorspace type
652
596
  */
653
597
  VALUE
654
598
  Info_colorspace(VALUE self)
655
599
  {
656
600
  Info *info;
657
601
 
658
- Data_Get_Struct(self, Info, info);
659
- return ColorspaceType_new(info->colorspace);
602
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
603
+ return ColorspaceType_find(info->colorspace);
660
604
  }
661
605
 
662
606
  /**
663
607
  * Set the colorspace type
664
608
  *
665
- * Ruby usage:
666
- * - @verbatim Info#colorspace= @endverbatim
667
- *
668
- * @param self this object
669
- * @param colorspace the colorspace type
670
- * @return self
671
- * @throw ArgumentError
609
+ * @param colorspace [Magick::ColorspaceType] the colorspace type
610
+ * @return [Magick::ColorspaceType] the given colorspace
672
611
  */
673
612
  VALUE
674
613
  Info_colorspace_eq(VALUE self, VALUE colorspace)
675
614
  {
676
615
  Info *info;
677
616
 
678
- Data_Get_Struct(self, Info, info);
617
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
679
618
  VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
680
- return self;
619
+ return colorspace;
681
620
  }
682
621
 
683
- OPTION_ATTR_ACCESSOR(comment, Comment)
622
+ /**
623
+ * Get the comment.
624
+ *
625
+ * @return [String] the comment
626
+ */
627
+ VALUE Info_comment(VALUE self)
628
+ {
629
+ return get_option(self, "Comment");
630
+ }
684
631
 
685
632
  /**
686
- * Get the compression type.
633
+ * Set the comment
687
634
  *
688
- * Ruby usage:
689
- * - @verbatim Info#compression @endverbatim
635
+ * @param string [String] the comment
636
+ * @return [String] the given comment
637
+ */
638
+ VALUE Info_comment_eq(VALUE self, VALUE string)
639
+ {
640
+ return set_option(self, "Comment", string);
641
+ }
642
+
643
+ /**
644
+ * Get the compression type.
690
645
  *
691
- * @param self this object
692
- * @return the compression type
646
+ * @return [Magick::CompressionType] the compression type
693
647
  */
694
648
  VALUE
695
649
  Info_compression(VALUE self)
696
650
  {
697
651
  Info *info;
698
652
 
699
- Data_Get_Struct(self, Info, info);
700
- return CompressionType_new(info->compression);
653
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
654
+ return CompressionType_find(info->compression);
701
655
  }
702
656
 
703
657
  /**
704
658
  * Set the compression type
705
659
  *
706
- * Ruby usage:
707
- * - @verbatim Info#compression= @endverbatim
708
- *
709
- * @param self this object
710
- * @param type the compression type
711
- * @return self
712
- * @throw ArgumentError
660
+ * @param type [Magick::CompressionType] the compression type
661
+ * @return [Magick::CompressionType] the given type
713
662
  */
714
663
  VALUE
715
664
  Info_compression_eq(VALUE self, VALUE type)
716
665
  {
717
666
  Info *info;
718
667
 
719
- Data_Get_Struct(self, Info, info);
668
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
720
669
  VALUE_TO_ENUM(type, info->compression, CompressionType);
721
- return self;
670
+ return type;
722
671
  }
723
672
 
724
673
  /**
725
- * Call SetImageOption
674
+ * Define an option.
726
675
  *
727
- * Ruby usage:
728
- * - @verbatim Info#define(format, key) @endverbatim
729
- * - @verbatim Info#define(format, key, value) @endverbatim
730
- *
731
- * Notes:
732
- * - Default value is the empty string
733
- * - This is the only method in Info that is not an attribute accessor.
676
+ * @overload Info#define(format, key, value = "")
677
+ * @param format [String] An image format name such as "ps" or "tiff".
678
+ * @param key [String] A string that identifies the option.
679
+ * @param value [String] A value of option
734
680
  *
735
- * @param argc number of input arguments
736
- * @param argv array of input arguments
737
- * @param self this object
738
- * @return self
681
+ * @return [Magick::Image::Info] self
739
682
  */
740
683
  VALUE
741
684
  Info_define(int argc, VALUE *argv, VALUE self)
@@ -743,19 +686,19 @@ Info_define(int argc, VALUE *argv, VALUE self)
743
686
  Info *info;
744
687
  char *format, *key;
745
688
  const char *value = "";
746
- long format_l, key_l;
689
+ size_t format_l, key_l;
747
690
  char ckey[100];
748
691
  unsigned int okay;
749
692
  VALUE fmt_arg;
750
693
 
751
- Data_Get_Struct(self, Info, info);
694
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
752
695
 
753
696
  switch (argc)
754
697
  {
755
698
  case 3:
756
699
  /* Allow any argument that supports to_s */
757
700
  fmt_arg = rb_String(argv[2]);
758
- value = (const char *)StringValuePtr(fmt_arg);
701
+ value = (const char *)StringValueCStr(fmt_arg);
759
702
  case 2:
760
703
  key = rm_str2cstr(argv[1], &key_l);
761
704
  format = rm_str2cstr(argv[0], &format_l);
@@ -768,9 +711,9 @@ Info_define(int argc, VALUE *argv, VALUE self)
768
711
  {
769
712
  rb_raise(rb_eArgError, "%.20s:%.20s not defined - format or key too long", format, key);
770
713
  }
771
- (void) sprintf(ckey, "%s:%s", format, key);
714
+ snprintf(ckey, sizeof(ckey), "%s:%s", format, key);
772
715
 
773
- (void) RemoveImageOption(info, ckey);
716
+ DeleteImageOption(info, ckey);
774
717
  okay = SetImageOption(info, ckey, value);
775
718
  if (!okay)
776
719
  {
@@ -784,16 +727,9 @@ Info_define(int argc, VALUE *argv, VALUE self)
784
727
  }
785
728
 
786
729
  /**
787
- * Get the delay attribute.
730
+ * Get the delay value.
788
731
  *
789
- * Ruby usage:
790
- * - @verbatim Info#delay @endverbatim
791
- *
792
- * Notes:
793
- * - Convert from string to numeric
794
- *
795
- * @param self this object
796
- * @return the delay
732
+ * @return [Numeric, nil] the delay
797
733
  */
798
734
  VALUE
799
735
  Info_delay(VALUE self)
@@ -801,13 +737,14 @@ Info_delay(VALUE self)
801
737
  Info *info;
802
738
  const char *delay;
803
739
  char *p;
804
- long d;
805
740
 
806
- Data_Get_Struct(self, Info, info);
741
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
807
742
 
808
743
  delay = GetImageOption(info, "delay");
809
744
  if (delay)
810
745
  {
746
+ long d;
747
+
811
748
  d = strtol(delay, &p, 10);
812
749
  if (*p != '\0')
813
750
  {
@@ -829,78 +766,62 @@ Info_delay(VALUE self)
829
766
  static VALUE
830
767
  arg_is_integer(VALUE arg)
831
768
  {
832
- int d = NUM2INT(arg);
833
- d = d; // satisfy icc
834
- return arg;
769
+ return INT2NUM(NUM2INT(arg));
835
770
  }
836
771
 
837
772
  /**
838
- * Set the delay attribute.
773
+ * Set the delay value.
839
774
  *
840
- * Ruby usage:
841
- * - @verbatim Info#delay= @endverbatim
842
- *
843
- * Notes:
844
- * - Convert from numeric value to string.
845
- *
846
- * @param self this object
847
- * @param string the delay
848
- * @return self
775
+ * @param string [String] the delay
776
+ * @return [String] the given value
849
777
  */
850
778
  VALUE
851
779
  Info_delay_eq(VALUE self, VALUE string)
852
780
  {
853
781
  Info *info;
854
- int delay;
855
782
  int not_num;
856
- char dstr[20];
857
783
 
858
- Data_Get_Struct(self, Info, info);
784
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
859
785
 
860
786
  if (NIL_P(string))
861
787
  {
862
- (void) RemoveImageOption(info, "delay");
788
+ DeleteImageOption(info, "delay");
863
789
  }
864
790
  else
865
791
  {
792
+ char dstr[20];
793
+ int delay;
794
+
866
795
  not_num = 0;
867
- (void) rb_protect(arg_is_integer, string, &not_num);
796
+ rb_protect(arg_is_integer, string, &not_num);
868
797
  if (not_num)
869
798
  {
870
799
  rb_raise(rb_eTypeError, "failed to convert %s into Integer", rb_class2name(CLASS_OF(string)));
871
800
  }
872
801
  delay = NUM2INT(string);
873
- sprintf(dstr, "%d", delay);
874
- (void) RemoveImageOption(info, "delay");
875
- (void) SetImageOption(info, "delay", dstr);
802
+ snprintf(dstr, sizeof(dstr), "%d", delay);
803
+ SetImageOption(info, "delay", dstr);
876
804
  }
877
- return self;
805
+ return string;
878
806
  }
879
807
 
880
808
  /**
881
- * Get the density attribute
882
- *
883
- * Ruby usage:
884
- * - @verbatim Info#density @endverbatim
809
+ * Get the density value
885
810
  *
886
- * @param self this object
887
- * @return the density
811
+ * @return [String] the density
888
812
  */
889
- DEF_ATTR_READER(Info, density, str)
813
+ VALUE
814
+ Info_density(VALUE self)
815
+ {
816
+ IMPLEMENT_TYPED_ATTR_READER(Info, density, str, &rm_info_data_type);
817
+ }
890
818
 
891
819
  /**
892
- * Set the text rendering density
820
+ * Set the text rendering density geometry
893
821
  *
894
- * Ruby usage:
895
- * - @verbatim Info#density= @endverbatim
896
- *
897
- * Notes:
898
- * - density should be a string, e.g., "72x72"
899
- *
900
- * @param self this object
901
- * @param density_arg the density
902
- * @return self
903
- * @throw ArgumentError
822
+ * @param density_arg [Magick::Geometry, String] the density
823
+ * @return [Magick::Geometry, String] the given value
824
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
904
825
  */
905
826
  VALUE
906
827
  Info_density_eq(VALUE self, VALUE density_arg)
@@ -909,17 +830,17 @@ Info_density_eq(VALUE self, VALUE density_arg)
909
830
  VALUE density;
910
831
  char *dens;
911
832
 
912
- Data_Get_Struct(self, Info, info);
833
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
913
834
 
914
835
  if (NIL_P(density_arg))
915
836
  {
916
837
  magick_free(info->density);
917
838
  info->density = NULL;
918
- return self;
839
+ return density_arg;
919
840
  }
920
841
 
921
- density = rm_to_s(density_arg);
922
- dens = StringValuePtr(density);
842
+ density = rb_String(density_arg);
843
+ dens = StringValueCStr(density);
923
844
  if (!IsGeometry(dens))
924
845
  {
925
846
  rb_raise(rb_eArgError, "invalid density geometry: %s", dens);
@@ -929,30 +850,25 @@ Info_density_eq(VALUE self, VALUE density_arg)
929
850
 
930
851
  RB_GC_GUARD(density);
931
852
 
932
- return self;
853
+ return density_arg;
933
854
  }
934
855
 
935
856
  /**
936
- * Get the depth attribute
857
+ * Get the depth value
937
858
  *
938
- * Ruby usage:
939
- * - @verbatim Info#depth @endverbatim
940
- *
941
- * @param self this object
942
- * @return the depth
859
+ * @return [Numeric] the depth
943
860
  */
944
- DEF_ATTR_READER(Info, depth, int)
861
+ VALUE
862
+ Info_depth(VALUE self)
863
+ {
864
+ IMPLEMENT_TYPED_ATTR_READER(Info, depth, int, &rm_info_data_type);
865
+ }
945
866
 
946
867
  /**
947
- * Set the depth (8, 16, 32).
948
- *
949
- * Ruby usage:
950
- * - @verbatim Info#depth= @endverbatim
868
+ * Set the depth (8, 16, 32, 64).
951
869
  *
952
- * @param self this object
953
- * @param depth the depth
954
- * @return self
955
- * @throw ArgumentError
870
+ * @param depth [Numeric] the depth
871
+ * @return [Numeric] the given depth
956
872
  */
957
873
  VALUE
958
874
  Info_depth_eq(VALUE self, VALUE depth)
@@ -960,7 +876,7 @@ Info_depth_eq(VALUE self, VALUE depth)
960
876
  Info *info;
961
877
  unsigned long d;
962
878
 
963
- Data_Get_Struct(self, Info, info);
879
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
964
880
  d = NUM2ULONG(depth);
965
881
  switch (d)
966
882
  {
@@ -981,7 +897,7 @@ Info_depth_eq(VALUE self, VALUE depth)
981
897
  }
982
898
 
983
899
  info->depth = d;
984
- return self;
900
+ return depth;
985
901
  }
986
902
 
987
903
  /** A dispose option */
@@ -1035,29 +951,24 @@ DisposeType rm_dispose_to_enum(const char *name)
1035
951
  * Retrieve the dispose option string and convert it to a DisposeType
1036
952
  * enumerator.
1037
953
  *
1038
- * Ruby usage:
1039
- * - @verbatim Info#dispose @endverbatim
1040
- *
1041
- * @param self this object
1042
- * @return a DisposeType enumerator
954
+ * @return [Magick::DisposeType] a DisposeType enumerator
1043
955
  */
1044
956
  VALUE
1045
957
  Info_dispose(VALUE self)
1046
958
  {
1047
959
  Info *info;
1048
- int x;
1049
960
  ID dispose_id;
1050
961
  const char *dispose;
1051
962
 
1052
- Data_Get_Struct(self, Info, info);
963
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1053
964
 
1054
965
  dispose_id = rb_intern("UndefinedDispose");
1055
966
 
1056
967
  // Map the dispose option string to a DisposeType enumerator.
1057
- dispose=GetImageOption(info, "dispose");
968
+ dispose = GetImageOption(info, "dispose");
1058
969
  if (dispose)
1059
970
  {
1060
- for (x = 0; x < N_DISPOSE_OPTIONS; x++)
971
+ for (int x = 0; x < N_DISPOSE_OPTIONS; x++)
1061
972
  {
1062
973
  if (strcmp(dispose, Dispose_Option[x].string) == 0)
1063
974
  {
@@ -1073,12 +984,8 @@ Info_dispose(VALUE self)
1073
984
  /**
1074
985
  * Convert a DisposeType enumerator into the equivalent dispose option string.
1075
986
  *
1076
- * Ruby usage:
1077
- * - @verbatim Info#dispose= @endverbatim
1078
- *
1079
- * @param self this object
1080
- * @param disp the DisposeType enumerator
1081
- * @return self
987
+ * @param disp [Magic::DisposeType] the DisposeType enumerator
988
+ * @return [Magic::DisposeType] the given value
1082
989
  */
1083
990
  VALUE
1084
991
  Info_dispose_eq(VALUE self, VALUE disp)
@@ -1088,12 +995,12 @@ Info_dispose_eq(VALUE self, VALUE disp)
1088
995
  const char *option;
1089
996
  int x;
1090
997
 
1091
- Data_Get_Struct(self, Info, info);
998
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1092
999
 
1093
1000
  if (NIL_P(disp))
1094
1001
  {
1095
- (void) RemoveImageOption(info, "dispose");
1096
- return self;
1002
+ DeleteImageOption(info, "dispose");
1003
+ return disp;
1097
1004
  }
1098
1005
 
1099
1006
  VALUE_TO_ENUM(disp, dispose, DisposeType);
@@ -1108,41 +1015,54 @@ Info_dispose_eq(VALUE self, VALUE disp)
1108
1015
  }
1109
1016
  }
1110
1017
 
1111
- (void) SetImageOption(info, "dispose", option);
1112
- return self;
1018
+ SetImageOption(info, "dispose", option);
1019
+ return disp;
1113
1020
  }
1114
1021
 
1115
- DEF_ATTR_ACCESSOR(Info, dither, bool)
1116
-
1022
+ /**
1023
+ * Get dither value
1024
+ *
1025
+ * @return [Boolean] true if dither is enabled
1026
+ */
1027
+ VALUE
1028
+ Info_dither(VALUE self)
1029
+ {
1030
+ IMPLEMENT_TYPED_ATTR_READER(Info, dither, boolean, &rm_info_data_type);
1031
+ }
1117
1032
 
1118
1033
  /**
1119
- * Get the endian attribute.
1034
+ * Set dither value
1120
1035
  *
1121
- * Ruby usage:
1122
- * - @verbatim Info#endian @endverbatim
1036
+ * @param val [Boolean] true if dither will be enabled
1037
+ * @return [Boolean] true if dither is enabled
1038
+ */
1039
+ VALUE
1040
+ Info_dither_eq(VALUE self, VALUE val)
1041
+ {
1042
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, dither, boolean, &rm_info_data_type);
1043
+ }
1044
+
1045
+
1046
+ /**
1047
+ * Get the endian value.
1123
1048
  *
1124
- * @param self this object
1125
- * @return the endian (Magick::MSBEndian or Magick::LSBEndian)
1049
+ * @return [Magick::EndianType] the endian
1126
1050
  */
1127
1051
  VALUE
1128
1052
  Info_endian(VALUE self)
1129
1053
  {
1130
1054
  Info *info;
1131
1055
 
1132
- Data_Get_Struct(self, Info, info);
1133
- return EndianType_new(info->endian);
1056
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1057
+ return EndianType_find(info->endian);
1134
1058
  }
1135
1059
 
1136
1060
 
1137
1061
  /**
1138
- * Set the endian attribute.
1062
+ * Set the endian value.
1139
1063
  *
1140
- * Ruby usage:
1141
- * - @verbatim Info#endian= @endverbatim
1142
- *
1143
- * @param self this object
1144
- * @param endian the endian (Magick::MSBEndian or Magick::LSBEndian)
1145
- * @return self
1064
+ * @param endian [Magick::EndianType] the endian
1065
+ * @return [Magick::EndianType] the given endian
1146
1066
  */
1147
1067
  VALUE
1148
1068
  Info_endian_eq(VALUE self, VALUE endian)
@@ -1155,39 +1075,30 @@ Info_endian_eq(VALUE self, VALUE endian)
1155
1075
  VALUE_TO_ENUM(endian, type, EndianType);
1156
1076
  }
1157
1077
 
1158
- Data_Get_Struct(self, Info, info);
1078
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1159
1079
  info->endian = type;
1160
- return self;
1080
+ return endian;
1161
1081
  }
1162
1082
 
1163
1083
 
1164
1084
  /**
1165
- * Get the extract string, e.g. "200x200+100+100"
1085
+ * Get the extract geometry, e.g. "200x200+100+100"
1166
1086
  *
1167
- * Ruby usage:
1168
- * - @verbatim Info#extract @endverbatim
1169
- *
1170
- * Notes:
1171
- * - Defined for ImageMagick 5.5.6 and later
1172
- *
1173
- * @param self this object
1174
- * @return the extract string
1087
+ * @return [String] the extract string
1088
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
1175
1089
  */
1176
- DEF_ATTR_READER(Info, extract, str)
1090
+ VALUE
1091
+ Info_extract(VALUE self)
1092
+ {
1093
+ IMPLEMENT_TYPED_ATTR_READER(Info, extract, str, &rm_info_data_type);
1094
+ }
1177
1095
 
1178
1096
  /**
1179
- * Set the extract string, e.g. "200x200+100+100"
1180
- *
1181
- * Ruby usage:
1182
- * - @verbatim Info#extract= @endverbatim
1183
- *
1184
- * Notes:
1185
- * - Defined for ImageMagick 5.5.6 and later
1097
+ * Set the extract geometry.
1186
1098
  *
1187
- * @param self this object
1188
- * @param extract_arg the extract string
1189
- * @return self
1190
- * @throw ArgumentError
1099
+ * @param extract_arg [Magick::Geometry, String] the extract string
1100
+ * @return [Magick::Geometry, String] the given value
1101
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
1191
1102
  */
1192
1103
  VALUE
1193
1104
  Info_extract_eq(VALUE self, VALUE extract_arg)
@@ -1196,17 +1107,17 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1196
1107
  char *extr;
1197
1108
  VALUE extract;
1198
1109
 
1199
- Data_Get_Struct(self, Info, info);
1110
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1200
1111
 
1201
1112
  if (NIL_P(extract_arg))
1202
1113
  {
1203
1114
  magick_free(info->extract);
1204
1115
  info->extract = NULL;
1205
- return self;
1116
+ return extract_arg;
1206
1117
  }
1207
1118
 
1208
- extract = rm_to_s(extract_arg);
1209
- extr = StringValuePtr(extract);
1119
+ extract = rb_String(extract_arg);
1120
+ extr = StringValueCStr(extract);
1210
1121
  if (!IsGeometry(extr))
1211
1122
  {
1212
1123
  rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
@@ -1216,77 +1127,62 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1216
1127
 
1217
1128
  RB_GC_GUARD(extract);
1218
1129
 
1219
- return self;
1130
+ return extract_arg;
1220
1131
  }
1221
1132
 
1222
1133
 
1223
1134
  /**
1224
- * Get the "filename".
1135
+ * Get the "filename" value.
1225
1136
  *
1226
- * Ruby usage:
1227
- * - @verbatim Info#filename @endverbatim
1228
- *
1229
- * Notes:
1230
- * - Only used for Image_capture
1231
- *
1232
- * @param self this object
1233
- * @return the filename ("" if filename not set)
1234
- * @see Image_capture
1137
+ * @return [String] the file name ("" if filename not set)
1138
+ * @note Only used for Image#capture
1139
+ * @see Image#capture
1235
1140
  */
1236
1141
  VALUE
1237
1142
  Info_filename(VALUE self)
1238
1143
  {
1239
1144
  Info *info;
1240
1145
 
1241
- Data_Get_Struct(self, Info, info);
1146
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1242
1147
  return rb_str_new2(info->filename);
1243
1148
  }
1244
1149
 
1245
1150
  /**
1246
- * Set the "filename".
1151
+ * Set the "filename" value.
1247
1152
  *
1248
- * Ruby usage:
1249
- * - @verbatim Info#filename= @endverbatim
1250
- *
1251
- * Notes:
1252
- * - Only used for Image_capture
1253
- *
1254
- * @param self this object
1255
- * @param filename the filename
1256
- * @return self
1257
- * @see Image_capture
1153
+ * @param filename [String] the file name
1154
+ * @return [String] the given file name
1155
+ * @note Only used for Image#capture
1156
+ * @see Image#capture
1258
1157
  */
1259
1158
  VALUE
1260
1159
  Info_filename_eq(VALUE self, VALUE filename)
1261
1160
  {
1262
1161
  Info *info;
1263
- char *fname;
1264
1162
 
1265
- Data_Get_Struct(self, Info, info);
1163
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1266
1164
 
1267
1165
  // Allow "nil" - remove current filename
1268
- if (NIL_P(filename) || StringValuePtr(filename) == NULL)
1166
+ if (NIL_P(filename) || StringValueCStr(filename) == NULL)
1269
1167
  {
1270
1168
  info->filename[0] = '\0';
1271
1169
  }
1272
1170
  else
1273
1171
  {
1172
+ char *fname;
1173
+
1274
1174
  // Otherwise copy in filename
1275
- fname = StringValuePtr(filename);
1276
- strncpy(info->filename, fname, MaxTextExtent);
1175
+ fname = StringValueCStr(filename);
1176
+ strlcpy(info->filename, fname, sizeof(info->filename));
1277
1177
  }
1278
- return self;
1178
+ return filename;
1279
1179
  }
1280
1180
 
1281
1181
 
1282
1182
  /**
1283
1183
  * Return the fill color as a String.
1284
1184
  *
1285
- * Ruby usage:
1286
- * - @verbatim Info#fill @endverbatim
1287
- *
1288
- * @param self this object
1289
- * @return the fill color
1185
+ * @return [String] the fill color
1290
1186
  */
1291
1187
  VALUE
1292
1188
  Info_fill(VALUE self)
@@ -1297,13 +1193,8 @@ Info_fill(VALUE self)
1297
1193
  /**
1298
1194
  * Set the fill color
1299
1195
  *
1300
- * Ruby usage:
1301
- * - @verbatim Info#fill= @endverbatim
1302
- *
1303
- * @param self this object
1304
- * @param color the fill color (as a String)
1305
- * @return self
1306
- * @throw ArgumentError
1196
+ * @param color [String] the fill color
1197
+ * @return [String] the given value
1307
1198
  */
1308
1199
  VALUE
1309
1200
  Info_fill_eq(VALUE self, VALUE color)
@@ -1315,65 +1206,59 @@ Info_fill_eq(VALUE self, VALUE color)
1315
1206
  /**
1316
1207
  * Get the text font.
1317
1208
  *
1318
- * Ruby usage:
1319
- * - @verbatim Info#font @endverbatim
1320
- *
1321
- * @param self this object
1322
- * @return the font
1209
+ * @return [String] the font
1323
1210
  */
1324
- DEF_ATTR_READER(Info, font, str)
1211
+ VALUE
1212
+ Info_font(VALUE self)
1213
+ {
1214
+ IMPLEMENT_TYPED_ATTR_READER(Info, font, str, &rm_info_data_type);
1215
+ }
1325
1216
 
1326
1217
  /**
1327
1218
  * Set the text font.
1328
1219
  *
1329
- * Ruby usage:
1330
- * - @verbatim Info#font= @endverbatim
1331
- *
1332
- * @param self this object
1333
- * @param font_arg the font (as a String)
1334
- * @return self
1220
+ * @param font_arg [String] the font
1221
+ * @return [String] the given font
1335
1222
  */
1336
1223
  VALUE
1337
1224
  Info_font_eq(VALUE self, VALUE font_arg)
1338
1225
  {
1339
1226
  Info *info;
1340
- char *font;
1341
1227
 
1342
- Data_Get_Struct(self, Info, info);
1343
- if (NIL_P(font_arg) || StringValuePtr(font_arg) == NULL)
1228
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1229
+ if (NIL_P(font_arg) || StringValueCStr(font_arg) == NULL)
1344
1230
  {
1345
1231
  magick_free(info->font);
1346
1232
  info->font = NULL;
1347
1233
  }
1348
1234
  else
1349
1235
  {
1350
- font = StringValuePtr(font_arg);
1236
+ char *font;
1237
+
1238
+ font = StringValueCStr(font_arg);
1351
1239
  magick_clone_string(&info->font, font);
1352
1240
  }
1353
- return self;
1241
+ return font_arg;
1354
1242
  }
1355
1243
 
1356
1244
  /**
1357
1245
  * Return the image encoding format.
1358
1246
  *
1359
- * Ruby usage:
1360
- * - @verbatim Info#format @endverbatim
1361
- *
1362
- * @param self this object
1363
- * @return the encoding format
1247
+ * @return [String, nil] the encoding format
1364
1248
  */
1365
1249
  VALUE Info_format(VALUE self)
1366
1250
  {
1367
1251
  Info *info;
1368
- const MagickInfo *magick_info ;
1369
- ExceptionInfo *exception;
1370
1252
 
1371
- Data_Get_Struct(self, Info, info);
1253
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1372
1254
  if (*info->magick)
1373
1255
  {
1256
+ const MagickInfo *magick_info;
1257
+ ExceptionInfo *exception;
1258
+
1374
1259
  exception = AcquireExceptionInfo();
1375
1260
  magick_info = GetMagickInfo(info->magick, exception);
1376
- (void) DestroyExceptionInfo(exception);
1261
+ DestroyExceptionInfo(exception);
1377
1262
 
1378
1263
  return magick_info ? rb_str_new2(magick_info->name) : Qnil;
1379
1264
  }
@@ -1384,12 +1269,8 @@ VALUE Info_format(VALUE self)
1384
1269
  /**
1385
1270
  * Set the image encoding format.
1386
1271
  *
1387
- * Ruby usage:
1388
- * - @verbatim Info#format= @endverbatim
1389
- *
1390
- * @param self this object
1391
- * @param magick the encoding format
1392
- * @return self
1272
+ * @param magick [String] the encoding format
1273
+ * @return [String] the given format
1393
1274
  */
1394
1275
  VALUE
1395
1276
  Info_format_eq(VALUE self, VALUE magick)
@@ -1399,55 +1280,52 @@ Info_format_eq(VALUE self, VALUE magick)
1399
1280
  char *mgk;
1400
1281
  ExceptionInfo *exception;
1401
1282
 
1402
- Data_Get_Struct(self, Info, info);
1283
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1403
1284
 
1404
- exception = AcquireExceptionInfo();
1285
+ mgk = StringValueCStr(magick);
1405
1286
 
1406
- mgk = StringValuePtr(magick);
1287
+ exception = AcquireExceptionInfo();
1407
1288
  m = GetMagickInfo(mgk, exception);
1408
- CHECK_EXCEPTION()
1409
- (void) DestroyExceptionInfo(exception);
1289
+ CHECK_EXCEPTION();
1290
+ DestroyExceptionInfo(exception);
1410
1291
 
1411
1292
  if (!m)
1412
1293
  {
1413
1294
  rb_raise(rb_eArgError, "unknown format: %s", mgk);
1414
1295
  }
1415
1296
 
1416
- strncpy(info->magick, m->name, MaxTextExtent-1);
1417
- return self;
1297
+ strlcpy(info->magick, m->name, sizeof(info->magick));
1298
+ return magick;
1418
1299
  }
1419
1300
 
1420
1301
  /**
1421
1302
  * Get the fuzz.
1422
1303
  *
1423
- * Ruby usage:
1424
- * - @verbatim Info#fuzz @endverbatim
1425
- *
1426
- * @param self this object
1427
- * @return the fuzz
1428
- * @see Image_fuzz
1304
+ * @return [Float] the fuzz
1305
+ * @see Image#fuzz
1429
1306
  */
1430
- DEF_ATTR_READER(Info, fuzz, dbl)
1307
+ VALUE
1308
+ Info_fuzz(VALUE self)
1309
+ {
1310
+ IMPLEMENT_TYPED_ATTR_READER(Info, fuzz, dbl, &rm_info_data_type);
1311
+ }
1431
1312
 
1432
1313
  /**
1433
1314
  * Set the fuzz.
1434
1315
  *
1435
- * Ruby usage:
1436
- * - @verbatim Info#fuzz=number @endverbatim
1437
- * - @verbatim Info#fuzz=NN% @endverbatim
1438
- *
1439
- * @param self this object
1440
- * @param fuzz the fuzz
1441
- * @return self
1442
- * @see Image_fuzz_eq
1316
+ * @param fuzz [Float, String] the fuzz with Float or
1317
+ * percent format "xx%" with String
1318
+ * @return [Float, String] the given value
1319
+ * @see Image#fuzz=
1443
1320
  */
1444
- VALUE Info_fuzz_eq(VALUE self, VALUE fuzz)
1321
+ VALUE
1322
+ Info_fuzz_eq(VALUE self, VALUE fuzz)
1445
1323
  {
1446
1324
  Info *info;
1447
1325
 
1448
- Data_Get_Struct(self, Info, info);
1326
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1449
1327
  info->fuzz = rm_fuzz_to_dbl(fuzz);
1450
- return self;
1328
+ return fuzz;
1451
1329
  }
1452
1330
 
1453
1331
  /** A gravity option */
@@ -1468,8 +1346,7 @@ static struct
1468
1346
  { "SouthEast", "SouthEastGravity", SouthEastGravity},
1469
1347
  { "South", "SouthGravity", SouthGravity},
1470
1348
  { "SouthWest", "SouthWestGravity", SouthWestGravity},
1471
- { "West", "WestGravity", WestGravity},
1472
- { "Static", "StaticGravity", StaticGravity}
1349
+ { "West", "WestGravity", WestGravity}
1473
1350
  };
1474
1351
 
1475
1352
  /** Number of gravity options */
@@ -1505,28 +1382,23 @@ GravityType rm_gravity_to_enum(const char *name)
1505
1382
  /**
1506
1383
  * Return the value of the gravity option as a GravityType enumerator.
1507
1384
  *
1508
- * Ruby usage:
1509
- * - @verbatim Info#gravity @endverbatim
1510
- *
1511
- * @param self this object
1512
- * @return the gravity enumerator
1385
+ * @return [Magick::GravityType] the gravity enumerator
1513
1386
  */
1514
1387
  VALUE Info_gravity(VALUE self)
1515
1388
  {
1516
1389
  Info *info;
1517
1390
  const char *gravity;
1518
- int x;
1519
1391
  ID gravity_id;
1520
1392
 
1521
- Data_Get_Struct(self, Info, info);
1393
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1522
1394
 
1523
1395
  gravity_id = rb_intern("UndefinedGravity");
1524
1396
 
1525
1397
  // Map the gravity option string to a GravityType enumerator.
1526
- gravity=GetImageOption(info, "gravity");
1398
+ gravity = GetImageOption(info, "gravity");
1527
1399
  if (gravity)
1528
1400
  {
1529
- for (x = 0; x < N_GRAVITY_OPTIONS; x++)
1401
+ for (int x = 0; x < N_GRAVITY_OPTIONS; x++)
1530
1402
  {
1531
1403
  if (strcmp(gravity, Gravity_Option[x].string) == 0)
1532
1404
  {
@@ -1543,12 +1415,8 @@ VALUE Info_gravity(VALUE self)
1543
1415
  * Convert a GravityType enum to a gravity option name and store in the Info
1544
1416
  * structure.
1545
1417
  *
1546
- * Ruby usage:
1547
- * - @verbatim Info#gravity= @endverbatim
1548
- *
1549
- * @param self this object
1550
- * @param grav the gravity enumerator
1551
- * @return self
1418
+ * @param grav [Magick::GravityType] the gravity enumerator
1419
+ * @return [Magick::GravityType] the given gravity
1552
1420
  */
1553
1421
  VALUE
1554
1422
  Info_gravity_eq(VALUE self, VALUE grav)
@@ -1558,12 +1426,12 @@ Info_gravity_eq(VALUE self, VALUE grav)
1558
1426
  const char *option;
1559
1427
  int x;
1560
1428
 
1561
- Data_Get_Struct(self, Info, info);
1429
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1562
1430
 
1563
1431
  if (NIL_P(grav))
1564
1432
  {
1565
- (void) RemoveImageOption(info, "gravity");
1566
- return self;
1433
+ DeleteImageOption(info, "gravity");
1434
+ return grav;
1567
1435
  }
1568
1436
 
1569
1437
  VALUE_TO_ENUM(grav, gravity, GravityType);
@@ -1578,222 +1446,207 @@ Info_gravity_eq(VALUE self, VALUE grav)
1578
1446
  }
1579
1447
  }
1580
1448
 
1581
- (void) SetImageOption(info, "gravity", option);
1582
- return self;
1449
+ SetImageOption(info, "gravity", option);
1450
+ return grav;
1583
1451
  }
1584
1452
 
1585
1453
 
1586
- DEF_ATTR_ACCESSOR(Info, group, long)
1587
-
1588
1454
  /**
1589
1455
  * Get the classification type.
1590
1456
  *
1591
- * Ruby usage:
1592
- * - @verbatim Info#image_type @endverbatim
1593
- *
1594
- * @param self this object
1595
- * @return the classification type
1457
+ * @return [Magick::ImageType] the classification type
1596
1458
  */
1597
1459
  VALUE
1598
1460
  Info_image_type(VALUE self)
1599
1461
  {
1600
1462
  Info *info;
1601
1463
 
1602
- Data_Get_Struct(self, Info, info);
1603
- return ImageType_new(info->type);
1464
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1465
+ return ImageType_find(info->type);
1604
1466
  }
1605
1467
 
1606
1468
  /**
1607
1469
  * Set the classification type.
1608
1470
  *
1609
- * Ruby usage:
1610
- * - @verbatim Info#image_type= @endverbatim
1611
- *
1612
- * @param self this object
1613
- * @param type the classification type
1614
- * @return self
1615
- * @throw ArgumentError
1471
+ * @param type [Magick::ImageType] the classification type
1472
+ * @return [Magick::ImageType] the given type
1616
1473
  */
1617
1474
  VALUE
1618
1475
  Info_image_type_eq(VALUE self, VALUE type)
1619
1476
  {
1620
1477
  Info *info;
1621
1478
 
1622
- Data_Get_Struct(self, Info, info);
1479
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1623
1480
  VALUE_TO_ENUM(type, info->type, ImageType);
1624
- return self;
1481
+ return type;
1625
1482
  }
1626
1483
 
1627
1484
  /**
1628
1485
  * Get the interlace type.
1629
1486
  *
1630
- * Ruby usage:
1631
- * - @verbatim Info#interlace @endverbatim
1632
- *
1633
- * @param self this object
1634
- * @return the interlace type
1487
+ * @return [Magick::InterlaceType] the interlace type
1635
1488
  */
1636
1489
  VALUE
1637
1490
  Info_interlace(VALUE self)
1638
1491
  {
1639
1492
  Info *info;
1640
1493
 
1641
- Data_Get_Struct(self, Info, info);
1642
- return InterlaceType_new(info->interlace);
1494
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1495
+ return InterlaceType_find(info->interlace);
1643
1496
  }
1644
1497
 
1645
1498
  /**
1646
1499
  * Set the interlace type
1647
1500
  *
1648
- * Ruby usage:
1649
- * - @verbatim Info#interlace= @endverbatim
1650
- *
1651
- * @param self this object
1652
- * @param inter the interlace type
1653
- * @return self
1654
- * @throw ArgumentError
1501
+ * @param inter [Magick::InterlaceType] the interlace type
1502
+ * @return [Magick::InterlaceType] the given interlace
1655
1503
  */
1656
1504
  VALUE
1657
1505
  Info_interlace_eq(VALUE self, VALUE inter)
1658
1506
  {
1659
1507
  Info *info;
1660
1508
 
1661
- Data_Get_Struct(self, Info, info);
1509
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1662
1510
  VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
1663
- return self;
1511
+ return inter;
1664
1512
  }
1665
1513
 
1666
- OPTION_ATTR_ACCESSOR(label, Label)
1514
+ /**
1515
+ * Get the label.
1516
+ *
1517
+ * @return [String] the label
1518
+ */
1519
+ VALUE Info_label(VALUE self)
1520
+ {
1521
+ return get_option(self, "Label");
1522
+ }
1667
1523
 
1668
1524
  /**
1669
- * Return the name of the matte color as a String.
1525
+ * Set the label.
1670
1526
  *
1671
- * Ruby usage:
1672
- * - @verbatim Info#matte_color @endverbatim
1527
+ * @param string [String] the label
1528
+ * @return [String] the given label
1529
+ */
1530
+ VALUE Info_label_eq(VALUE self, VALUE string)
1531
+ {
1532
+ return set_option(self, "Label", string);
1533
+ }
1534
+
1535
+ /**
1536
+ * Return the name of the matte color as a String.
1673
1537
  *
1674
- * @param self this object
1675
- * @return the name of the matte color
1676
- * @see Image_matte_color
1538
+ * @return [String] the name of the matte color
1539
+ * @see Image#matte_color
1677
1540
  */
1678
1541
  VALUE
1679
1542
  Info_matte_color(VALUE self)
1680
1543
  {
1681
1544
  Info *info;
1682
1545
 
1683
- Data_Get_Struct(self, Info, info);
1684
- return rm_pixelpacket_to_color_name_info(info, &info->matte_color);
1546
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1547
+ return rm_pixelcolor_to_color_name_info(info, &info->matte_color);
1685
1548
  }
1686
1549
 
1687
1550
  /**
1688
1551
  * Set the matte color.
1689
1552
  *
1690
- * Ruby usage:
1691
- * - @verbatim Info#matte_color= @endverbatim
1692
- *
1693
- * @param self this object
1694
- * @param matte_arg the name of the matte as a String
1695
- * @return self
1696
- * @throw ArgumentError
1553
+ * @param matte_arg [Magick::Pixel, String] the name of the matte as a String
1554
+ * @return [Magick::Pixel, String] the given value
1697
1555
  */
1698
1556
  VALUE
1699
1557
  Info_matte_color_eq(VALUE self, VALUE matte_arg)
1700
1558
  {
1701
1559
  Info *info;
1702
- //char colorname[MaxTextExtent];
1703
1560
 
1704
- Data_Get_Struct(self, Info, info);
1705
- Color_to_PixelPacket(&info->matte_color, matte_arg);
1706
- //SetImageOption(info, "mattecolor", pixel_packet_to_hexname(&info->matte_color, colorname));
1707
- return self;
1561
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1562
+ Color_to_PixelColor(&info->matte_color, matte_arg);
1563
+
1564
+ return matte_arg;
1708
1565
  }
1709
1566
 
1710
1567
  /**
1711
- * Establish a progress monitor.
1568
+ * Get the monochrome value.
1712
1569
  *
1713
- * Ruby usage:
1714
- * - @verbatim Info#monitor= @endverbatim
1715
- *
1716
- * @param self this object
1717
- * @param monitor the monitor
1718
- * @return self
1719
- * @see Image_monitor_eq
1570
+ * @return [Boolean] true or false
1720
1571
  */
1721
1572
  VALUE
1722
- Info_monitor_eq(VALUE self, VALUE monitor)
1573
+ Info_monochrome(VALUE self)
1723
1574
  {
1724
- Info *info;
1725
-
1726
- Data_Get_Struct(self, Info, info);
1727
-
1728
- if (NIL_P(monitor))
1729
- {
1730
- info->progress_monitor = NULL;
1731
- }
1732
- else
1733
- {
1734
- (void) SetImageInfoProgressMonitor(info, rm_progress_monitor, (void *)monitor);
1735
- }
1736
-
1737
-
1738
- return self;
1575
+ IMPLEMENT_TYPED_ATTR_READER(Info, monochrome, boolean, &rm_info_data_type);
1739
1576
  }
1740
1577
 
1578
+ /**
1579
+ * Set the monochrome value.
1580
+ *
1581
+ * @param val [Boolean] true or false
1582
+ * @return [Boolean] the given value
1583
+ */
1584
+ VALUE
1585
+ Info_monochrome_eq(VALUE self, VALUE val)
1586
+ {
1587
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, monochrome, boolean, &rm_info_data_type);
1588
+ }
1741
1589
 
1590
+ /**
1591
+ * Get the scene number of an image or the first image in a sequence.
1592
+ *
1593
+ * @return [Numeric] the scene number
1594
+ */
1595
+ VALUE
1596
+ Info_number_scenes(VALUE self)
1597
+ {
1598
+ IMPLEMENT_TYPED_ATTR_READER(Info, number_scenes, ulong, &rm_info_data_type);
1599
+ }
1742
1600
 
1743
-
1744
- DEF_ATTR_ACCESSOR(Info, monochrome, bool)
1745
-
1746
- DEF_ATTR_ACCESSOR(Info, number_scenes, ulong)
1601
+ /**
1602
+ * Set the scene number of an image or the first image in a sequence.
1603
+ *
1604
+ * @param val [Numeric] the scene number
1605
+ * @return [Numeric] the given value
1606
+ */
1607
+ VALUE
1608
+ Info_number_scenes_eq(VALUE self, VALUE val)
1609
+ {
1610
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, number_scenes, ulong, &rm_info_data_type);
1611
+ }
1747
1612
 
1748
1613
  /**
1749
1614
  * Return the orientation attribute as an OrientationType enum value.
1750
1615
  *
1751
- * Ruby usage:
1752
- * - @verbatim Info#orientation @endverbatim
1753
- *
1754
- * @param self this object
1755
- * @return the orientation
1616
+ * @return [Magick::OrientationType] the orientation
1756
1617
  */
1757
1618
  VALUE
1758
1619
  Info_orientation(VALUE self)
1759
1620
  {
1760
1621
  Info *info;
1761
1622
 
1762
- Data_Get_Struct(self, Info, info);
1763
- return OrientationType_new(info->orientation);
1623
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1624
+ return OrientationType_find(info->orientation);
1764
1625
  }
1765
1626
 
1766
1627
 
1767
1628
  /**
1768
1629
  * Set the Orientation type.
1769
1630
  *
1770
- * Ruby usage:
1771
- * - @verbatim Info#Orientation= @endverbatim
1772
- *
1773
- * @param self this object
1774
- * @param inter the orientation type as an OrientationType enum value
1775
- * @return self
1776
- * @throw ArgumentError
1631
+ * @param inter [Magick::OrientationType] the orientation type as an OrientationType enum value
1632
+ * @return [Magick::OrientationType] the given value
1777
1633
  */
1778
1634
  VALUE
1779
1635
  Info_orientation_eq(VALUE self, VALUE inter)
1780
1636
  {
1781
1637
  Info *info;
1782
1638
 
1783
- Data_Get_Struct(self, Info, info);
1639
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1784
1640
  VALUE_TO_ENUM(inter, info->orientation, OrientationType);
1785
- return self;
1641
+ return inter;
1786
1642
  }
1787
1643
 
1788
1644
 
1789
1645
  /**
1790
1646
  * Return origin geometry.
1791
1647
  *
1792
- * Ruby usage:
1793
- * - @verbatim Info#origin @endverbatim
1794
- *
1795
- * @param self this object
1796
- * @return the origin geometry
1648
+ * @return [String] the origin geometry
1649
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
1797
1650
  */
1798
1651
  VALUE
1799
1652
  Info_origin(VALUE self)
@@ -1801,7 +1654,7 @@ Info_origin(VALUE self)
1801
1654
  Info *info;
1802
1655
  const char *origin;
1803
1656
 
1804
- Data_Get_Struct(self, Info, info);
1657
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1805
1658
 
1806
1659
  origin = GetImageOption(info, "origin");
1807
1660
  return origin ? rb_str_new2(origin) : Qnil;
@@ -1812,12 +1665,12 @@ Info_origin(VALUE self)
1812
1665
  * Set origin geometry. Argument may be a Geometry object as well as a geometry
1813
1666
  * string.
1814
1667
  *
1815
- * Ruby usage:
1816
- * - @verbatim Info#origin=+-x+-y @endverbatim
1668
+ * The geometry format is
1669
+ * +-x+-y
1817
1670
  *
1818
- * @param self this object
1819
- * @param origin_arg the origin geometry
1820
- * @return self
1671
+ * @param origin_arg [Magick::Geometry, String] the origin geometry
1672
+ * @return [Magick::Geometry, String] the given value
1673
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
1821
1674
  */
1822
1675
  VALUE
1823
1676
  Info_origin_eq(VALUE self, VALUE origin_arg)
@@ -1826,45 +1679,43 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1826
1679
  VALUE origin_str;
1827
1680
  char *origin;
1828
1681
 
1829
- Data_Get_Struct(self, Info, info);
1682
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1830
1683
 
1831
1684
  if (NIL_P(origin_arg))
1832
1685
  {
1833
- (void) RemoveImageOption(info, "origin");
1834
- return self;
1686
+ DeleteImageOption(info, "origin");
1687
+ return origin_arg;
1835
1688
  }
1836
1689
 
1837
- origin_str = rm_to_s(origin_arg);
1838
- origin = GetPageGeometry(StringValuePtr(origin_str));
1690
+ origin_str = rb_String(origin_arg);
1691
+ origin = GetPageGeometry(StringValueCStr(origin_str));
1839
1692
 
1840
1693
  if (IsGeometry(origin) == MagickFalse)
1841
1694
  {
1842
- rb_raise(rb_eArgError, "invalid origin geometry: %s", origin);
1695
+ magick_free(origin);
1696
+ rb_raise(rb_eArgError, "invalid origin geometry");
1843
1697
  }
1844
1698
 
1845
- (void) SetImageOption(info, "origin", origin);
1699
+ SetImageOption(info, "origin", origin);
1700
+ magick_free(origin);
1846
1701
 
1847
1702
  RB_GC_GUARD(origin_str);
1848
1703
 
1849
- return self;
1704
+ return origin_arg;
1850
1705
  }
1851
1706
 
1852
1707
 
1853
1708
  /**
1854
1709
  * Get the Postscript page geometry.
1855
1710
  *
1856
- * Ruby usage:
1857
- * - @verbatim Info_page @endverbatim
1858
- *
1859
- * @param self this object
1860
- * @return the page geometry
1711
+ * @return [String] the page geometry
1861
1712
  */
1862
1713
  VALUE
1863
1714
  Info_page(VALUE self)
1864
1715
  {
1865
1716
  Info *info;
1866
1717
 
1867
- Data_Get_Struct(self, Info, info);
1718
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1868
1719
  return info->page ? rb_str_new2(info->page) : Qnil;
1869
1720
 
1870
1721
  }
@@ -1873,12 +1724,9 @@ Info_page(VALUE self)
1873
1724
  * Store the Postscript page geometry. Argument may be a Geometry object as well
1874
1725
  * as a geometry string.
1875
1726
  *
1876
- * Ruby usage:
1877
- * - @verbatim Info#page= @endverbatim
1878
- *
1879
- * @param self this object
1880
- * @param page_arg the geometry
1881
- * @return self
1727
+ * @param page_arg [Magick::Geometry, String] the geometry
1728
+ * @return [Magick::Geometry, String] the given value
1729
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
1882
1730
  */
1883
1731
  VALUE
1884
1732
  Info_page_eq(VALUE self, VALUE page_arg)
@@ -1887,46 +1735,85 @@ Info_page_eq(VALUE self, VALUE page_arg)
1887
1735
  VALUE geom_str;
1888
1736
  char *geometry;
1889
1737
 
1890
- Data_Get_Struct(self, Info, info);
1738
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1891
1739
  if (NIL_P(page_arg))
1892
1740
  {
1893
1741
  magick_free(info->page);
1894
1742
  info->page = NULL;
1895
- return self;
1743
+ return page_arg;
1896
1744
  }
1897
- geom_str = rm_to_s(page_arg);
1898
- geometry=GetPageGeometry(StringValuePtr(geom_str));
1745
+ geom_str = rb_String(page_arg);
1746
+ geometry = GetPageGeometry(StringValueCStr(geom_str));
1899
1747
  if (*geometry == '\0')
1900
1748
  {
1901
1749
  magick_free(info->page);
1902
1750
  info->page = NULL;
1903
- return self;
1751
+ return page_arg;
1904
1752
  }
1905
- magick_clone_string(&info->page, geometry);
1753
+ info->page = geometry;
1906
1754
 
1907
1755
  RB_GC_GUARD(geom_str);
1908
1756
 
1909
- return self;
1757
+ return page_arg;
1910
1758
  }
1911
1759
 
1912
- DEF_ATTR_ACCESSOR(Info, pointsize, dbl)
1913
- DEF_ATTR_ACCESSOR(Info, quality, ulong)
1760
+ /**
1761
+ * Get the point size.
1762
+ *
1763
+ * @return [Float] the point size
1764
+ */
1765
+ VALUE
1766
+ Info_pointsize(VALUE self)
1767
+ {
1768
+ IMPLEMENT_TYPED_ATTR_READER(Info, pointsize, dbl, &rm_info_data_type);
1769
+ }
1914
1770
 
1915
1771
  /**
1916
- * Get sampling factors used by JPEG or MPEG-2 encoder and YUV decoder/encoder.
1772
+ * Set the point size.
1917
1773
  *
1918
- * Ruby usage:
1919
- * - @verbatim Info#sampling_factor @endverbatim
1774
+ * @param val [Float] the point size
1775
+ * @return [Float] the given value
1776
+ */
1777
+ VALUE
1778
+ Info_pointsize_eq(VALUE self, VALUE val)
1779
+ {
1780
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, pointsize, dbl, &rm_info_data_type);
1781
+ }
1782
+
1783
+ /**
1784
+ * Get the compression level for JPEG, etc.
1920
1785
  *
1921
- * @param self this object
1922
- * @return the sampling factors
1786
+ * @return [Numeric] the compression level
1787
+ */
1788
+ VALUE
1789
+ Info_quality(VALUE self)
1790
+ {
1791
+ IMPLEMENT_TYPED_ATTR_READER(Info, quality, ulong, &rm_info_data_type);
1792
+ }
1793
+
1794
+ /**
1795
+ * Get the compression level for JPEG, etc.
1796
+ *
1797
+ * @param val [Numeric] the compression level
1798
+ * @return [Numeric] the given value
1799
+ */
1800
+ VALUE
1801
+ Info_quality_eq(VALUE self, VALUE val)
1802
+ {
1803
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, quality, ulong, &rm_info_data_type);
1804
+ }
1805
+
1806
+ /**
1807
+ * Get sampling factors used by JPEG or MPEG-2 encoder and YUV decoder/encoder.
1808
+ *
1809
+ * @return [String, nil] the sampling factors
1923
1810
  */
1924
1811
  VALUE
1925
1812
  Info_sampling_factor(VALUE self)
1926
1813
  {
1927
1814
  Info *info;
1928
1815
 
1929
- Data_Get_Struct(self, Info, info);
1816
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1930
1817
  if (info->sampling_factor)
1931
1818
  {
1932
1819
  return rb_str_new2(info->sampling_factor);
@@ -1940,21 +1827,17 @@ Info_sampling_factor(VALUE self)
1940
1827
  /**
1941
1828
  * Set sampling factors used by JPEG or MPEG-2 encoder and YUV decoder/encoder.
1942
1829
  *
1943
- * Ruby usage:
1944
- * - @verbatim Info#sampling_factor= @endverbatim
1945
- *
1946
- * @param self this object
1947
- * @param sampling_factor the sampling factors
1948
- * @return self
1830
+ * @param sampling_factor [String] the sampling factors
1831
+ * @return [String] the given value
1949
1832
  */
1950
1833
  VALUE
1951
1834
  Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1952
1835
  {
1953
1836
  Info *info;
1954
1837
  char *sampling_factor_p = NULL;
1955
- long sampling_factor_len = 0;
1838
+ size_t sampling_factor_len = 0;
1956
1839
 
1957
- Data_Get_Struct(self, Info, info);
1840
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1958
1841
 
1959
1842
  if (!NIL_P(sampling_factor))
1960
1843
  {
@@ -1971,25 +1854,21 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1971
1854
  magick_clone_string(&info->sampling_factor, sampling_factor_p);
1972
1855
  }
1973
1856
 
1974
- return self;
1857
+ return sampling_factor;
1975
1858
  }
1976
1859
 
1977
1860
 
1978
1861
  /**
1979
1862
  * Get the scene number.
1980
1863
  *
1981
- * Ruby usage:
1982
- * - @verbatim Info#scene @endverbatim
1983
- *
1984
- * @param self this object
1985
- * @return the scene number
1864
+ * @return [Numeric] the scene number
1986
1865
  */
1987
1866
  VALUE
1988
1867
  Info_scene(VALUE self)
1989
1868
  {
1990
1869
  Info *info;
1991
1870
 
1992
- Data_Get_Struct(self, Info, info);
1871
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1993
1872
  return ULONG2NUM(info->scene);
1994
1873
  }
1995
1874
 
@@ -1997,12 +1876,8 @@ Info_scene(VALUE self)
1997
1876
  /**
1998
1877
  * Set the scene number.
1999
1878
  *
2000
- * Ruby usage:
2001
- * - @verbatim Info#scene= @endverbatim
2002
- *
2003
- * @param self this object
2004
- * @param scene the scene number
2005
- * @return self
1879
+ * @param scene [Numeric] the scene number
1880
+ * @return [Numeric] the given value
2006
1881
  */
2007
1882
  VALUE
2008
1883
  Info_scene_eq(VALUE self, VALUE scene)
@@ -2010,84 +1885,73 @@ Info_scene_eq(VALUE self, VALUE scene)
2010
1885
  Info *info;
2011
1886
  char buf[25];
2012
1887
 
2013
- Data_Get_Struct(self, Info, info);
1888
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2014
1889
  info->scene = NUM2ULONG(scene);
2015
1890
 
2016
- #if defined(HAVE_SNPRINTF)
2017
- (void) snprintf(buf, sizeof(buf), "%-ld", info->scene);
2018
- #else
2019
- (void) sprintf(buf, "%-l", info->scene);
2020
- #endif
2021
- (void) SetImageOption(info, "scene", buf);
1891
+ snprintf(buf, sizeof(buf), "%" RMIuSIZE "", info->scene);
1892
+ SetImageOption(info, "scene", buf);
2022
1893
 
2023
- return self;
1894
+ return scene;
2024
1895
  }
2025
1896
 
2026
1897
 
2027
1898
  /**
2028
1899
  * Get the server name.
2029
1900
  *
2030
- * Ruby usage:
2031
- * - @verbatim Info#server_name @endverbatim
2032
- *
2033
- * @param self this object
2034
- * @return the server name
1901
+ * @return [String] the server name
2035
1902
  */
2036
- DEF_ATTR_READER(Info, server_name, str)
1903
+ VALUE
1904
+ Info_server_name(VALUE self)
1905
+ {
1906
+ IMPLEMENT_TYPED_ATTR_READER(Info, server_name, str, &rm_info_data_type);
1907
+ }
2037
1908
 
2038
1909
 
2039
1910
  /**
2040
1911
  * Set the server name.
2041
1912
  *
2042
- * Ruby usage:
2043
- * - @verbatim Info#server_name= @endverbatim
2044
- *
2045
- * @param self this object
2046
- * @param server_arg the server name as a String
2047
- * @return self
1913
+ * @param server_arg [String] the server name
1914
+ * @return [String] the given value
2048
1915
  */
2049
1916
  VALUE
2050
1917
  Info_server_name_eq(VALUE self, VALUE server_arg)
2051
1918
  {
2052
1919
  Info *info;
2053
- char *server;
2054
1920
 
2055
- Data_Get_Struct(self, Info, info);
2056
- if (NIL_P(server_arg) || StringValuePtr(server_arg) == NULL)
1921
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1922
+ if (NIL_P(server_arg) || StringValueCStr(server_arg) == NULL)
2057
1923
  {
2058
1924
  magick_free(info->server_name);
2059
1925
  info->server_name = NULL;
2060
1926
  }
2061
1927
  else
2062
1928
  {
2063
- server = StringValuePtr(server_arg);
1929
+ char *server;
1930
+
1931
+ server = StringValueCStr(server_arg);
2064
1932
  magick_clone_string(&info->server_name, server);
2065
1933
  }
2066
- return self;
1934
+ return server_arg;
2067
1935
  }
2068
1936
 
2069
1937
  /**
2070
1938
  * Get ths size
2071
1939
  *
2072
- * Ruby usage:
2073
- * - @verbatim Info#size @endverbatim
2074
- *
2075
- * @param self this object
2076
- * @return the size as a Geometry object
1940
+ * @return [String] the size as a Geometry object
1941
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
2077
1942
  */
2078
- DEF_ATTR_READER(Info, size, str)
1943
+ VALUE
1944
+ Info_size(VALUE self)
1945
+ {
1946
+ IMPLEMENT_TYPED_ATTR_READER(Info, size, str, &rm_info_data_type);
1947
+ }
2079
1948
 
2080
1949
  /**
2081
- * Set the size (either as a Geometry object or a Geometry string, i.e.
2082
- * WxH{+-}x{+-}y)
2083
- *
2084
- * Ruby usage:
2085
- * - @verbatim Info#size= @endverbatim
1950
+ * Set the size (either as a Geometry object or a Geometry string
2086
1951
  *
2087
- * @param self this object
2088
- * @param size_arg the size
2089
- * @return self
2090
- * @throw ArgumentError
1952
+ * @param size_arg [Magick::Geometry, String] the size
1953
+ * @return [Magick::Geometry, String] the given value
1954
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
2091
1955
  */
2092
1956
  VALUE
2093
1957
  Info_size_eq(VALUE self, VALUE size_arg)
@@ -2096,17 +1960,17 @@ Info_size_eq(VALUE self, VALUE size_arg)
2096
1960
  VALUE size;
2097
1961
  char *sz;
2098
1962
 
2099
- Data_Get_Struct(self, Info, info);
1963
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2100
1964
 
2101
1965
  if (NIL_P(size_arg))
2102
1966
  {
2103
1967
  magick_free(info->size);
2104
1968
  info->size = NULL;
2105
- return self;
1969
+ return size_arg;
2106
1970
  }
2107
1971
 
2108
- size = rm_to_s(size_arg);
2109
- sz = StringValuePtr(size);
1972
+ size = rb_String(size_arg);
1973
+ sz = StringValueCStr(size);
2110
1974
  if (!IsGeometry(sz))
2111
1975
  {
2112
1976
  rb_raise(rb_eArgError, "invalid size geometry: %s", sz);
@@ -2116,18 +1980,14 @@ Info_size_eq(VALUE self, VALUE size_arg)
2116
1980
 
2117
1981
  RB_GC_GUARD(size);
2118
1982
 
2119
- return self;
1983
+ return size_arg;
2120
1984
  }
2121
1985
 
2122
1986
 
2123
1987
  /**
2124
1988
  * Return the stroke color as a String.
2125
1989
  *
2126
- * Ruby usage:
2127
- * - @verbatim Info#stroke @endverbatim
2128
- *
2129
- * @param self this object
2130
- * @return the stroke color
1990
+ * @return [String] the stroke color
2131
1991
  */
2132
1992
  VALUE
2133
1993
  Info_stroke(VALUE self)
@@ -2138,13 +1998,8 @@ Info_stroke(VALUE self)
2138
1998
  /**
2139
1999
  * Set the stroke color
2140
2000
  *
2141
- * Ruby usage:
2142
- * - @verbatim Info#stroke= @endverbatim
2143
- *
2144
- * @param self this object
2145
- * @param color the stroke color as a String
2146
- * @return self
2147
- * @throw ArgumentError
2001
+ * @param color [String] the stroke color
2002
+ * @return [String] the given value
2148
2003
  */
2149
2004
  VALUE
2150
2005
  Info_stroke_eq(VALUE self, VALUE color)
@@ -2154,16 +2009,9 @@ Info_stroke_eq(VALUE self, VALUE color)
2154
2009
 
2155
2010
 
2156
2011
  /**
2157
- * Support for caption: format.
2158
- *
2159
- * Ruby usage:
2160
- * - @verbatim Info#stroke_width @endverbatim
2161
- *
2162
- * Notes:
2163
- * - Supported in ImageMagick >= 6.3.2-6
2012
+ * Get stroke width.
2164
2013
  *
2165
- * @param self this object
2166
- * @return the stroke width
2014
+ * @return [Float] the stroke width
2167
2015
  */
2168
2016
  VALUE
2169
2017
  Info_stroke_width(VALUE self)
@@ -2173,17 +2021,10 @@ Info_stroke_width(VALUE self)
2173
2021
 
2174
2022
 
2175
2023
  /**
2176
- * Support for caption: format.
2024
+ * Set stroke width.
2177
2025
  *
2178
- * Ruby usage:
2179
- * - @verbatim Info#stroke_width= @endverbatim
2180
- *
2181
- * Notes:
2182
- * - Supported in ImageMagick >= 6.3.2-6
2183
- *
2184
- * @param self this object
2185
- * @param stroke_width the stroke width
2186
- * @return self
2026
+ * @param stroke_width [Float] the stroke width
2027
+ * @return [Float] the given value
2187
2028
  */
2188
2029
  VALUE
2189
2030
  Info_stroke_width_eq(VALUE self, VALUE stroke_width)
@@ -2195,12 +2036,8 @@ Info_stroke_width_eq(VALUE self, VALUE stroke_width)
2195
2036
  /**
2196
2037
  * Set name of texture to tile onto the image background.
2197
2038
  *
2198
- * Ruby usage:
2199
- * - @verbatim Image::Info#texture= @endverbatim
2200
- *
2201
- * @param self this object
2202
- * @param texture the name of the texture image
2203
- * @return self
2039
+ * @param texture [Magick::Image] the texture image
2040
+ * @return [Magick::Image] the given image
2204
2041
  */
2205
2042
  VALUE
2206
2043
  Info_texture_eq(VALUE self, VALUE texture)
@@ -2209,7 +2046,7 @@ Info_texture_eq(VALUE self, VALUE texture)
2209
2046
  Image *image;
2210
2047
  char name[MaxTextExtent];
2211
2048
 
2212
- Data_Get_Struct(self, Info, info);
2049
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2213
2050
 
2214
2051
  // Delete any existing texture file
2215
2052
  if (info->texture)
@@ -2222,28 +2059,50 @@ Info_texture_eq(VALUE self, VALUE texture)
2222
2059
  // If argument is nil we're done
2223
2060
  if (texture == Qnil)
2224
2061
  {
2225
- return self;
2062
+ return texture;
2226
2063
  }
2227
2064
 
2228
2065
  // Create a temp copy of the texture and store its name in the texture field
2229
2066
  image = rm_check_destroyed(texture);
2230
- rm_write_temp_image(image, name);
2067
+ rm_write_temp_image(image, name, sizeof(name));
2231
2068
 
2232
2069
  magick_clone_string(&info->texture, name);
2233
2070
 
2234
- return self;
2071
+ return texture;
2235
2072
  }
2236
2073
 
2237
2074
 
2238
2075
  /**
2239
- * info.tile_offset = [+/-]x[+/-]y.
2076
+ * Return tile_offset geometry.
2240
2077
  *
2241
- * Ruby usage:
2242
- * - @verbatim Image::Info#tile_offset= @endverbatim
2078
+ * @return [String, nil] the tile offset
2079
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
2080
+ */
2081
+ VALUE
2082
+ Info_tile_offset(VALUE self)
2083
+ {
2084
+ Info *info;
2085
+ const char *tile_offset;
2086
+
2087
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2088
+
2089
+ tile_offset = GetImageOption(info, "tile-offset");
2090
+
2091
+ if (!tile_offset)
2092
+ {
2093
+ return Qnil;
2094
+ }
2095
+
2096
+ return rb_str_new2(tile_offset);
2097
+ }
2098
+
2099
+
2100
+ /**
2101
+ * Set tile offset geometry.
2243
2102
  *
2244
- * @param self this object
2245
- * @param offset the offset
2246
- * @return self
2103
+ * @param offset [Magick::Geometry, String] the offset geometry
2104
+ * @return [Magick::Geometry, String] the given value
2105
+ * @see https://www.imagemagick.org/Magick++/Geometry.html
2247
2106
  */
2248
2107
  VALUE
2249
2108
  Info_tile_offset_eq(VALUE self, VALUE offset)
@@ -2252,113 +2111,71 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
2252
2111
  VALUE offset_str;
2253
2112
  char *tile_offset;
2254
2113
 
2255
- offset_str = rm_to_s(offset);
2256
- tile_offset = StringValuePtr(offset_str);
2114
+ offset_str = rb_String(offset);
2115
+ tile_offset = StringValueCStr(offset_str);
2257
2116
  if (!IsGeometry(tile_offset))
2258
2117
  {
2259
2118
  rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset);
2260
2119
  }
2261
2120
 
2262
- Data_Get_Struct(self, Info, info);
2121
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2263
2122
 
2264
- (void) DeleteImageOption(info, "tile-offset");
2265
- (void) SetImageOption(info, "tile-offset", tile_offset);
2123
+ DeleteImageOption(info, "tile-offset");
2124
+ SetImageOption(info, "tile-offset", tile_offset);
2266
2125
 
2267
2126
  RB_GC_GUARD(offset_str);
2268
2127
 
2269
- return self;
2128
+ return offset;
2270
2129
  }
2271
2130
 
2272
2131
 
2273
2132
  /**
2274
- * Return the name of the transparent color as a String.
2275
- *
2276
- * Ruby usage:
2277
- * - @verbatim Info#transparent_color @endverbatim
2133
+ * Return the name of the transparent color.
2278
2134
  *
2279
- * @param self this object
2280
- * @return the name of the transparent color
2281
- * @see Image_transparent_color
2135
+ * @return [String] the name of the transparent color
2136
+ * @see Image#transparent_color
2282
2137
  */
2283
2138
  VALUE
2284
2139
  Info_transparent_color(VALUE self)
2285
2140
  {
2286
2141
  Info *info;
2287
2142
 
2288
- Data_Get_Struct(self, Info, info);
2289
- return rm_pixelpacket_to_color_name_info(info, &info->transparent_color);
2143
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2144
+ return rm_pixelcolor_to_color_name_info(info, &info->transparent_color);
2290
2145
  }
2291
2146
 
2292
2147
 
2293
2148
  /**
2294
2149
  * Set the transparent color.
2295
2150
  *
2296
- * Ruby usage:
2297
- * - @verbatim Info#transparent_color= @endverbatim
2298
- *
2299
- * @param self this object
2300
- * @param tc_arg the transparent color as a String
2301
- * @return self
2302
- * @throw ArgumentError
2151
+ * @param tc_arg [String] the transparent color
2152
+ * @return [Magick::Pixel, String] the given value
2303
2153
  */
2304
2154
  VALUE
2305
2155
  Info_transparent_color_eq(VALUE self, VALUE tc_arg)
2306
2156
  {
2307
2157
  Info *info;
2308
- //char colorname[MaxTextExtent];
2309
-
2310
- Data_Get_Struct(self, Info, info);
2311
- Color_to_PixelPacket(&info->transparent_color, tc_arg);
2312
- //SetImageOption(info, "transparent", pixel_packet_to_hexname(&info->transparent_color, colorname));
2313
- return self;
2314
- }
2315
-
2316
-
2317
- /**
2318
- * Return tile_offset attribute values.
2319
- *
2320
- * Ruby usage:
2321
- * - @verbatim Image::Info#tile_offset @endverbatim
2322
- *
2323
- * @param self this object
2324
- * @return the tile offset
2325
- */
2326
- VALUE
2327
- Info_tile_offset(VALUE self)
2328
- {
2329
- Info *info;
2330
- const char *tile_offset;
2331
2158
 
2332
- Data_Get_Struct(self, Info, info);
2159
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2160
+ Color_to_PixelColor(&info->transparent_color, tc_arg);
2333
2161
 
2334
- tile_offset = GetImageOption(info, "tile-offset");
2335
-
2336
- if (!tile_offset)
2337
- {
2338
- return Qnil;
2339
- }
2340
-
2341
- return rb_str_new2(tile_offset);
2162
+ return tc_arg;
2342
2163
  }
2343
2164
 
2344
2165
 
2345
2166
  /**
2346
2167
  * Undefine image option.
2347
2168
  *
2348
- * Ruby usage:
2349
- * - @verbatim Info#undefine(format,key) @endverbatim
2350
- *
2351
- * @param self this object
2352
- * @param format the format
2353
- * @param key the key
2354
- * @return self
2169
+ * @param format [String] the format
2170
+ * @param key [String] the key
2171
+ * @return [Magick::Info] self
2355
2172
  */
2356
2173
  VALUE
2357
2174
  Info_undefine(VALUE self, VALUE format, VALUE key)
2358
2175
  {
2359
2176
  Info *info;
2360
2177
  char *format_p, *key_p;
2361
- long format_l, key_l;
2178
+ size_t format_l, key_l;
2362
2179
  char fkey[MaxTextExtent];
2363
2180
 
2364
2181
  format_p = rm_str2cstr(format, &format_l);
@@ -2369,25 +2186,19 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
2369
2186
  rb_raise(rb_eArgError, "can't undefine %.60s:%.1024s - too long", format_p, key_p);
2370
2187
  }
2371
2188
 
2372
- sprintf(fkey, "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
2189
+ snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
2373
2190
 
2374
- Data_Get_Struct(self, Info, info);
2375
- /* Depending on the IM version, RemoveImageOption returns either */
2376
- /* char * or MagickBooleanType. Ignore the return value. */
2377
- (void) RemoveImageOption(info, fkey);
2191
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2192
+ DeleteImageOption(info, fkey);
2378
2193
 
2379
2194
  return self;
2380
2195
  }
2381
2196
 
2382
2197
 
2383
2198
  /**
2384
- * Return the undercolor color as a String.
2385
- *
2386
- * Ruby usage:
2387
- * - @verbatim Info#undercolor @endverbatim
2199
+ * Return the undercolor color.
2388
2200
  *
2389
- * @param self this object
2390
- * @return the undercolor
2201
+ * @return [String] the undercolor
2391
2202
  */
2392
2203
  VALUE
2393
2204
  Info_undercolor(VALUE self)
@@ -2398,13 +2209,8 @@ Info_undercolor(VALUE self)
2398
2209
  /**
2399
2210
  * Set the undercolor color.
2400
2211
  *
2401
- * Ruby usage:
2402
- * - @verbatim Info#undercolor= @endverbatim
2403
- *
2404
- * @param self this object
2405
- * @param color the undercolor color as a String
2406
- * @return self
2407
- * @throw ArgumentError
2212
+ * @param color [String] the undercolor color
2213
+ * @return [String] the given value
2408
2214
  */
2409
2215
  VALUE
2410
2216
  Info_undercolor_eq(VALUE self, VALUE color)
@@ -2415,87 +2221,96 @@ Info_undercolor_eq(VALUE self, VALUE color)
2415
2221
  /**
2416
2222
  * Get the resolution type.
2417
2223
  *
2418
- * Ruby usage:
2419
- * - @verbatim Info#units @endverbatim
2420
- *
2421
- * @param self this object
2422
- * @return the resolution type
2224
+ * @return [Magick::ResolutionType] the resolution type
2423
2225
  */
2424
2226
  VALUE
2425
2227
  Info_units(VALUE self)
2426
2228
  {
2427
2229
  Info *info;
2428
2230
 
2429
- Data_Get_Struct(self, Info, info);
2430
- return ResolutionType_new(info->units);
2231
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2232
+ return ResolutionType_find(info->units);
2431
2233
  }
2432
2234
 
2433
2235
  /**
2434
2236
  * Set the resolution type
2435
2237
  *
2436
- * Ruby usage:
2437
- * - @verbatim Info#units= @endverbatim
2438
- *
2439
- * @param self this object
2440
- * @param units the resolution type
2441
- * @return self
2442
- * @throw ArgumentError
2238
+ * @param units [Magick::ResolutionType] the resolution type
2239
+ * @return [Magick::ResolutionType] the given value
2443
2240
  */
2444
2241
  VALUE
2445
2242
  Info_units_eq(VALUE self, VALUE units)
2446
2243
  {
2447
2244
  Info *info;
2448
2245
 
2449
- Data_Get_Struct(self, Info, info);
2246
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2450
2247
  VALUE_TO_ENUM(units, info->units, ResolutionType);
2451
- return self;
2248
+ return units;
2452
2249
  }
2453
2250
 
2454
2251
  /**
2455
2252
  * Get FlashPix viewing parameters.
2456
2253
  *
2457
- * Ruby usage:
2458
- * - @verbatim Info#view @endverbatim
2459
- *
2460
- * @param self this object.
2461
- * @return the viewing parameters
2254
+ * @return [String] the viewing parameters
2462
2255
  */
2463
- DEF_ATTR_READER(Info, view, str)
2256
+ VALUE
2257
+ Info_view(VALUE self)
2258
+ {
2259
+ Info *info;
2260
+
2261
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2262
+ #if defined(IMAGEMAGICK_7)
2263
+ return C_str_to_R_str(GetImageOption(info, "fpx:view"));
2264
+ #else
2265
+ return C_str_to_R_str(info->view);
2266
+ #endif
2267
+ }
2464
2268
 
2465
2269
  /**
2466
2270
  * Set FlashPix viewing parameters.
2467
2271
  *
2468
- * Ruby usage:
2469
- * - @verbatim Info#view= @endverbatim
2470
- *
2471
- * @param self this object
2472
- * @param view_arg the viewing parameters
2473
- * @return self
2272
+ * @param view_arg [String] the viewing parameters
2273
+ * @return [String] the given value
2474
2274
  */
2475
2275
  VALUE
2476
2276
  Info_view_eq(VALUE self, VALUE view_arg)
2477
2277
  {
2478
2278
  Info *info;
2479
- char *view;
2279
+ char *view = NULL;
2480
2280
 
2481
- Data_Get_Struct(self, Info, info);
2281
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2482
2282
 
2483
- if (NIL_P(view_arg) || StringValuePtr(view_arg) == NULL)
2283
+ if (!NIL_P(view_arg))
2284
+ {
2285
+ view = StringValueCStr(view_arg);
2286
+ }
2287
+
2288
+ #if defined(IMAGEMAGICK_7)
2289
+ if (view)
2290
+ {
2291
+ SetImageOption(info, "fpx:view", view);
2292
+ }
2293
+ else
2294
+ {
2295
+ RemoveImageOption(info, "fpx:view");
2296
+ }
2297
+ #else
2298
+ if (info->view)
2484
2299
  {
2485
2300
  magick_free(info->view);
2486
2301
  info->view = NULL;
2487
2302
  }
2488
- else
2303
+ if (view)
2489
2304
  {
2490
- view = StringValuePtr(view_arg);
2491
2305
  magick_clone_string(&info->view, view);
2492
2306
  }
2493
- return self;
2307
+ #endif
2308
+ return view_arg;
2494
2309
  }
2495
2310
 
2496
2311
 
2497
2312
  /**
2498
- * If there is a texture image, delete it before destroying the ImageInfo
2313
+ * If there is a texture image, delete it before destroying the Image::Info
2499
2314
  * structure.
2500
2315
  *
2501
2316
  * No Ruby usage (internal function)
@@ -2503,7 +2318,7 @@ Info_view_eq(VALUE self, VALUE view_arg)
2503
2318
  * @param infoptr pointer to the Info object
2504
2319
  */
2505
2320
  static void
2506
- destroy_Info(void *infoptr)
2321
+ Info_free(void *infoptr)
2507
2322
  {
2508
2323
  Info *info = (Info *)infoptr;
2509
2324
 
@@ -2514,20 +2329,32 @@ destroy_Info(void *infoptr)
2514
2329
  info->texture = NULL;
2515
2330
  }
2516
2331
 
2517
- (void) DestroyImageInfo(info);
2332
+ DestroyImageInfo(info);
2518
2333
  }
2519
2334
 
2335
+ /**
2336
+ * Get Info object size.
2337
+ *
2338
+ * No Ruby usage (internal function)
2339
+ *
2340
+ * @param infoptr pointer to the Info object
2341
+ */
2342
+ static size_t
2343
+ Info_memsize(const void *infoptr)
2344
+ {
2345
+ return sizeof(Info);
2346
+ }
2520
2347
 
2521
2348
  /**
2522
- * Create an ImageInfo object.
2349
+ * Create an Image::Info object.
2523
2350
  *
2524
2351
  * No Ruby usage (internal function)
2525
2352
  *
2526
- * @param class the Ruby class to use
2353
+ * @param klass the Ruby class to use
2527
2354
  * @return a new ImageInfo object
2528
2355
  */
2529
2356
  VALUE
2530
- Info_alloc(VALUE class)
2357
+ Info_alloc(VALUE klass)
2531
2358
  {
2532
2359
  Info *info;
2533
2360
  VALUE info_obj;
@@ -2537,7 +2364,7 @@ Info_alloc(VALUE class)
2537
2364
  {
2538
2365
  rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
2539
2366
  }
2540
- info_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
2367
+ info_obj = TypedData_Wrap_Struct(klass, &rm_info_data_type, info);
2541
2368
 
2542
2369
  RB_GC_GUARD(info_obj);
2543
2370
 
@@ -2571,10 +2398,12 @@ rm_info_new(void)
2571
2398
  /**
2572
2399
  * If an initializer block is present, run it.
2573
2400
  *
2574
- * Ruby usage:
2575
- * - @verbatim Info#initialize @endverbatim
2401
+ * @overload initialize
2402
+ *
2403
+ * @overload initialize
2404
+ * @yield [info]
2405
+ * @yieldparam info [Magick::Image::Info]
2576
2406
  *
2577
- * @param self this object
2578
2407
  * @return self
2579
2408
  */
2580
2409
  VALUE
@@ -2582,8 +2411,7 @@ Info_initialize(VALUE self)
2582
2411
  {
2583
2412
  if (rb_block_given_p())
2584
2413
  {
2585
- // Run the block in self's context
2586
- (void) rb_obj_instance_eval(0, NULL, self);
2414
+ rb_yield(self);
2587
2415
  }
2588
2416
  return self;
2589
2417
  }