rmagick-windows 2.16.1

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