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,1047 @@
1
+ /**************************************************************************//**
2
+ * Contains various Struct class methods.
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 rmstruct.c
9
+ * @version $Id: rmstruct.c,v 1.5 2009/12/20 02:33:34 baror Exp $
10
+ * @author Tim Hunter
11
+ ******************************************************************************/
12
+
13
+ #include "rmagick.h"
14
+
15
+
16
+
17
+
18
+ static const char *ComplianceType_name(ComplianceType *);
19
+ static VALUE ComplianceType_new(ComplianceType);
20
+ static const char *StretchType_name(StretchType);
21
+ static VALUE StretchType_new(StretchType);
22
+ static const char *StyleType_name(StyleType);
23
+ static VALUE StyleType_new(StyleType);
24
+
25
+
26
+
27
+
28
+ /**
29
+ * Given a C AffineMatrix, create the equivalent AffineMatrix object.
30
+ *
31
+ * No Ruby usage (internal function)
32
+ *
33
+ * Notes:
34
+ * - am = Magick::AffineMatrix.new(sx, rx, ry, sy, tx, ty)
35
+ *
36
+ * @param affine the C AffineMatrix
37
+ * @return a Ruby AffineMatrix object
38
+ */
39
+ VALUE
40
+ Import_AffineMatrix(AffineMatrix *affine)
41
+ {
42
+ VALUE argv[6];
43
+
44
+ argv[0] = rb_float_new(affine->sx);
45
+ argv[1] = rb_float_new(affine->rx);
46
+ argv[2] = rb_float_new(affine->ry);
47
+ argv[3] = rb_float_new(affine->sy);
48
+ argv[4] = rb_float_new(affine->tx);
49
+ argv[5] = rb_float_new(affine->ty);
50
+ return rb_class_new_instance(6, argv, Class_AffineMatrix);
51
+ }
52
+
53
+
54
+ /**
55
+ * Convert a Magick::AffineMatrix object to a AffineMatrix structure.
56
+ *
57
+ * No Ruby usage (internal function)
58
+ *
59
+ * Notes:
60
+ * - If not initialized, the defaults are [sx,rx,ry,sy,tx,ty] = [1,0,0,1,0,0]
61
+ *
62
+ * @param am The C AffineMatrix to modify
63
+ * @param st the Ruby AffineMatrix object
64
+ */
65
+ void
66
+ Export_AffineMatrix(AffineMatrix *am, VALUE st)
67
+ {
68
+ volatile VALUE values, v;
69
+
70
+ if (CLASS_OF(st) != Class_AffineMatrix)
71
+ {
72
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
73
+ rb_class2name(CLASS_OF(st)));
74
+ }
75
+ values = rb_funcall(st, rm_ID_values, 0);
76
+ v = rb_ary_entry(values, 0);
77
+ am->sx = v == Qnil ? 1.0 : NUM2DBL(v);
78
+ v = rb_ary_entry(values, 1);
79
+ am->rx = v == Qnil ? 0.0 : NUM2DBL(v);
80
+ v = rb_ary_entry(values, 2);
81
+ am->ry = v == Qnil ? 0.0 : NUM2DBL(v);
82
+ v = rb_ary_entry(values, 3);
83
+ am->sy = v == Qnil ? 1.0 : NUM2DBL(v);
84
+ v = rb_ary_entry(values, 4);
85
+ am->tx = v == Qnil ? 0.0 : NUM2DBL(v);
86
+ v = rb_ary_entry(values, 5);
87
+ am->ty = v == Qnil ? 0.0 : NUM2DBL(v);
88
+ }
89
+
90
+
91
+ /**
92
+ * Create a Magick::ChromaticityInfo object from a ChromaticityInfo structure.
93
+ *
94
+ * No Ruby usage (internal function)
95
+ *
96
+ * @param ci the C ChromaticityInfo
97
+ * @return a Ruby Magick::ChromaticityInfo object
98
+ */
99
+ VALUE
100
+ ChromaticityInfo_new(ChromaticityInfo *ci)
101
+ {
102
+ volatile VALUE red_primary;
103
+ volatile VALUE green_primary;
104
+ volatile VALUE blue_primary;
105
+ volatile VALUE white_point;
106
+
107
+ red_primary = Import_PrimaryInfo(&ci->red_primary);
108
+ green_primary = Import_PrimaryInfo(&ci->green_primary);
109
+ blue_primary = Import_PrimaryInfo(&ci->blue_primary);
110
+ white_point = Import_PrimaryInfo(&ci->white_point);
111
+
112
+ return rb_funcall(Class_Chromaticity, rm_ID_new, 4
113
+ , red_primary, green_primary, blue_primary, white_point);
114
+ }
115
+
116
+
117
+ /**
118
+ * Extract the elements from a Magick::ChromaticityInfo and store in a
119
+ * ChromaticityInfo structure.
120
+ *
121
+ * No Ruby usage (internal function)
122
+ *
123
+ * @param ci the C ChromaticityInfo structure to modify
124
+ * @param chrom the Ruby Magick::ChromaticityInfo object
125
+ */
126
+ void
127
+ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
128
+ {
129
+ volatile VALUE chrom_members;
130
+ volatile VALUE red_primary, green_primary, blue_primary, white_point;
131
+ volatile VALUE entry_members, x, y;
132
+ ID values_id;
133
+
134
+ if (CLASS_OF(chrom) != Class_Chromaticity)
135
+ {
136
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
137
+ rb_class2name(CLASS_OF(chrom)));
138
+ }
139
+ values_id = rm_ID_values;
140
+
141
+ // Get the struct members in an array
142
+ chrom_members = rb_funcall(chrom, values_id, 0);
143
+ red_primary = rb_ary_entry(chrom_members, 0);
144
+ green_primary = rb_ary_entry(chrom_members, 1);
145
+ blue_primary = rb_ary_entry(chrom_members, 2);
146
+ white_point = rb_ary_entry(chrom_members, 3);
147
+
148
+ // Get the red_primary PrimaryInfo members in an array
149
+ entry_members = rb_funcall(red_primary, values_id, 0);
150
+ x = rb_ary_entry(entry_members, 0); // red_primary.x
151
+ ci->red_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
152
+ y = rb_ary_entry(entry_members, 1); // red_primary.y
153
+ ci->red_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
154
+ ci->red_primary.z = 0.0;
155
+
156
+ // Get the green_primary PrimaryInfo members in an array
157
+ entry_members = rb_funcall(green_primary, values_id, 0);
158
+ x = rb_ary_entry(entry_members, 0); // green_primary.x
159
+ ci->green_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
160
+ y = rb_ary_entry(entry_members, 1); // green_primary.y
161
+ ci->green_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
162
+ ci->green_primary.z = 0.0;
163
+
164
+ // Get the blue_primary PrimaryInfo members in an array
165
+ entry_members = rb_funcall(blue_primary, values_id, 0);
166
+ x = rb_ary_entry(entry_members, 0); // blue_primary.x
167
+ ci->blue_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
168
+ y = rb_ary_entry(entry_members, 1); // blue_primary.y
169
+ ci->blue_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
170
+ ci->blue_primary.z = 0.0;
171
+
172
+ // Get the white_point PrimaryInfo members in an array
173
+ entry_members = rb_funcall(white_point, values_id, 0);
174
+ x = rb_ary_entry(entry_members, 0); // white_point.x
175
+ ci->white_point.x = x == Qnil ? 0.0 : NUM2DBL(x);
176
+ y = rb_ary_entry(entry_members, 1); // white_point.y
177
+ ci->white_point.y = y == Qnil ? 0.0 : NUM2DBL(y);
178
+ ci->white_point.z = 0.0;
179
+ }
180
+
181
+
182
+ /**
183
+ * Create a string representation of a Magick::Chromaticity.
184
+ *
185
+ * Ruby usage:
186
+ * - @verbatim Magick::Chromaticity#to_s @endverbatim
187
+ *
188
+ * @param self this object
189
+ * @return the string
190
+ */
191
+ VALUE
192
+ ChromaticityInfo_to_s(VALUE self)
193
+ {
194
+ ChromaticityInfo ci;
195
+ char buff[200];
196
+
197
+ Export_ChromaticityInfo(&ci, self);
198
+ sprintf(buff, "red_primary=(x=%g,y=%g) "
199
+ "green_primary=(x=%g,y=%g) "
200
+ "blue_primary=(x=%g,y=%g) "
201
+ "white_point=(x=%g,y=%g) ",
202
+ ci.red_primary.x, ci.red_primary.y,
203
+ ci.green_primary.x, ci.green_primary.y,
204
+ ci.blue_primary.x, ci.blue_primary.y,
205
+ ci.white_point.x, ci.white_point.y);
206
+ return rb_str_new2(buff);
207
+ }
208
+
209
+
210
+ /**
211
+ * Convert a ColorInfo structure to a Magick::Color.
212
+ *
213
+ * No Ruby usage (internal function)
214
+ *
215
+ * @param ci the C ColorInfo structure
216
+ * @return a Ruby Magick::Color object
217
+ */
218
+ VALUE
219
+ Import_ColorInfo(const ColorInfo *ci)
220
+ {
221
+ ComplianceType compliance_type;
222
+ volatile VALUE name;
223
+ volatile VALUE compliance;
224
+ volatile VALUE color;
225
+
226
+ name = rb_str_new2(ci->name);
227
+
228
+ compliance_type = ci->compliance;
229
+ compliance = ComplianceType_new(compliance_type);
230
+ color = Pixel_from_MagickPixelPacket(&(ci->color));
231
+
232
+ return rb_funcall(Class_Color, rm_ID_new, 3
233
+ , name, compliance, color);
234
+ }
235
+
236
+
237
+ /**
238
+ * Convert a Magick::Color to a ColorInfo structure.
239
+ *
240
+ * No Ruby usage (internal function)
241
+ *
242
+ * @param ci the C ColorInfo structure to modify
243
+ * @param st the Ruby Magick::Color object
244
+ */
245
+ void
246
+ Export_ColorInfo(ColorInfo *ci, VALUE st)
247
+ {
248
+ Pixel *pixel;
249
+ volatile VALUE members, m;
250
+
251
+ if (CLASS_OF(st) != Class_Color)
252
+ {
253
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
254
+ rb_class2name(CLASS_OF(st)));
255
+ }
256
+
257
+ memset(ci, '\0', sizeof(ColorInfo));
258
+
259
+ members = rb_funcall(st, rm_ID_values, 0);
260
+
261
+ m = rb_ary_entry(members, 0);
262
+ if (m != Qnil)
263
+ {
264
+ (void) CloneString((char **)&(ci->name), StringValuePtr(m));
265
+ }
266
+ m = rb_ary_entry(members, 1);
267
+ if (m != Qnil)
268
+ {
269
+ VALUE_TO_ENUM(m, ci->compliance, ComplianceType);
270
+ }
271
+ m = rb_ary_entry(members, 2);
272
+ if (m != Qnil)
273
+ {
274
+ Data_Get_Struct(m, Pixel, pixel);
275
+ // For >= 6.3.0, ColorInfo.color is a MagickPixelPacket so we have to
276
+ // convert the PixelPacket.
277
+ GetMagickPixelPacket(NULL, &ci->color);
278
+ ci->color.red = (MagickRealType) pixel->red;
279
+ ci->color.green = (MagickRealType) pixel->green;
280
+ ci->color.blue = (MagickRealType) pixel->blue;
281
+ ci->color.opacity = (MagickRealType) OpaqueOpacity;
282
+ ci->color.index = (MagickRealType) 0;
283
+ }
284
+ }
285
+
286
+
287
+ /**
288
+ * Convert either a String color name or a Magick::Pixel to a MagickPixelPacket.
289
+ *
290
+ * No Ruby usage (internal function)
291
+ *
292
+ * Notes:
293
+ * - The channel values in a MagickPixelPacket are doubles.
294
+ *
295
+ * @param image the Image
296
+ * @param mpp The MagickPixelPacket to modify
297
+ * @param color the name of the color
298
+ */
299
+ void
300
+ Color_to_MagickPixelPacket(Image *image, MagickPixelPacket *mpp, VALUE color)
301
+ {
302
+ PixelPacket pp;
303
+
304
+ // image can be NULL
305
+ GetMagickPixelPacket(image, mpp);
306
+
307
+ memset(&pp, '\0', sizeof(pp));
308
+ Color_to_PixelPacket(&pp, color);
309
+ mpp->red = (MagickRealType) pp.red;
310
+ mpp->green = (MagickRealType) pp.green;
311
+ mpp->blue = (MagickRealType) pp.blue;
312
+ mpp->opacity = (MagickRealType) pp.opacity;
313
+ }
314
+
315
+
316
+ /**
317
+ * Free the storage allocated by Export_ColorInfo.
318
+ *
319
+ * No Ruby usage (internal function)
320
+ *
321
+ * @param ci the ColorInfo object
322
+ * @see Export_ColorInfo
323
+ */
324
+ static void
325
+ destroy_ColorInfo(ColorInfo *ci)
326
+ {
327
+ magick_free((void*)ci->name);
328
+ ci->name = NULL;
329
+ }
330
+
331
+
332
+ /**
333
+ * Return a string representation of a Magick::Color object.
334
+ *
335
+ * Ruby usage:
336
+ * - @verbatim Color#to_s @endverbatim
337
+ *
338
+ * @param self this object
339
+ * @return the string
340
+ */
341
+ VALUE
342
+ Color_to_s(VALUE self)
343
+ {
344
+ ColorInfo ci;
345
+ char buff[1024];
346
+
347
+ Export_ColorInfo(&ci, self);
348
+
349
+ sprintf(buff, "name=%s, compliance=%s, "
350
+ #if (QuantumDepth == 32 || QuantumDepth == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
351
+ "color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.opacity=%Lg ",
352
+ #else
353
+ "color.red=%g, color.green=%g, color.blue=%g, color.opacity=%g ",
354
+ #endif
355
+ ci.name,
356
+ ComplianceType_name(&ci.compliance),
357
+ ci.color.red, ci.color.green, ci.color.blue, ci.color.opacity);
358
+
359
+ destroy_ColorInfo(&ci);
360
+ return rb_str_new2(buff);
361
+ }
362
+
363
+
364
+ /**
365
+ * Return the string representation of a ComplianceType value.
366
+ *
367
+ * No Ruby usage (internal function)
368
+ *
369
+ * Notes:
370
+ * - xMagick will OR multiple compliance types so we have to arbitrarily pick
371
+ * one name.
372
+ * - Set the compliance argument to the selected value.
373
+ *
374
+ * @param c the ComplianceType value
375
+ * @return the string
376
+ */
377
+ static const char *
378
+ ComplianceType_name(ComplianceType *c)
379
+ {
380
+ if ((*c & (SVGCompliance|X11Compliance|XPMCompliance))
381
+ == (SVGCompliance|X11Compliance|XPMCompliance))
382
+ {
383
+ return "AllCompliance";
384
+ }
385
+ else if (*c & SVGCompliance)
386
+ {
387
+ *c = SVGCompliance;
388
+ return "SVGCompliance";
389
+ }
390
+ else if (*c & X11Compliance)
391
+ {
392
+ *c = X11Compliance;
393
+ return "X11Compliance";
394
+ }
395
+ else if (*c & XPMCompliance)
396
+ {
397
+ *c = XPMCompliance;
398
+ return "XPMCompliance";
399
+ }
400
+ else if (*c == NoCompliance)
401
+ {
402
+ *c = NoCompliance;
403
+ return "NoCompliance";
404
+ }
405
+ else
406
+ {
407
+ *c = UndefinedCompliance;
408
+ return "UndefinedCompliance";
409
+ }
410
+ }
411
+
412
+
413
+ /**
414
+ * Construct a ComplianceType enum object for the specified value.
415
+ *
416
+ * No Ruby usage (internal function)
417
+ *
418
+ * @param compliance the C ComplianceType value
419
+ * @return the Ruby ComplianceType enum object
420
+ */
421
+ static VALUE
422
+ ComplianceType_new(ComplianceType compliance)
423
+ {
424
+ const char *name;
425
+
426
+ // Turn off undefined bits
427
+ compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
428
+ name = ComplianceType_name(&compliance);
429
+ return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
430
+ }
431
+
432
+
433
+ /**
434
+ * Convert a TypeInfo structure to a Magick::Font.
435
+ *
436
+ * No Ruby usage (internal function)
437
+ *
438
+ * @param ti the C TypeInfo structure
439
+ * @return a Ruby Magick::Font object
440
+ */
441
+ VALUE
442
+ Import_TypeInfo(const TypeInfo *ti)
443
+ {
444
+ volatile VALUE name, description, family;
445
+ volatile VALUE style, stretch, weight;
446
+ volatile VALUE encoding, foundry, format;
447
+
448
+ name = rb_str_new2(ti->name);
449
+ family = rb_str_new2(ti->family);
450
+ style = StyleType_new(ti->style);
451
+ stretch = StretchType_new(ti->stretch);
452
+ weight = ULONG2NUM(ti->weight);
453
+ description = ti->description ? rb_str_new2(ti->description) : Qnil;
454
+ encoding = ti->encoding ? rb_str_new2(ti->encoding) : Qnil;
455
+ foundry = ti->foundry ? rb_str_new2(ti->foundry) : Qnil;
456
+ format = ti->format ? rb_str_new2(ti->format) : Qnil;
457
+
458
+ return rb_funcall(Class_Font, rm_ID_new, 9
459
+ , name, description, family, style
460
+ , stretch, weight, encoding, foundry, format);
461
+ }
462
+
463
+
464
+ /**
465
+ * Convert a Magick::Font to a TypeInfo structure.
466
+ *
467
+ * No Ruby usage (internal function)
468
+ *
469
+ * @param ti the C TypeInfo structure to modify
470
+ * @param st the Ruby Magick::Font object
471
+ */
472
+ void
473
+ Export_TypeInfo(TypeInfo *ti, VALUE st)
474
+ {
475
+ volatile VALUE members, m;
476
+
477
+ if (CLASS_OF(st) != Class_Font)
478
+ {
479
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
480
+ rb_class2name(CLASS_OF(st)));
481
+ }
482
+
483
+ memset(ti, '\0', sizeof(TypeInfo));
484
+
485
+ members = rb_funcall(st, rm_ID_values, 0);
486
+ m = rb_ary_entry(members, 0);
487
+ if (m != Qnil)
488
+ {
489
+ (void) CloneString((char **)&(ti->name), StringValuePtr(m));
490
+ }
491
+ m = rb_ary_entry(members, 1);
492
+ if (m != Qnil)
493
+ {
494
+ (void) CloneString((char **)&(ti->description), StringValuePtr(m));
495
+ }
496
+ m = rb_ary_entry(members, 2);
497
+ if (m != Qnil)
498
+ {
499
+ (void) CloneString((char **)&(ti->family), StringValuePtr(m));
500
+ }
501
+ m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(m);
502
+ m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(m);
503
+ m = rb_ary_entry(members, 5); ti->weight = m == Qnil ? 0 : FIX2INT(m);
504
+
505
+ m = rb_ary_entry(members, 6);
506
+ if (m != Qnil)
507
+ (void) CloneString((char **)&(ti->encoding), StringValuePtr(m));
508
+ m = rb_ary_entry(members, 7);
509
+ if (m != Qnil)
510
+ (void) CloneString((char **)&(ti->foundry), StringValuePtr(m));
511
+ m = rb_ary_entry(members, 8);
512
+ if (m != Qnil)
513
+ (void) CloneString((char **)&(ti->format), StringValuePtr(m));
514
+ }
515
+
516
+
517
+ /**
518
+ * Free the storage allocated by Export_TypeInfo.
519
+ *
520
+ * No Ruby usage (internal function)
521
+ *
522
+ * @param ti the TypeInfo object
523
+ * @see Export_TypeInfo
524
+ */
525
+ static void
526
+ destroy_TypeInfo(TypeInfo *ti)
527
+ {
528
+ magick_free((void*)ti->name);
529
+ ti->name = NULL;
530
+ magick_free((void*)ti->description);
531
+ ti->description = NULL;
532
+ magick_free((void*)ti->family);
533
+ ti->family = NULL;
534
+ magick_free((void*)ti->encoding);
535
+ ti->encoding = NULL;
536
+ magick_free((void*)ti->foundry);
537
+ ti->foundry = NULL;
538
+ magick_free((void*)ti->format);
539
+ ti->format = NULL;
540
+ }
541
+
542
+
543
+ /**
544
+ * Implement the Font#to_s method.
545
+ *
546
+ * No Ruby usage (internal function)
547
+ *
548
+ * @param self this object
549
+ * @return the string
550
+ */
551
+ VALUE
552
+ Font_to_s(VALUE self)
553
+ {
554
+ TypeInfo ti;
555
+ char weight[20];
556
+ char buff[1024];
557
+
558
+ Export_TypeInfo(&ti, self);
559
+
560
+ switch (ti.weight)
561
+ {
562
+ case 400:
563
+ strcpy(weight, "NormalWeight");
564
+ break;
565
+ case 700:
566
+ strcpy(weight, "BoldWeight");
567
+ break;
568
+ default:
569
+ sprintf(weight, "%lu", ti.weight);
570
+ break;
571
+ }
572
+
573
+ sprintf(buff, "name=%s, description=%s, "
574
+ "family=%s, style=%s, stretch=%s, weight=%s, "
575
+ "encoding=%s, foundry=%s, format=%s",
576
+ ti.name,
577
+ ti.description,
578
+ ti.family,
579
+ StyleType_name(ti.style),
580
+ StretchType_name(ti.stretch),
581
+ weight,
582
+ ti.encoding ? ti.encoding : "",
583
+ ti.foundry ? ti.foundry : "",
584
+ ti.format ? ti.format : "");
585
+
586
+ destroy_TypeInfo(&ti);
587
+ return rb_str_new2(buff);
588
+
589
+ }
590
+
591
+
592
+ /**
593
+ * Create a Magick::Point object from a PointInfo structure.
594
+ *
595
+ * No Ruby usage (internal function)
596
+ *
597
+ * @param p the C PointInfo structure
598
+ * @return a Ruby Magick::Point object
599
+ */
600
+ VALUE
601
+ Import_PointInfo(PointInfo *p)
602
+ {
603
+ return rb_funcall(Class_Point, rm_ID_new, 2
604
+ , INT2FIX(p->x), INT2FIX(p->y));
605
+ }
606
+
607
+
608
+ /**
609
+ * Convert a Magick::Point object to a PointInfo structure.
610
+ *
611
+ * No Ruby usage (internal function)
612
+ *
613
+ * @param pi the C PointInfo structure to modify
614
+ * @param sp the Ruby Magick::Point object
615
+ */
616
+ void
617
+ Export_PointInfo(PointInfo *pi, VALUE sp)
618
+ {
619
+ volatile VALUE members, m;
620
+
621
+ if (CLASS_OF(sp) != Class_Point)
622
+ {
623
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
624
+ rb_class2name(CLASS_OF(sp)));
625
+ }
626
+ members = rb_funcall(sp, rm_ID_values, 0);
627
+ m = rb_ary_entry(members, 0);
628
+ pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
629
+ m = rb_ary_entry(members, 1);
630
+ pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
631
+ }
632
+
633
+
634
+ /**
635
+ * Create a Magick::PrimaryInfo object from a PrimaryInfo structure.
636
+ *
637
+ * No Ruby usage (internal function)
638
+ *
639
+ * @param p the C PrimaryInfo structure
640
+ * @return a Ruby Magick::PrimaryInfo object
641
+ */
642
+ VALUE
643
+ Import_PrimaryInfo(PrimaryInfo *p)
644
+ {
645
+ return rb_funcall(Class_Primary, rm_ID_new, 3
646
+ , INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
647
+ }
648
+
649
+
650
+ /**
651
+ * Convert a Magick::PrimaryInfo object to a PrimaryInfo structure.
652
+ *
653
+ * No Ruby usage (internal function)
654
+ *
655
+ * @param pi the C PrimaryInfo structure to modify
656
+ * @param sp the Ruby Magick::PrimaryInfo object
657
+ */
658
+ void
659
+ Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
660
+ {
661
+ volatile VALUE members, m;
662
+
663
+ if (CLASS_OF(sp) != Class_Primary)
664
+ {
665
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
666
+ rb_class2name(CLASS_OF(sp)));
667
+ }
668
+ members = rb_funcall(sp, rm_ID_values, 0);
669
+ m = rb_ary_entry(members, 0);
670
+ pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
671
+ m = rb_ary_entry(members, 1);
672
+ pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
673
+ m = rb_ary_entry(members, 2);
674
+ pi->z = m == Qnil ? 0.0 : NUM2DBL(m);
675
+ }
676
+
677
+
678
+ /**
679
+ * Create a string representation of a Magick::PrimaryInfo.
680
+ *
681
+ * Ruby usage:
682
+ * - @verbatim Magick::PrimaryInfo#to_s @endverbatim
683
+ *
684
+ * @param self this object
685
+ * @return the string
686
+ */
687
+ VALUE
688
+ PrimaryInfo_to_s(VALUE self)
689
+ {
690
+ PrimaryInfo pi;
691
+ char buff[100];
692
+
693
+ Export_PrimaryInfo(&pi, self);
694
+ sprintf(buff, "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
695
+ return rb_str_new2(buff);
696
+ }
697
+
698
+
699
+ /**
700
+ * Convert a RectangleInfo structure to a Magick::Rectangle.
701
+ *
702
+ * No Ruby usage (internal function)
703
+ *
704
+ * @param rect the C RectangleInfo structure
705
+ * @return a Ruby Magick::Rectangle object
706
+ */
707
+ VALUE
708
+ Import_RectangleInfo(RectangleInfo *rect)
709
+ {
710
+ volatile VALUE width;
711
+ volatile VALUE height;
712
+ volatile VALUE x, y;
713
+
714
+ width = UINT2NUM(rect->width);
715
+ height = UINT2NUM(rect->height);
716
+ x = INT2NUM(rect->x);
717
+ y = INT2NUM(rect->y);
718
+ return rb_funcall(Class_Rectangle, rm_ID_new, 4
719
+ , width, height, x, y);
720
+ }
721
+
722
+
723
+ /**
724
+ * Convert a Magick::Rectangle to a RectangleInfo structure.
725
+ *
726
+ * No Ruby usage (internal function)
727
+ *
728
+ * @param rect the C RectangleInfo structure to modify
729
+ * @param sr the Ruby Magick::Rectangle object
730
+ */
731
+ void
732
+ Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
733
+ {
734
+ volatile VALUE members, m;
735
+
736
+ if (CLASS_OF(sr) != Class_Rectangle)
737
+ {
738
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
739
+ rb_class2name(CLASS_OF(sr)));
740
+ }
741
+ members = rb_funcall(sr, rm_ID_values, 0);
742
+ m = rb_ary_entry(members, 0);
743
+ rect->width = m == Qnil ? 0 : NUM2ULONG(m);
744
+ m = rb_ary_entry(members, 1);
745
+ rect->height = m == Qnil ? 0 : NUM2ULONG(m);
746
+ m = rb_ary_entry(members, 2);
747
+ rect->x = m == Qnil ? 0 : NUM2LONG (m);
748
+ m = rb_ary_entry(members, 3);
749
+ rect->y = m == Qnil ? 0 : NUM2LONG (m);
750
+ }
751
+
752
+
753
+ /**
754
+ * Create a string representation of a Magick::Rectangle.
755
+ *
756
+ * Ruby usage:
757
+ * - @verbatim Magick::Rectangle#to_s @endverbatim
758
+ *
759
+ * @param self this object
760
+ * @return the string
761
+ */
762
+ VALUE
763
+ RectangleInfo_to_s(VALUE self)
764
+ {
765
+ RectangleInfo rect;
766
+ char buff[100];
767
+
768
+ Export_RectangleInfo(&rect, self);
769
+ sprintf(buff, "width=%lu, height=%lu, x=%ld, y=%ld"
770
+ , rect.width, rect.height, rect.x, rect.y);
771
+ return rb_str_new2(buff);
772
+ }
773
+
774
+
775
+ /**
776
+ * Convert a SegmentInfo structure to a Magick::Segment.
777
+ *
778
+ * No Ruby usage (internal function)
779
+ *
780
+ * @param segment the C SegmentInfo structure
781
+ * @return a Ruby Magick::Segment object
782
+ */
783
+ VALUE
784
+ Import_SegmentInfo(SegmentInfo *segment)
785
+ {
786
+ volatile VALUE x1, y1, x2, y2;
787
+
788
+ x1 = rb_float_new(segment->x1);
789
+ y1 = rb_float_new(segment->y1);
790
+ x2 = rb_float_new(segment->x2);
791
+ y2 = rb_float_new(segment->y2);
792
+ return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
793
+ }
794
+
795
+
796
+ /**
797
+ * Convert a Magick::Segment to a SegmentInfo structure.
798
+ *
799
+ * No Ruby usage (internal function)
800
+ *
801
+ * @param segment the C SegmentInfo structure to modify
802
+ * @param s the Ruby Magick::Segment object
803
+ */
804
+ void
805
+ Export_SegmentInfo(SegmentInfo *segment, VALUE s)
806
+ {
807
+ volatile VALUE members, m;
808
+
809
+ if (CLASS_OF(s) != Class_Segment)
810
+ {
811
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
812
+ rb_class2name(CLASS_OF(s)));
813
+ }
814
+
815
+ members = rb_funcall(s, rm_ID_values, 0);
816
+ m = rb_ary_entry(members, 0);
817
+ segment->x1 = m == Qnil ? 0.0 : NUM2DBL(m);
818
+ m = rb_ary_entry(members, 1);
819
+ segment->y1 = m == Qnil ? 0.0 : NUM2DBL(m);
820
+ m = rb_ary_entry(members, 2);
821
+ segment->x2 = m == Qnil ? 0.0 : NUM2DBL(m);
822
+ m = rb_ary_entry(members, 3);
823
+ segment->y2 = m == Qnil ? 0.0 : NUM2DBL(m);
824
+ }
825
+
826
+
827
+ /**
828
+ * Create a string representation of a Magick::Segment.
829
+ *
830
+ * Ruby usage:
831
+ * - @verbatim Magick::SegmentInfo#to_s @endverbatim
832
+ *
833
+ * @param self this object
834
+ * @return the string
835
+ */
836
+ VALUE
837
+ SegmentInfo_to_s(VALUE self)
838
+ {
839
+ SegmentInfo segment;
840
+ char buff[100];
841
+
842
+ Export_SegmentInfo(&segment, self);
843
+ sprintf(buff, "x1=%g, y1=%g, x2=%g, y2=%g"
844
+ , segment.x1, segment.y1, segment.x2, segment.y2);
845
+ return rb_str_new2(buff);
846
+ }
847
+
848
+
849
+ /**
850
+ * Return the string representation of a StretchType value.
851
+ *
852
+ * No Ruby usage (internal function)
853
+ *
854
+ * @param stretch the StretchType value
855
+ * @return the string
856
+ */
857
+ static const char *
858
+ StretchType_name(StretchType stretch)
859
+ {
860
+ switch (stretch)
861
+ {
862
+ ENUM_TO_NAME(UndefinedStretch)
863
+ ENUM_TO_NAME(NormalStretch)
864
+ ENUM_TO_NAME(UltraCondensedStretch)
865
+ ENUM_TO_NAME(ExtraCondensedStretch)
866
+ ENUM_TO_NAME(CondensedStretch)
867
+ ENUM_TO_NAME(SemiCondensedStretch)
868
+ ENUM_TO_NAME(SemiExpandedStretch)
869
+ ENUM_TO_NAME(ExpandedStretch)
870
+ ENUM_TO_NAME(ExtraExpandedStretch)
871
+ ENUM_TO_NAME(UltraExpandedStretch)
872
+ ENUM_TO_NAME(AnyStretch)
873
+ }
874
+
875
+ return "UndefinedStretch";
876
+ }
877
+
878
+
879
+ /**
880
+ * Construct a StretchType enum for a specified StretchType value.
881
+ *
882
+ * No Ruby usage (internal function)
883
+ *
884
+ * @param stretch the C StretchType value
885
+ * @return a Ruby StretchType enum
886
+ */
887
+ static VALUE
888
+ StretchType_new(StretchType stretch)
889
+ {
890
+ const char *name = StretchType_name(stretch);
891
+ return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
892
+ }
893
+
894
+
895
+ /**
896
+ * Return the string representation of a StyleType value.
897
+ *
898
+ * No Ruby usage (internal function)
899
+ *
900
+ * @param style the StyleType value
901
+ * @return the string
902
+ */
903
+ static const char *
904
+ StyleType_name(StyleType style)
905
+ {
906
+ switch (style)
907
+ {
908
+ ENUM_TO_NAME(UndefinedStyle)
909
+ ENUM_TO_NAME(NormalStyle)
910
+ ENUM_TO_NAME(ItalicStyle)
911
+ ENUM_TO_NAME(ObliqueStyle)
912
+ ENUM_TO_NAME(AnyStyle)
913
+ }
914
+
915
+ return "UndefinedStyle";
916
+ }
917
+
918
+
919
+ /**
920
+ * Construct a StyleType enum for a specified StyleType value.
921
+ *
922
+ * No Ruby usage (internal function)
923
+ *
924
+ * @param style the C StyleType value
925
+ * @return a Ruby StyleType enum
926
+ */
927
+ static VALUE
928
+ StyleType_new(StyleType style)
929
+ {
930
+ const char *name = StyleType_name(style);
931
+ return rm_enum_new(Class_StyleType, ID2SYM(rb_intern(name)), INT2FIX(style));
932
+ }
933
+
934
+
935
+ /**
936
+ * Convert a TypeMetric structure to a Magick::TypeMetric.
937
+ *
938
+ * No Ruby usage (internal function)
939
+ *
940
+ * @param tm the C TypeMetric structure
941
+ * @return a Ruby Magick::TypeMetric object
942
+ */
943
+ VALUE
944
+ Import_TypeMetric(TypeMetric *tm)
945
+ {
946
+ volatile VALUE pixels_per_em;
947
+ volatile VALUE ascent, descent;
948
+ volatile VALUE width, height, max_advance;
949
+ volatile VALUE bounds, underline_position, underline_thickness;
950
+
951
+ pixels_per_em = Import_PointInfo(&tm->pixels_per_em);
952
+ ascent = rb_float_new(tm->ascent);
953
+ descent = rb_float_new(tm->descent);
954
+ width = rb_float_new(tm->width);
955
+ height = rb_float_new(tm->height);
956
+ max_advance = rb_float_new(tm->max_advance);
957
+ bounds = Import_SegmentInfo(&tm->bounds);
958
+ underline_position = rb_float_new(tm->underline_position);
959
+ underline_thickness = rb_float_new(tm->underline_position);
960
+
961
+ return rb_funcall(Class_TypeMetric, rm_ID_new, 9
962
+ , pixels_per_em, ascent, descent, width
963
+ , height, max_advance, bounds
964
+ , underline_position, underline_thickness);
965
+ }
966
+
967
+
968
+ /**
969
+ * Convert a Magick::TypeMetric to a TypeMetric structure.
970
+ *
971
+ * No Ruby usage (internal function)
972
+ *
973
+ * @param tm the C TypeMetric structure to modify
974
+ * @param st the Ruby Magick::TypeMetric object
975
+ */
976
+ void
977
+ Export_TypeMetric(TypeMetric *tm, VALUE st)
978
+ {
979
+ volatile VALUE members, m;
980
+ volatile VALUE pixels_per_em;
981
+
982
+ if (CLASS_OF(st) != Class_TypeMetric)
983
+ {
984
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
985
+ rb_class2name(CLASS_OF(st)));
986
+ }
987
+ members = rb_funcall(st, rm_ID_values, 0);
988
+
989
+ pixels_per_em = rb_ary_entry(members, 0);
990
+ Export_PointInfo(&tm->pixels_per_em, pixels_per_em);
991
+
992
+ m = rb_ary_entry(members, 1);
993
+ tm->ascent = m == Qnil ? 0.0 : NUM2DBL(m);
994
+ m = rb_ary_entry(members, 2);
995
+ tm->descent = m == Qnil ? 0.0 : NUM2DBL(m);
996
+ m = rb_ary_entry(members, 3);
997
+ tm->width = m == Qnil ? 0.0 : NUM2DBL(m);
998
+ m = rb_ary_entry(members, 4);
999
+ tm->height = m == Qnil ? 0.0 : NUM2DBL(m);
1000
+ m = rb_ary_entry(members, 5);
1001
+ tm->max_advance = m == Qnil ? 0.0 : NUM2DBL(m);
1002
+
1003
+ m = rb_ary_entry(members, 6);
1004
+ Export_SegmentInfo(&tm->bounds, m);
1005
+
1006
+ m = rb_ary_entry(members, 7);
1007
+ tm->underline_position = m == Qnil ? 0.0 : NUM2DBL(m);
1008
+ m = rb_ary_entry(members, 8);
1009
+ tm->underline_thickness = m == Qnil ? 0.0 : NUM2DBL(m);
1010
+ }
1011
+
1012
+
1013
+ /**
1014
+ * Create a string representation of a Magick::TypeMetric.
1015
+ *
1016
+ * Ruby usage:
1017
+ * - @verbatim Magick::TypeMetric#to_s @endverbatim
1018
+ *
1019
+ * @param self this object
1020
+ * @return the string
1021
+ */
1022
+ VALUE
1023
+ TypeMetric_to_s(VALUE self)
1024
+ {
1025
+ volatile VALUE str;
1026
+ TypeMetric tm;
1027
+ char temp[200];
1028
+ int len;
1029
+
1030
+ Export_TypeMetric(&tm, self);
1031
+
1032
+ len = sprintf(temp, "pixels_per_em=(x=%g,y=%g) ", tm.pixels_per_em.x, tm.pixels_per_em.y);
1033
+ str = rb_str_new(temp, len);
1034
+ len = sprintf(temp, "ascent=%g descent=%g ",tm.ascent, tm.descent);
1035
+ rb_str_cat(str, temp, len);
1036
+ len = sprintf(temp, "width=%g height=%g max_advance=%g ", tm.width, tm.height, tm.max_advance);
1037
+ rb_str_cat(str, temp, len);
1038
+ len = sprintf(temp, "bounds.x1=%g bounds.y1=%g ", tm.bounds.x1, tm.bounds.y1);
1039
+ rb_str_cat(str, temp, len);
1040
+ len = sprintf(temp, "bounds.x2=%g bounds.y2=%g ", tm.bounds.x2, tm.bounds.y2);
1041
+ rb_str_cat(str, temp, len);
1042
+ len = sprintf(temp, "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
1043
+ rb_str_cat(str, temp, len);
1044
+
1045
+ return str;
1046
+ }
1047
+