rdp-rmagick 0.0.0

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