rmagick-windows 2.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (393) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +14 -0
  3. data/.gitignore +23 -0
  4. data/.hound.yml +2 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +340 -0
  7. data/.simplecov +27 -0
  8. data/.travis.yml +60 -0
  9. data/CHANGELOG.md +915 -0
  10. data/CODE_OF_CONDUCT.md +13 -0
  11. data/CONTRIBUTING.md +50 -0
  12. data/Doxyfile +1514 -0
  13. data/Gemfile +10 -0
  14. data/LICENSE +20 -0
  15. data/README.textile +257 -0
  16. data/Rakefile +188 -0
  17. data/before_install_linux.sh +32 -0
  18. data/before_install_osx.sh +2 -0
  19. data/deprecated/RMagick.rb +6 -0
  20. data/doc/.cvsignore +1 -0
  21. data/doc/comtasks.html +287 -0
  22. data/doc/constants.html +1581 -0
  23. data/doc/css/doc.css +299 -0
  24. data/doc/css/popup.css +34 -0
  25. data/doc/css/ref.css +67 -0
  26. data/doc/draw.html +3272 -0
  27. data/doc/ex/InitialCoords.rb +22 -0
  28. data/doc/ex/NewCoordSys.rb +30 -0
  29. data/doc/ex/OrigCoordSys.rb +16 -0
  30. data/doc/ex/PreserveAspectRatio.rb +204 -0
  31. data/doc/ex/RotateScale.rb +36 -0
  32. data/doc/ex/Skew.rb +38 -0
  33. data/doc/ex/Use01.rb +15 -0
  34. data/doc/ex/Use02.rb +20 -0
  35. data/doc/ex/Use03.rb +16 -0
  36. data/doc/ex/ViewBox.rb +31 -0
  37. data/doc/ex/adaptive_threshold.rb +9 -0
  38. data/doc/ex/add_noise.rb +16 -0
  39. data/doc/ex/affine.rb +48 -0
  40. data/doc/ex/affine_transform.rb +20 -0
  41. data/doc/ex/arc.rb +49 -0
  42. data/doc/ex/arcpath.rb +32 -0
  43. data/doc/ex/arcs01.rb +28 -0
  44. data/doc/ex/arcs02.rb +59 -0
  45. data/doc/ex/average.rb +15 -0
  46. data/doc/ex/axes.rb +64 -0
  47. data/doc/ex/baseline_shift01.rb +17 -0
  48. data/doc/ex/bilevel_channel.rb +8 -0
  49. data/doc/ex/blur_image.rb +12 -0
  50. data/doc/ex/border.rb +10 -0
  51. data/doc/ex/bounding_box.rb +42 -0
  52. data/doc/ex/cbezier1.rb +41 -0
  53. data/doc/ex/cbezier2.rb +41 -0
  54. data/doc/ex/cbezier3.rb +41 -0
  55. data/doc/ex/cbezier4.rb +42 -0
  56. data/doc/ex/cbezier5.rb +42 -0
  57. data/doc/ex/cbezier6.rb +53 -0
  58. data/doc/ex/channel.rb +25 -0
  59. data/doc/ex/charcoal.rb +12 -0
  60. data/doc/ex/chop.rb +29 -0
  61. data/doc/ex/circle.rb +33 -0
  62. data/doc/ex/circle01.rb +16 -0
  63. data/doc/ex/clip_path.rb +60 -0
  64. data/doc/ex/coalesce.rb +57 -0
  65. data/doc/ex/color_fill_to_border.rb +29 -0
  66. data/doc/ex/color_floodfill.rb +28 -0
  67. data/doc/ex/color_histogram.rb +47 -0
  68. data/doc/ex/color_reset.rb +11 -0
  69. data/doc/ex/colorize.rb +16 -0
  70. data/doc/ex/colors.rb +64 -0
  71. data/doc/ex/compose_mask.rb +22 -0
  72. data/doc/ex/composite.rb +133 -0
  73. data/doc/ex/composite_layers.rb +53 -0
  74. data/doc/ex/composite_tiled.rb +21 -0
  75. data/doc/ex/contrast.rb +36 -0
  76. data/doc/ex/crop.rb +31 -0
  77. data/doc/ex/crop_with_gravity.rb +42 -0
  78. data/doc/ex/cubic01.rb +43 -0
  79. data/doc/ex/cubic02.rb +91 -0
  80. data/doc/ex/cycle_colormap.rb +21 -0
  81. data/doc/ex/dissolve.rb +12 -0
  82. data/doc/ex/drawcomp.rb +42 -0
  83. data/doc/ex/drop_shadow.rb +60 -0
  84. data/doc/ex/edge.rb +11 -0
  85. data/doc/ex/ellipse.rb +45 -0
  86. data/doc/ex/ellipse01.rb +21 -0
  87. data/doc/ex/emboss.rb +11 -0
  88. data/doc/ex/enhance.rb +28 -0
  89. data/doc/ex/equalize.rb +11 -0
  90. data/doc/ex/evenodd.rb +42 -0
  91. data/doc/ex/fill_pattern.rb +23 -0
  92. data/doc/ex/flatten_images.rb +36 -0
  93. data/doc/ex/flip.rb +11 -0
  94. data/doc/ex/flop.rb +11 -0
  95. data/doc/ex/font_styles.rb +32 -0
  96. data/doc/ex/fonts.rb +20 -0
  97. data/doc/ex/frame.rb +12 -0
  98. data/doc/ex/gaussian_blur.rb +11 -0
  99. data/doc/ex/get_multiline_type_metrics.rb +41 -0
  100. data/doc/ex/get_pixels.rb +47 -0
  101. data/doc/ex/get_type_metrics.rb +141 -0
  102. data/doc/ex/gradientfill.rb +27 -0
  103. data/doc/ex/grav.rb +45 -0
  104. data/doc/ex/gravity.rb +80 -0
  105. data/doc/ex/group.rb +26 -0
  106. data/doc/ex/hatchfill.rb +27 -0
  107. data/doc/ex/image.rb +44 -0
  108. data/doc/ex/images/Apple.miff +0 -0
  109. data/doc/ex/images/Ballerina.jpg +0 -0
  110. data/doc/ex/images/Ballerina3.jpg +0 -0
  111. data/doc/ex/images/Button_0.gif +0 -0
  112. data/doc/ex/images/Button_1.gif +0 -0
  113. data/doc/ex/images/Button_2.gif +0 -0
  114. data/doc/ex/images/Button_3.gif +0 -0
  115. data/doc/ex/images/Button_4.gif +0 -0
  116. data/doc/ex/images/Button_5.gif +0 -0
  117. data/doc/ex/images/Button_6.gif +0 -0
  118. data/doc/ex/images/Button_7.gif +0 -0
  119. data/doc/ex/images/Button_8.gif +0 -0
  120. data/doc/ex/images/Button_9.gif +0 -0
  121. data/doc/ex/images/Button_A.gif +0 -0
  122. data/doc/ex/images/Button_B.gif +0 -0
  123. data/doc/ex/images/Button_C.gif +0 -0
  124. data/doc/ex/images/Button_D.gif +0 -0
  125. data/doc/ex/images/Button_E.gif +0 -0
  126. data/doc/ex/images/Button_F.gif +0 -0
  127. data/doc/ex/images/Button_G.gif +0 -0
  128. data/doc/ex/images/Button_H.gif +0 -0
  129. data/doc/ex/images/Button_I.gif +0 -0
  130. data/doc/ex/images/Button_J.gif +0 -0
  131. data/doc/ex/images/Button_K.gif +0 -0
  132. data/doc/ex/images/Button_L.gif +0 -0
  133. data/doc/ex/images/Button_M.gif +0 -0
  134. data/doc/ex/images/Button_N.gif +0 -0
  135. data/doc/ex/images/Button_O.gif +0 -0
  136. data/doc/ex/images/Button_P.gif +0 -0
  137. data/doc/ex/images/Button_Q.gif +0 -0
  138. data/doc/ex/images/Button_R.gif +0 -0
  139. data/doc/ex/images/Button_S.gif +0 -0
  140. data/doc/ex/images/Button_T.gif +0 -0
  141. data/doc/ex/images/Button_U.gif +0 -0
  142. data/doc/ex/images/Button_V.gif +0 -0
  143. data/doc/ex/images/Button_W.gif +0 -0
  144. data/doc/ex/images/Button_X.gif +0 -0
  145. data/doc/ex/images/Button_Y.gif +0 -0
  146. data/doc/ex/images/Button_Z.gif +0 -0
  147. data/doc/ex/images/Cheetah.jpg +0 -0
  148. data/doc/ex/images/Coffee.wmf +0 -0
  149. data/doc/ex/images/Flower_Hat.jpg +0 -0
  150. data/doc/ex/images/Gold_Statue.jpg +0 -0
  151. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  152. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  153. data/doc/ex/images/Leaf.miff +0 -0
  154. data/doc/ex/images/No.wmf +0 -0
  155. data/doc/ex/images/Polynesia.jpg +0 -0
  156. data/doc/ex/images/Red_Rocks.jpg +0 -0
  157. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  158. data/doc/ex/images/Shorts.jpg +0 -0
  159. data/doc/ex/images/Snake.wmf +0 -0
  160. data/doc/ex/images/Violin.jpg +0 -0
  161. data/doc/ex/images/Yellow_Rose.miff +0 -0
  162. data/doc/ex/images/big-duck.gif +0 -0
  163. data/doc/ex/images/duck.gif +0 -0
  164. data/doc/ex/images/duck0.gif +0 -0
  165. data/doc/ex/images/duck1.gif +0 -0
  166. data/doc/ex/images/duck10.gif +0 -0
  167. data/doc/ex/images/duck11.gif +0 -0
  168. data/doc/ex/images/duck12.gif +0 -0
  169. data/doc/ex/images/duck13.gif +0 -0
  170. data/doc/ex/images/duck14.gif +0 -0
  171. data/doc/ex/images/duck15.gif +0 -0
  172. data/doc/ex/images/duck2.gif +0 -0
  173. data/doc/ex/images/duck3.gif +0 -0
  174. data/doc/ex/images/duck4.gif +0 -0
  175. data/doc/ex/images/duck5.gif +0 -0
  176. data/doc/ex/images/duck6.gif +0 -0
  177. data/doc/ex/images/duck7.gif +0 -0
  178. data/doc/ex/images/duck8.gif +0 -0
  179. data/doc/ex/images/duck9.gif +0 -0
  180. data/doc/ex/images/graydient230x6.gif +0 -0
  181. data/doc/ex/images/image_with_profile.jpg +0 -0
  182. data/doc/ex/images/logo400x83.gif +0 -0
  183. data/doc/ex/images/model.miff +0 -0
  184. data/doc/ex/images/notimplemented.gif +0 -0
  185. data/doc/ex/images/smile.miff +0 -0
  186. data/doc/ex/images/spin.gif +0 -0
  187. data/doc/ex/implode.rb +34 -0
  188. data/doc/ex/level.rb +11 -0
  189. data/doc/ex/level_colors.rb +11 -0
  190. data/doc/ex/line.rb +41 -0
  191. data/doc/ex/line01.rb +21 -0
  192. data/doc/ex/mask.rb +35 -0
  193. data/doc/ex/matte_fill_to_border.rb +39 -0
  194. data/doc/ex/matte_floodfill.rb +32 -0
  195. data/doc/ex/matte_replace.rb +39 -0
  196. data/doc/ex/median_filter.rb +28 -0
  197. data/doc/ex/modulate.rb +11 -0
  198. data/doc/ex/mono.rb +23 -0
  199. data/doc/ex/morph.rb +25 -0
  200. data/doc/ex/mosaic.rb +35 -0
  201. data/doc/ex/motion_blur.rb +11 -0
  202. data/doc/ex/negate.rb +11 -0
  203. data/doc/ex/negate_channel.rb +9 -0
  204. data/doc/ex/nested_rvg.rb +21 -0
  205. data/doc/ex/nonzero.rb +42 -0
  206. data/doc/ex/normalize.rb +11 -0
  207. data/doc/ex/oil_paint.rb +11 -0
  208. data/doc/ex/opacity.rb +37 -0
  209. data/doc/ex/ordered_dither.rb +11 -0
  210. data/doc/ex/path.rb +63 -0
  211. data/doc/ex/pattern1.rb +25 -0
  212. data/doc/ex/pattern2.rb +26 -0
  213. data/doc/ex/polaroid.rb +27 -0
  214. data/doc/ex/polygon.rb +23 -0
  215. data/doc/ex/polygon01.rb +21 -0
  216. data/doc/ex/polyline.rb +22 -0
  217. data/doc/ex/polyline01.rb +21 -0
  218. data/doc/ex/posterize.rb +8 -0
  219. data/doc/ex/preview.rb +8 -0
  220. data/doc/ex/qbezierpath.rb +52 -0
  221. data/doc/ex/quad01.rb +34 -0
  222. data/doc/ex/quantize-m.rb +25 -0
  223. data/doc/ex/radial_blur.rb +9 -0
  224. data/doc/ex/raise.rb +8 -0
  225. data/doc/ex/random_threshold_channel.rb +13 -0
  226. data/doc/ex/rect01.rb +14 -0
  227. data/doc/ex/rect02.rb +20 -0
  228. data/doc/ex/rectangle.rb +34 -0
  229. data/doc/ex/reduce_noise.rb +28 -0
  230. data/doc/ex/remap.rb +11 -0
  231. data/doc/ex/remap_images.rb +19 -0
  232. data/doc/ex/resize_to_fill.rb +8 -0
  233. data/doc/ex/resize_to_fit.rb +8 -0
  234. data/doc/ex/roll.rb +9 -0
  235. data/doc/ex/rotate.rb +44 -0
  236. data/doc/ex/rotate_f.rb +14 -0
  237. data/doc/ex/roundrect.rb +33 -0
  238. data/doc/ex/rubyname.rb +30 -0
  239. data/doc/ex/rvg_clippath.rb +12 -0
  240. data/doc/ex/rvg_linecap.rb +42 -0
  241. data/doc/ex/rvg_linejoin.rb +40 -0
  242. data/doc/ex/rvg_opacity.rb +18 -0
  243. data/doc/ex/rvg_pattern.rb +26 -0
  244. data/doc/ex/rvg_stroke_dasharray.rb +11 -0
  245. data/doc/ex/segment.rb +11 -0
  246. data/doc/ex/sepiatone.rb +7 -0
  247. data/doc/ex/shade.rb +11 -0
  248. data/doc/ex/shadow.rb +30 -0
  249. data/doc/ex/shave.rb +15 -0
  250. data/doc/ex/shear.rb +10 -0
  251. data/doc/ex/sketch.rb +17 -0
  252. data/doc/ex/skewx.rb +51 -0
  253. data/doc/ex/skewy.rb +47 -0
  254. data/doc/ex/smile.rb +125 -0
  255. data/doc/ex/solarize.rb +11 -0
  256. data/doc/ex/sparse_color.rb +54 -0
  257. data/doc/ex/splice.rb +8 -0
  258. data/doc/ex/spread.rb +11 -0
  259. data/doc/ex/stegano.rb +55 -0
  260. data/doc/ex/stroke_dasharray.rb +42 -0
  261. data/doc/ex/stroke_fill.rb +10 -0
  262. data/doc/ex/stroke_linecap.rb +44 -0
  263. data/doc/ex/stroke_linejoin.rb +48 -0
  264. data/doc/ex/stroke_width.rb +49 -0
  265. data/doc/ex/swirl.rb +17 -0
  266. data/doc/ex/text.rb +37 -0
  267. data/doc/ex/text01.rb +16 -0
  268. data/doc/ex/text_align.rb +36 -0
  269. data/doc/ex/text_antialias.rb +37 -0
  270. data/doc/ex/text_styles.rb +19 -0
  271. data/doc/ex/text_undercolor.rb +28 -0
  272. data/doc/ex/texture_fill_to_border.rb +34 -0
  273. data/doc/ex/texture_floodfill.rb +32 -0
  274. data/doc/ex/texturefill.rb +24 -0
  275. data/doc/ex/threshold.rb +13 -0
  276. data/doc/ex/to_blob.rb +13 -0
  277. data/doc/ex/translate.rb +39 -0
  278. data/doc/ex/transparent.rb +38 -0
  279. data/doc/ex/transpose.rb +9 -0
  280. data/doc/ex/transverse.rb +9 -0
  281. data/doc/ex/tref01.rb +24 -0
  282. data/doc/ex/triangle01.rb +15 -0
  283. data/doc/ex/trim.rb +23 -0
  284. data/doc/ex/tspan01.rb +17 -0
  285. data/doc/ex/tspan02.rb +17 -0
  286. data/doc/ex/tspan03.rb +19 -0
  287. data/doc/ex/unsharp_mask.rb +28 -0
  288. data/doc/ex/viewex.rb +33 -0
  289. data/doc/ex/vignette.rb +12 -0
  290. data/doc/ex/watermark.rb +27 -0
  291. data/doc/ex/wave.rb +9 -0
  292. data/doc/ex/wet_floor.rb +58 -0
  293. data/doc/ex/writing_mode01.rb +26 -0
  294. data/doc/ex/writing_mode02.rb +26 -0
  295. data/doc/ilist.html +2056 -0
  296. data/doc/image1.html +4680 -0
  297. data/doc/image2.html +3665 -0
  298. data/doc/image3.html +4522 -0
  299. data/doc/imageattrs.html +1638 -0
  300. data/doc/imusage.html +514 -0
  301. data/doc/index.html +416 -0
  302. data/doc/info.html +1499 -0
  303. data/doc/magick.html +565 -0
  304. data/doc/optequiv.html +2435 -0
  305. data/doc/rvg.html +975 -0
  306. data/doc/rvgclip.html +248 -0
  307. data/doc/rvggroup.html +305 -0
  308. data/doc/rvgimage.html +289 -0
  309. data/doc/rvgpattern.html +475 -0
  310. data/doc/rvgshape.html +406 -0
  311. data/doc/rvgstyle.html +270 -0
  312. data/doc/rvgtext.html +465 -0
  313. data/doc/rvgtspan.html +238 -0
  314. data/doc/rvgtut.html +530 -0
  315. data/doc/rvguse.html +145 -0
  316. data/doc/rvgxform.html +294 -0
  317. data/doc/scripts/doc.js +22 -0
  318. data/doc/scripts/stripeTables.js +23 -0
  319. data/doc/struct.html +1339 -0
  320. data/doc/usage.html +1621 -0
  321. data/examples/constitute.rb +7 -0
  322. data/examples/crop_with_gravity.rb +42 -0
  323. data/examples/demo.rb +324 -0
  324. data/examples/describe.rb +43 -0
  325. data/examples/find_similar_region.rb +34 -0
  326. data/examples/histogram.rb +321 -0
  327. data/examples/identify.rb +185 -0
  328. data/examples/image_opacity.rb +29 -0
  329. data/examples/import_export.rb +31 -0
  330. data/examples/pattern_fill.rb +38 -0
  331. data/examples/rotating_text.rb +44 -0
  332. data/examples/spinner.rb +49 -0
  333. data/examples/thumbnail.rb +64 -0
  334. data/examples/vignette.rb +78 -0
  335. data/ext/RMagick/extconf.rb +548 -0
  336. data/ext/RMagick/rmagick.c +401 -0
  337. data/ext/RMagick/rmagick.h +1287 -0
  338. data/ext/RMagick/rmdraw.c +2022 -0
  339. data/ext/RMagick/rmenum.c +1235 -0
  340. data/ext/RMagick/rmfill.c +720 -0
  341. data/ext/RMagick/rmilist.c +1270 -0
  342. data/ext/RMagick/rmimage.c +15427 -0
  343. data/ext/RMagick/rminfo.c +2590 -0
  344. data/ext/RMagick/rmmain.c +1741 -0
  345. data/ext/RMagick/rmmontage.c +519 -0
  346. data/ext/RMagick/rmpixel.c +1114 -0
  347. data/ext/RMagick/rmstruct.c +1124 -0
  348. data/ext/RMagick/rmutil.c +1754 -0
  349. data/lib/rmagick.rb +1 -0
  350. data/lib/rmagick/version.rb +6 -0
  351. data/lib/rmagick_internal.rb +1947 -0
  352. data/lib/rvg/clippath.rb +45 -0
  353. data/lib/rvg/container.rb +122 -0
  354. data/lib/rvg/deep_equal.rb +52 -0
  355. data/lib/rvg/describable.rb +47 -0
  356. data/lib/rvg/embellishable.rb +391 -0
  357. data/lib/rvg/misc.rb +723 -0
  358. data/lib/rvg/paint.rb +50 -0
  359. data/lib/rvg/pathdata.rb +126 -0
  360. data/lib/rvg/rvg.rb +283 -0
  361. data/lib/rvg/stretchable.rb +165 -0
  362. data/lib/rvg/stylable.rb +116 -0
  363. data/lib/rvg/text.rb +172 -0
  364. data/lib/rvg/transformable.rb +126 -0
  365. data/lib/rvg/units.rb +63 -0
  366. data/rmagick.gemspec +46 -0
  367. data/spec/rmagick/ImageList1_spec.rb +24 -0
  368. data/spec/rmagick/draw_spec.rb +156 -0
  369. data/spec/rmagick/image/blue_shift_spec.rb +16 -0
  370. data/spec/rmagick/image/composite_spec.rb +140 -0
  371. data/spec/rmagick/image/constitute_spec.rb +15 -0
  372. data/spec/rmagick/image/dispatch_spec.rb +18 -0
  373. data/spec/rmagick/image/from_blob_spec.rb +14 -0
  374. data/spec/rmagick/image/ping_spec.rb +14 -0
  375. data/spec/rmagick/image/properties_spec.rb +29 -0
  376. data/spec/spec_helper.rb +4 -0
  377. data/test/Image1.rb +565 -0
  378. data/test/Image2.rb +1304 -0
  379. data/test/Image3.rb +1030 -0
  380. data/test/ImageList1.rb +806 -0
  381. data/test/ImageList2.rb +385 -0
  382. data/test/Image_attributes.rb +697 -0
  383. data/test/Import_Export.rb +121 -0
  384. data/test/Info.rb +345 -0
  385. data/test/Magick.rb +321 -0
  386. data/test/Pixel.rb +116 -0
  387. data/test/Preview.rb +57 -0
  388. data/test/cmyk.icm +0 -0
  389. data/test/srgb.icm +0 -0
  390. data/test/test_all_basic.rb +38 -0
  391. data/test/tmpnam_test.rb +50 -0
  392. data/wercker.yml +10 -0
  393. metadata +509 -0
@@ -0,0 +1,1124 @@
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
+ 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
+ RB_GC_GUARD(values);
90
+ RB_GC_GUARD(v);
91
+ }
92
+
93
+
94
+ /**
95
+ * Create a Magick::ChromaticityInfo object from a ChromaticityInfo structure.
96
+ *
97
+ * No Ruby usage (internal function)
98
+ *
99
+ * @param ci the C ChromaticityInfo
100
+ * @return a Ruby Magick::ChromaticityInfo object
101
+ */
102
+ VALUE
103
+ ChromaticityInfo_new(ChromaticityInfo *ci)
104
+ {
105
+ VALUE red_primary;
106
+ VALUE green_primary;
107
+ VALUE blue_primary;
108
+ VALUE white_point;
109
+
110
+ red_primary = Import_PrimaryInfo(&ci->red_primary);
111
+ green_primary = Import_PrimaryInfo(&ci->green_primary);
112
+ blue_primary = Import_PrimaryInfo(&ci->blue_primary);
113
+ white_point = Import_PrimaryInfo(&ci->white_point);
114
+
115
+ RB_GC_GUARD(red_primary);
116
+ RB_GC_GUARD(green_primary);
117
+ RB_GC_GUARD(blue_primary);
118
+ RB_GC_GUARD(white_point);
119
+
120
+ return rb_funcall(Class_Chromaticity, rm_ID_new, 4
121
+ , red_primary, green_primary, blue_primary, white_point);
122
+ }
123
+
124
+
125
+ /**
126
+ * Extract the elements from a Magick::ChromaticityInfo and store in a
127
+ * ChromaticityInfo structure.
128
+ *
129
+ * No Ruby usage (internal function)
130
+ *
131
+ * @param ci the C ChromaticityInfo structure to modify
132
+ * @param chrom the Ruby Magick::ChromaticityInfo object
133
+ */
134
+ void
135
+ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
136
+ {
137
+ VALUE chrom_members;
138
+ VALUE red_primary, green_primary, blue_primary, white_point;
139
+ VALUE entry_members, x, y;
140
+ ID values_id;
141
+
142
+ if (CLASS_OF(chrom) != Class_Chromaticity)
143
+ {
144
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
145
+ rb_class2name(CLASS_OF(chrom)));
146
+ }
147
+ values_id = rm_ID_values;
148
+
149
+ // Get the struct members in an array
150
+ chrom_members = rb_funcall(chrom, values_id, 0);
151
+ red_primary = rb_ary_entry(chrom_members, 0);
152
+ green_primary = rb_ary_entry(chrom_members, 1);
153
+ blue_primary = rb_ary_entry(chrom_members, 2);
154
+ white_point = rb_ary_entry(chrom_members, 3);
155
+
156
+ // Get the red_primary PrimaryInfo members in an array
157
+ entry_members = rb_funcall(red_primary, values_id, 0);
158
+ x = rb_ary_entry(entry_members, 0); // red_primary.x
159
+ ci->red_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
160
+ y = rb_ary_entry(entry_members, 1); // red_primary.y
161
+ ci->red_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
162
+ ci->red_primary.z = 0.0;
163
+
164
+ // Get the green_primary PrimaryInfo members in an array
165
+ entry_members = rb_funcall(green_primary, values_id, 0);
166
+ x = rb_ary_entry(entry_members, 0); // green_primary.x
167
+ ci->green_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
168
+ y = rb_ary_entry(entry_members, 1); // green_primary.y
169
+ ci->green_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
170
+ ci->green_primary.z = 0.0;
171
+
172
+ // Get the blue_primary PrimaryInfo members in an array
173
+ entry_members = rb_funcall(blue_primary, values_id, 0);
174
+ x = rb_ary_entry(entry_members, 0); // blue_primary.x
175
+ ci->blue_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
176
+ y = rb_ary_entry(entry_members, 1); // blue_primary.y
177
+ ci->blue_primary.y = y == Qnil ? 0.0 : NUM2DBL(y);
178
+ ci->blue_primary.z = 0.0;
179
+
180
+ // Get the white_point PrimaryInfo members in an array
181
+ entry_members = rb_funcall(white_point, values_id, 0);
182
+ x = rb_ary_entry(entry_members, 0); // white_point.x
183
+ ci->white_point.x = x == Qnil ? 0.0 : NUM2DBL(x);
184
+ y = rb_ary_entry(entry_members, 1); // white_point.y
185
+ ci->white_point.y = y == Qnil ? 0.0 : NUM2DBL(y);
186
+ ci->white_point.z = 0.0;
187
+
188
+ RB_GC_GUARD(chrom_members);
189
+ RB_GC_GUARD(red_primary);
190
+ RB_GC_GUARD(green_primary);
191
+ RB_GC_GUARD(blue_primary);
192
+ RB_GC_GUARD(white_point);
193
+ RB_GC_GUARD(entry_members);
194
+ RB_GC_GUARD(x);
195
+ RB_GC_GUARD(y);
196
+ }
197
+
198
+
199
+ /**
200
+ * Create a string representation of a Magick::Chromaticity.
201
+ *
202
+ * Ruby usage:
203
+ * - @verbatim Magick::Chromaticity#to_s @endverbatim
204
+ *
205
+ * @param self this object
206
+ * @return the string
207
+ */
208
+ VALUE
209
+ ChromaticityInfo_to_s(VALUE self)
210
+ {
211
+ ChromaticityInfo ci;
212
+ char buff[200];
213
+
214
+ Export_ChromaticityInfo(&ci, self);
215
+ sprintf(buff, "red_primary=(x=%g,y=%g) "
216
+ "green_primary=(x=%g,y=%g) "
217
+ "blue_primary=(x=%g,y=%g) "
218
+ "white_point=(x=%g,y=%g) ",
219
+ ci.red_primary.x, ci.red_primary.y,
220
+ ci.green_primary.x, ci.green_primary.y,
221
+ ci.blue_primary.x, ci.blue_primary.y,
222
+ ci.white_point.x, ci.white_point.y);
223
+ return rb_str_new2(buff);
224
+ }
225
+
226
+
227
+ /**
228
+ * Convert a ColorInfo structure to a Magick::Color.
229
+ *
230
+ * No Ruby usage (internal function)
231
+ *
232
+ * @param ci the C ColorInfo structure
233
+ * @return a Ruby Magick::Color object
234
+ */
235
+ VALUE
236
+ Import_ColorInfo(const ColorInfo *ci)
237
+ {
238
+ ComplianceType compliance_type;
239
+ VALUE name;
240
+ VALUE compliance;
241
+ VALUE color;
242
+
243
+ name = rb_str_new2(ci->name);
244
+
245
+ compliance_type = ci->compliance;
246
+ compliance = ComplianceType_new(compliance_type);
247
+ color = Pixel_from_MagickPixelPacket(&(ci->color));
248
+
249
+ RB_GC_GUARD(name);
250
+ RB_GC_GUARD(compliance);
251
+ RB_GC_GUARD(color);
252
+
253
+ return rb_funcall(Class_Color, rm_ID_new, 3
254
+ , name, compliance, color);
255
+ }
256
+
257
+
258
+ /**
259
+ * Convert a Magick::Color to a ColorInfo structure.
260
+ *
261
+ * No Ruby usage (internal function)
262
+ *
263
+ * @param ci the C ColorInfo structure to modify
264
+ * @param st the Ruby Magick::Color object
265
+ */
266
+ void
267
+ Export_ColorInfo(ColorInfo *ci, VALUE st)
268
+ {
269
+ Pixel *pixel;
270
+ VALUE members, m;
271
+
272
+ if (CLASS_OF(st) != Class_Color)
273
+ {
274
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
275
+ rb_class2name(CLASS_OF(st)));
276
+ }
277
+
278
+ memset(ci, '\0', sizeof(ColorInfo));
279
+
280
+ members = rb_funcall(st, rm_ID_values, 0);
281
+
282
+ m = rb_ary_entry(members, 0);
283
+ if (m != Qnil)
284
+ {
285
+ (void) CloneString((char **)&(ci->name), StringValuePtr(m));
286
+ }
287
+ m = rb_ary_entry(members, 1);
288
+ if (m != Qnil)
289
+ {
290
+ VALUE_TO_ENUM(m, ci->compliance, ComplianceType);
291
+ }
292
+ m = rb_ary_entry(members, 2);
293
+ if (m != Qnil)
294
+ {
295
+ Data_Get_Struct(m, Pixel, pixel);
296
+ // For >= 6.3.0, ColorInfo.color is a MagickPixelPacket so we have to
297
+ // convert the PixelPacket.
298
+ GetMagickPixelPacket(NULL, &ci->color);
299
+ ci->color.red = (MagickRealType) pixel->red;
300
+ ci->color.green = (MagickRealType) pixel->green;
301
+ ci->color.blue = (MagickRealType) pixel->blue;
302
+ ci->color.opacity = (MagickRealType) OpaqueOpacity;
303
+ ci->color.index = (MagickRealType) 0;
304
+ }
305
+
306
+ RB_GC_GUARD(members);
307
+ RB_GC_GUARD(m);
308
+ }
309
+
310
+
311
+ /**
312
+ * Convert either a String color name or a Magick::Pixel to a MagickPixelPacket.
313
+ *
314
+ * No Ruby usage (internal function)
315
+ *
316
+ * Notes:
317
+ * - The channel values in a MagickPixelPacket are doubles.
318
+ *
319
+ * @param image the Image
320
+ * @param mpp The MagickPixelPacket to modify
321
+ * @param color the name of the color
322
+ */
323
+ void
324
+ Color_to_MagickPixelPacket(Image *image, MagickPixelPacket *mpp, VALUE color)
325
+ {
326
+ PixelPacket pp;
327
+
328
+ // image can be NULL
329
+ GetMagickPixelPacket(image, mpp);
330
+
331
+ memset(&pp, '\0', sizeof(pp));
332
+ Color_to_PixelPacket(&pp, color);
333
+ mpp->red = (MagickRealType) pp.red;
334
+ mpp->green = (MagickRealType) pp.green;
335
+ mpp->blue = (MagickRealType) pp.blue;
336
+ mpp->opacity = (MagickRealType) pp.opacity;
337
+ }
338
+
339
+
340
+ /**
341
+ * Free the storage allocated by Export_ColorInfo.
342
+ *
343
+ * No Ruby usage (internal function)
344
+ *
345
+ * @param ci the ColorInfo object
346
+ * @see Export_ColorInfo
347
+ */
348
+ static void
349
+ destroy_ColorInfo(ColorInfo *ci)
350
+ {
351
+ magick_free((void*)ci->name);
352
+ ci->name = NULL;
353
+ }
354
+
355
+
356
+ /**
357
+ * Return a string representation of a Magick::Color object.
358
+ *
359
+ * Ruby usage:
360
+ * - @verbatim Color#to_s @endverbatim
361
+ *
362
+ * @param self this object
363
+ * @return the string
364
+ */
365
+ VALUE
366
+ Color_to_s(VALUE self)
367
+ {
368
+ ColorInfo ci;
369
+ char buff[1024];
370
+
371
+ Export_ColorInfo(&ci, self);
372
+
373
+ sprintf(buff, "name=%s, compliance=%s, "
374
+ #if (MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
375
+ "color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.opacity=%Lg ",
376
+ #else
377
+ "color.red=%g, color.green=%g, color.blue=%g, color.opacity=%g ",
378
+ #endif
379
+ ci.name,
380
+ ComplianceType_name(&ci.compliance),
381
+ ci.color.red, ci.color.green, ci.color.blue, ci.color.opacity);
382
+
383
+ destroy_ColorInfo(&ci);
384
+ return rb_str_new2(buff);
385
+ }
386
+
387
+
388
+ /**
389
+ * Return the string representation of a ComplianceType value.
390
+ *
391
+ * No Ruby usage (internal function)
392
+ *
393
+ * Notes:
394
+ * - xMagick will OR multiple compliance types so we have to arbitrarily pick
395
+ * one name.
396
+ * - Set the compliance argument to the selected value.
397
+ *
398
+ * @param c the ComplianceType value
399
+ * @return the string
400
+ */
401
+ static const char *
402
+ ComplianceType_name(ComplianceType *c)
403
+ {
404
+ if ((*c & (SVGCompliance|X11Compliance|XPMCompliance))
405
+ == (SVGCompliance|X11Compliance|XPMCompliance))
406
+ {
407
+ return "AllCompliance";
408
+ }
409
+ else if (*c & SVGCompliance)
410
+ {
411
+ *c = SVGCompliance;
412
+ return "SVGCompliance";
413
+ }
414
+ else if (*c & X11Compliance)
415
+ {
416
+ *c = X11Compliance;
417
+ return "X11Compliance";
418
+ }
419
+ else if (*c & XPMCompliance)
420
+ {
421
+ *c = XPMCompliance;
422
+ return "XPMCompliance";
423
+ }
424
+ else if (*c == NoCompliance)
425
+ {
426
+ *c = NoCompliance;
427
+ return "NoCompliance";
428
+ }
429
+ else
430
+ {
431
+ *c = UndefinedCompliance;
432
+ return "UndefinedCompliance";
433
+ }
434
+ }
435
+
436
+
437
+ /**
438
+ * Construct a ComplianceType enum object for the specified value.
439
+ *
440
+ * No Ruby usage (internal function)
441
+ *
442
+ * @param compliance the C ComplianceType value
443
+ * @return the Ruby ComplianceType enum object
444
+ */
445
+ static VALUE
446
+ ComplianceType_new(ComplianceType compliance)
447
+ {
448
+ const char *name;
449
+
450
+ // Turn off undefined bits
451
+ compliance &= (SVGCompliance|X11Compliance|XPMCompliance);
452
+ name = ComplianceType_name(&compliance);
453
+ return rm_enum_new(Class_ComplianceType, ID2SYM(rb_intern(name)), INT2FIX(compliance));
454
+ }
455
+
456
+
457
+ /**
458
+ * Convert a TypeInfo structure to a Magick::Font.
459
+ *
460
+ * No Ruby usage (internal function)
461
+ *
462
+ * @param ti the C TypeInfo structure
463
+ * @return a Ruby Magick::Font object
464
+ */
465
+ VALUE
466
+ Import_TypeInfo(const TypeInfo *ti)
467
+ {
468
+ VALUE name, description, family;
469
+ VALUE style, stretch, weight;
470
+ VALUE encoding, foundry, format;
471
+
472
+ name = rb_str_new2(ti->name);
473
+ family = rb_str_new2(ti->family);
474
+ style = StyleType_new(ti->style);
475
+ stretch = StretchType_new(ti->stretch);
476
+ weight = ULONG2NUM(ti->weight);
477
+ description = ti->description ? rb_str_new2(ti->description) : Qnil;
478
+ encoding = ti->encoding ? rb_str_new2(ti->encoding) : Qnil;
479
+ foundry = ti->foundry ? rb_str_new2(ti->foundry) : Qnil;
480
+ format = ti->format ? rb_str_new2(ti->format) : Qnil;
481
+
482
+ RB_GC_GUARD(name);
483
+ RB_GC_GUARD(description);
484
+ RB_GC_GUARD(family);
485
+ RB_GC_GUARD(style);
486
+ RB_GC_GUARD(stretch);
487
+ RB_GC_GUARD(weight);
488
+ RB_GC_GUARD(encoding);
489
+ RB_GC_GUARD(foundry);
490
+ RB_GC_GUARD(format);
491
+
492
+ return rb_funcall(Class_Font, rm_ID_new, 9
493
+ , name, description, family, style
494
+ , stretch, weight, encoding, foundry, format);
495
+ }
496
+
497
+
498
+ /**
499
+ * Convert a Magick::Font to a TypeInfo structure.
500
+ *
501
+ * No Ruby usage (internal function)
502
+ *
503
+ * @param ti the C TypeInfo structure to modify
504
+ * @param st the Ruby Magick::Font object
505
+ */
506
+ void
507
+ Export_TypeInfo(TypeInfo *ti, VALUE st)
508
+ {
509
+ VALUE members, m;
510
+
511
+ if (CLASS_OF(st) != Class_Font)
512
+ {
513
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
514
+ rb_class2name(CLASS_OF(st)));
515
+ }
516
+
517
+ memset(ti, '\0', sizeof(TypeInfo));
518
+
519
+ members = rb_funcall(st, rm_ID_values, 0);
520
+ m = rb_ary_entry(members, 0);
521
+ if (m != Qnil)
522
+ {
523
+ (void) CloneString((char **)&(ti->name), StringValuePtr(m));
524
+ }
525
+ m = rb_ary_entry(members, 1);
526
+ if (m != Qnil)
527
+ {
528
+ (void) CloneString((char **)&(ti->description), StringValuePtr(m));
529
+ }
530
+ m = rb_ary_entry(members, 2);
531
+ if (m != Qnil)
532
+ {
533
+ (void) CloneString((char **)&(ti->family), StringValuePtr(m));
534
+ }
535
+ m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(m);
536
+ m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(m);
537
+ m = rb_ary_entry(members, 5); ti->weight = m == Qnil ? 0 : FIX2INT(m);
538
+
539
+ m = rb_ary_entry(members, 6);
540
+ if (m != Qnil)
541
+ (void) CloneString((char **)&(ti->encoding), StringValuePtr(m));
542
+ m = rb_ary_entry(members, 7);
543
+ if (m != Qnil)
544
+ (void) CloneString((char **)&(ti->foundry), StringValuePtr(m));
545
+ m = rb_ary_entry(members, 8);
546
+ if (m != Qnil)
547
+ (void) CloneString((char **)&(ti->format), StringValuePtr(m));
548
+
549
+ RB_GC_GUARD(members);
550
+ RB_GC_GUARD(m);
551
+ }
552
+
553
+
554
+ /**
555
+ * Free the storage allocated by Export_TypeInfo.
556
+ *
557
+ * No Ruby usage (internal function)
558
+ *
559
+ * @param ti the TypeInfo object
560
+ * @see Export_TypeInfo
561
+ */
562
+ static void
563
+ destroy_TypeInfo(TypeInfo *ti)
564
+ {
565
+ magick_free((void*)ti->name);
566
+ ti->name = NULL;
567
+ magick_free((void*)ti->description);
568
+ ti->description = NULL;
569
+ magick_free((void*)ti->family);
570
+ ti->family = NULL;
571
+ magick_free((void*)ti->encoding);
572
+ ti->encoding = NULL;
573
+ magick_free((void*)ti->foundry);
574
+ ti->foundry = NULL;
575
+ magick_free((void*)ti->format);
576
+ ti->format = NULL;
577
+ }
578
+
579
+
580
+ /**
581
+ * Implement the Font#to_s method.
582
+ *
583
+ * No Ruby usage (internal function)
584
+ *
585
+ * @param self this object
586
+ * @return the string
587
+ */
588
+ VALUE
589
+ Font_to_s(VALUE self)
590
+ {
591
+ TypeInfo ti;
592
+ char weight[20];
593
+ char buff[1024];
594
+
595
+ Export_TypeInfo(&ti, self);
596
+
597
+ switch (ti.weight)
598
+ {
599
+ case 400:
600
+ strcpy(weight, "NormalWeight");
601
+ break;
602
+ case 700:
603
+ strcpy(weight, "BoldWeight");
604
+ break;
605
+ default:
606
+ sprintf(weight, "%lu", ti.weight);
607
+ break;
608
+ }
609
+
610
+ sprintf(buff, "name=%s, description=%s, "
611
+ "family=%s, style=%s, stretch=%s, weight=%s, "
612
+ "encoding=%s, foundry=%s, format=%s",
613
+ ti.name,
614
+ ti.description,
615
+ ti.family,
616
+ StyleType_name(ti.style),
617
+ StretchType_name(ti.stretch),
618
+ weight,
619
+ ti.encoding ? ti.encoding : "",
620
+ ti.foundry ? ti.foundry : "",
621
+ ti.format ? ti.format : "");
622
+
623
+ destroy_TypeInfo(&ti);
624
+ return rb_str_new2(buff);
625
+
626
+ }
627
+
628
+
629
+ /**
630
+ * Create a Magick::Point object from a PointInfo structure.
631
+ *
632
+ * No Ruby usage (internal function)
633
+ *
634
+ * @param p the C PointInfo structure
635
+ * @return a Ruby Magick::Point object
636
+ */
637
+ VALUE
638
+ Import_PointInfo(PointInfo *p)
639
+ {
640
+ return rb_funcall(Class_Point, rm_ID_new, 2
641
+ , INT2FIX(p->x), INT2FIX(p->y));
642
+ }
643
+
644
+
645
+ /**
646
+ * Convert a Magick::Point object to a PointInfo structure.
647
+ *
648
+ * No Ruby usage (internal function)
649
+ *
650
+ * @param pi the C PointInfo structure to modify
651
+ * @param sp the Ruby Magick::Point object
652
+ */
653
+ void
654
+ Export_PointInfo(PointInfo *pi, VALUE sp)
655
+ {
656
+ VALUE members, m;
657
+
658
+ if (CLASS_OF(sp) != Class_Point)
659
+ {
660
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
661
+ rb_class2name(CLASS_OF(sp)));
662
+ }
663
+ members = rb_funcall(sp, rm_ID_values, 0);
664
+ m = rb_ary_entry(members, 0);
665
+ pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
666
+ m = rb_ary_entry(members, 1);
667
+ pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
668
+
669
+ RB_GC_GUARD(members);
670
+ RB_GC_GUARD(m);
671
+ }
672
+
673
+
674
+ /**
675
+ * Create a Magick::PrimaryInfo object from a PrimaryInfo structure.
676
+ *
677
+ * No Ruby usage (internal function)
678
+ *
679
+ * @param p the C PrimaryInfo structure
680
+ * @return a Ruby Magick::PrimaryInfo object
681
+ */
682
+ VALUE
683
+ Import_PrimaryInfo(PrimaryInfo *p)
684
+ {
685
+ return rb_funcall(Class_Primary, rm_ID_new, 3
686
+ , INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
687
+ }
688
+
689
+
690
+ /**
691
+ * Convert a Magick::PrimaryInfo object to a PrimaryInfo structure.
692
+ *
693
+ * No Ruby usage (internal function)
694
+ *
695
+ * @param pi the C PrimaryInfo structure to modify
696
+ * @param sp the Ruby Magick::PrimaryInfo object
697
+ */
698
+ void
699
+ Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
700
+ {
701
+ VALUE members, m;
702
+
703
+ if (CLASS_OF(sp) != Class_Primary)
704
+ {
705
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
706
+ rb_class2name(CLASS_OF(sp)));
707
+ }
708
+ members = rb_funcall(sp, rm_ID_values, 0);
709
+ m = rb_ary_entry(members, 0);
710
+ pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
711
+ m = rb_ary_entry(members, 1);
712
+ pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
713
+ m = rb_ary_entry(members, 2);
714
+ pi->z = m == Qnil ? 0.0 : NUM2DBL(m);
715
+
716
+ RB_GC_GUARD(members);
717
+ RB_GC_GUARD(m);
718
+ }
719
+
720
+
721
+ /**
722
+ * Create a string representation of a Magick::PrimaryInfo.
723
+ *
724
+ * Ruby usage:
725
+ * - @verbatim Magick::PrimaryInfo#to_s @endverbatim
726
+ *
727
+ * @param self this object
728
+ * @return the string
729
+ */
730
+ VALUE
731
+ PrimaryInfo_to_s(VALUE self)
732
+ {
733
+ PrimaryInfo pi;
734
+ char buff[100];
735
+
736
+ Export_PrimaryInfo(&pi, self);
737
+ sprintf(buff, "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
738
+ return rb_str_new2(buff);
739
+ }
740
+
741
+
742
+ /**
743
+ * Convert a RectangleInfo structure to a Magick::Rectangle.
744
+ *
745
+ * No Ruby usage (internal function)
746
+ *
747
+ * @param rect the C RectangleInfo structure
748
+ * @return a Ruby Magick::Rectangle object
749
+ */
750
+ VALUE
751
+ Import_RectangleInfo(RectangleInfo *rect)
752
+ {
753
+ VALUE width;
754
+ VALUE height;
755
+ VALUE x, y;
756
+
757
+ width = UINT2NUM(rect->width);
758
+ height = UINT2NUM(rect->height);
759
+ x = INT2NUM(rect->x);
760
+ y = INT2NUM(rect->y);
761
+
762
+ RB_GC_GUARD(width);
763
+ RB_GC_GUARD(height);
764
+ RB_GC_GUARD(x);
765
+ RB_GC_GUARD(y);
766
+
767
+ return rb_funcall(Class_Rectangle, rm_ID_new, 4
768
+ , width, height, x, y);
769
+ }
770
+
771
+
772
+ /**
773
+ * Convert a Magick::Rectangle to a RectangleInfo structure.
774
+ *
775
+ * No Ruby usage (internal function)
776
+ *
777
+ * @param rect the C RectangleInfo structure to modify
778
+ * @param sr the Ruby Magick::Rectangle object
779
+ */
780
+ void
781
+ Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
782
+ {
783
+ VALUE members, m;
784
+
785
+ if (CLASS_OF(sr) != Class_Rectangle)
786
+ {
787
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
788
+ rb_class2name(CLASS_OF(sr)));
789
+ }
790
+ members = rb_funcall(sr, rm_ID_values, 0);
791
+ m = rb_ary_entry(members, 0);
792
+ rect->width = m == Qnil ? 0 : NUM2ULONG(m);
793
+ m = rb_ary_entry(members, 1);
794
+ rect->height = m == Qnil ? 0 : NUM2ULONG(m);
795
+ m = rb_ary_entry(members, 2);
796
+ rect->x = m == Qnil ? 0 : NUM2LONG (m);
797
+ m = rb_ary_entry(members, 3);
798
+ rect->y = m == Qnil ? 0 : NUM2LONG (m);
799
+
800
+ RB_GC_GUARD(members);
801
+ RB_GC_GUARD(m);
802
+ }
803
+
804
+
805
+ /**
806
+ * Create a string representation of a Magick::Rectangle.
807
+ *
808
+ * Ruby usage:
809
+ * - @verbatim Magick::Rectangle#to_s @endverbatim
810
+ *
811
+ * @param self this object
812
+ * @return the string
813
+ */
814
+ VALUE
815
+ RectangleInfo_to_s(VALUE self)
816
+ {
817
+ RectangleInfo rect;
818
+ char buff[100];
819
+
820
+ Export_RectangleInfo(&rect, self);
821
+ sprintf(buff, "width=%lu, height=%lu, x=%ld, y=%ld"
822
+ , rect.width, rect.height, rect.x, rect.y);
823
+ return rb_str_new2(buff);
824
+ }
825
+
826
+
827
+ /**
828
+ * Convert a SegmentInfo structure to a Magick::Segment.
829
+ *
830
+ * No Ruby usage (internal function)
831
+ *
832
+ * @param segment the C SegmentInfo structure
833
+ * @return a Ruby Magick::Segment object
834
+ */
835
+ VALUE
836
+ Import_SegmentInfo(SegmentInfo *segment)
837
+ {
838
+ VALUE x1, y1, x2, y2;
839
+
840
+ x1 = rb_float_new(segment->x1);
841
+ y1 = rb_float_new(segment->y1);
842
+ x2 = rb_float_new(segment->x2);
843
+ y2 = rb_float_new(segment->y2);
844
+
845
+ RB_GC_GUARD(x1);
846
+ RB_GC_GUARD(y1);
847
+ RB_GC_GUARD(x2);
848
+ RB_GC_GUARD(y2);
849
+
850
+ return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
851
+ }
852
+
853
+
854
+ /**
855
+ * Convert a Magick::Segment to a SegmentInfo structure.
856
+ *
857
+ * No Ruby usage (internal function)
858
+ *
859
+ * @param segment the C SegmentInfo structure to modify
860
+ * @param s the Ruby Magick::Segment object
861
+ */
862
+ void
863
+ Export_SegmentInfo(SegmentInfo *segment, VALUE s)
864
+ {
865
+ VALUE members, m;
866
+
867
+ if (CLASS_OF(s) != Class_Segment)
868
+ {
869
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
870
+ rb_class2name(CLASS_OF(s)));
871
+ }
872
+
873
+ members = rb_funcall(s, rm_ID_values, 0);
874
+ m = rb_ary_entry(members, 0);
875
+ segment->x1 = m == Qnil ? 0.0 : NUM2DBL(m);
876
+ m = rb_ary_entry(members, 1);
877
+ segment->y1 = m == Qnil ? 0.0 : NUM2DBL(m);
878
+ m = rb_ary_entry(members, 2);
879
+ segment->x2 = m == Qnil ? 0.0 : NUM2DBL(m);
880
+ m = rb_ary_entry(members, 3);
881
+ segment->y2 = m == Qnil ? 0.0 : NUM2DBL(m);
882
+
883
+ RB_GC_GUARD(members);
884
+ RB_GC_GUARD(m);
885
+ }
886
+
887
+
888
+ /**
889
+ * Create a string representation of a Magick::Segment.
890
+ *
891
+ * Ruby usage:
892
+ * - @verbatim Magick::SegmentInfo#to_s @endverbatim
893
+ *
894
+ * @param self this object
895
+ * @return the string
896
+ */
897
+ VALUE
898
+ SegmentInfo_to_s(VALUE self)
899
+ {
900
+ SegmentInfo segment;
901
+ char buff[100];
902
+
903
+ Export_SegmentInfo(&segment, self);
904
+ sprintf(buff, "x1=%g, y1=%g, x2=%g, y2=%g"
905
+ , segment.x1, segment.y1, segment.x2, segment.y2);
906
+ return rb_str_new2(buff);
907
+ }
908
+
909
+
910
+ /**
911
+ * Return the string representation of a StretchType value.
912
+ *
913
+ * No Ruby usage (internal function)
914
+ *
915
+ * @param stretch the StretchType value
916
+ * @return the string
917
+ */
918
+ static const char *
919
+ StretchType_name(StretchType stretch)
920
+ {
921
+ switch (stretch)
922
+ {
923
+ ENUM_TO_NAME(UndefinedStretch)
924
+ ENUM_TO_NAME(NormalStretch)
925
+ ENUM_TO_NAME(UltraCondensedStretch)
926
+ ENUM_TO_NAME(ExtraCondensedStretch)
927
+ ENUM_TO_NAME(CondensedStretch)
928
+ ENUM_TO_NAME(SemiCondensedStretch)
929
+ ENUM_TO_NAME(SemiExpandedStretch)
930
+ ENUM_TO_NAME(ExpandedStretch)
931
+ ENUM_TO_NAME(ExtraExpandedStretch)
932
+ ENUM_TO_NAME(UltraExpandedStretch)
933
+ ENUM_TO_NAME(AnyStretch)
934
+ }
935
+
936
+ return "UndefinedStretch";
937
+ }
938
+
939
+
940
+ /**
941
+ * Construct a StretchType enum for a specified StretchType value.
942
+ *
943
+ * No Ruby usage (internal function)
944
+ *
945
+ * @param stretch the C StretchType value
946
+ * @return a Ruby StretchType enum
947
+ */
948
+ static VALUE
949
+ StretchType_new(StretchType stretch)
950
+ {
951
+ const char *name = StretchType_name(stretch);
952
+ return rm_enum_new(Class_StretchType, ID2SYM(rb_intern(name)), INT2FIX(stretch));
953
+ }
954
+
955
+
956
+ /**
957
+ * Return the string representation of a StyleType value.
958
+ *
959
+ * No Ruby usage (internal function)
960
+ *
961
+ * @param style the StyleType value
962
+ * @return the string
963
+ */
964
+ static const char *
965
+ StyleType_name(StyleType style)
966
+ {
967
+ switch (style)
968
+ {
969
+ ENUM_TO_NAME(UndefinedStyle)
970
+ ENUM_TO_NAME(NormalStyle)
971
+ ENUM_TO_NAME(ItalicStyle)
972
+ ENUM_TO_NAME(ObliqueStyle)
973
+ ENUM_TO_NAME(AnyStyle)
974
+ }
975
+
976
+ return "UndefinedStyle";
977
+ }
978
+
979
+
980
+ /**
981
+ * Construct a StyleType enum for a specified StyleType value.
982
+ *
983
+ * No Ruby usage (internal function)
984
+ *
985
+ * @param style the C StyleType value
986
+ * @return a Ruby StyleType enum
987
+ */
988
+ static VALUE
989
+ StyleType_new(StyleType style)
990
+ {
991
+ const char *name = StyleType_name(style);
992
+ return rm_enum_new(Class_StyleType, ID2SYM(rb_intern(name)), INT2FIX(style));
993
+ }
994
+
995
+
996
+ /**
997
+ * Convert a TypeMetric structure to a Magick::TypeMetric.
998
+ *
999
+ * No Ruby usage (internal function)
1000
+ *
1001
+ * @param tm the C TypeMetric structure
1002
+ * @return a Ruby Magick::TypeMetric object
1003
+ */
1004
+ VALUE
1005
+ Import_TypeMetric(TypeMetric *tm)
1006
+ {
1007
+ VALUE pixels_per_em;
1008
+ VALUE ascent, descent;
1009
+ VALUE width, height, max_advance;
1010
+ VALUE bounds, underline_position, underline_thickness;
1011
+
1012
+ pixels_per_em = Import_PointInfo(&tm->pixels_per_em);
1013
+ ascent = rb_float_new(tm->ascent);
1014
+ descent = rb_float_new(tm->descent);
1015
+ width = rb_float_new(tm->width);
1016
+ height = rb_float_new(tm->height);
1017
+ max_advance = rb_float_new(tm->max_advance);
1018
+ bounds = Import_SegmentInfo(&tm->bounds);
1019
+ underline_position = rb_float_new(tm->underline_position);
1020
+ underline_thickness = rb_float_new(tm->underline_position);
1021
+
1022
+ RB_GC_GUARD(pixels_per_em);
1023
+ RB_GC_GUARD(ascent);
1024
+ RB_GC_GUARD(descent);
1025
+ RB_GC_GUARD(width);
1026
+ RB_GC_GUARD(height);
1027
+ RB_GC_GUARD(max_advance);
1028
+ RB_GC_GUARD(bounds);
1029
+ RB_GC_GUARD(underline_position);
1030
+ RB_GC_GUARD(underline_thickness);
1031
+
1032
+ return rb_funcall(Class_TypeMetric, rm_ID_new, 9
1033
+ , pixels_per_em, ascent, descent, width
1034
+ , height, max_advance, bounds
1035
+ , underline_position, underline_thickness);
1036
+ }
1037
+
1038
+
1039
+ /**
1040
+ * Convert a Magick::TypeMetric to a TypeMetric structure.
1041
+ *
1042
+ * No Ruby usage (internal function)
1043
+ *
1044
+ * @param tm the C TypeMetric structure to modify
1045
+ * @param st the Ruby Magick::TypeMetric object
1046
+ */
1047
+ void
1048
+ Export_TypeMetric(TypeMetric *tm, VALUE st)
1049
+ {
1050
+ VALUE members, m;
1051
+ VALUE pixels_per_em;
1052
+
1053
+ if (CLASS_OF(st) != Class_TypeMetric)
1054
+ {
1055
+ rb_raise(rb_eTypeError, "type mismatch: %s given",
1056
+ rb_class2name(CLASS_OF(st)));
1057
+ }
1058
+ members = rb_funcall(st, rm_ID_values, 0);
1059
+
1060
+ pixels_per_em = rb_ary_entry(members, 0);
1061
+ Export_PointInfo(&tm->pixels_per_em, pixels_per_em);
1062
+
1063
+ m = rb_ary_entry(members, 1);
1064
+ tm->ascent = m == Qnil ? 0.0 : NUM2DBL(m);
1065
+ m = rb_ary_entry(members, 2);
1066
+ tm->descent = m == Qnil ? 0.0 : NUM2DBL(m);
1067
+ m = rb_ary_entry(members, 3);
1068
+ tm->width = m == Qnil ? 0.0 : NUM2DBL(m);
1069
+ m = rb_ary_entry(members, 4);
1070
+ tm->height = m == Qnil ? 0.0 : NUM2DBL(m);
1071
+ m = rb_ary_entry(members, 5);
1072
+ tm->max_advance = m == Qnil ? 0.0 : NUM2DBL(m);
1073
+
1074
+ m = rb_ary_entry(members, 6);
1075
+ Export_SegmentInfo(&tm->bounds, m);
1076
+
1077
+ m = rb_ary_entry(members, 7);
1078
+ tm->underline_position = m == Qnil ? 0.0 : NUM2DBL(m);
1079
+ m = rb_ary_entry(members, 8);
1080
+ tm->underline_thickness = m == Qnil ? 0.0 : NUM2DBL(m);
1081
+
1082
+ RB_GC_GUARD(members);
1083
+ RB_GC_GUARD(m);
1084
+ RB_GC_GUARD(pixels_per_em);
1085
+ }
1086
+
1087
+
1088
+ /**
1089
+ * Create a string representation of a Magick::TypeMetric.
1090
+ *
1091
+ * Ruby usage:
1092
+ * - @verbatim Magick::TypeMetric#to_s @endverbatim
1093
+ *
1094
+ * @param self this object
1095
+ * @return the string
1096
+ */
1097
+ VALUE
1098
+ TypeMetric_to_s(VALUE self)
1099
+ {
1100
+ VALUE str;
1101
+ TypeMetric tm;
1102
+ char temp[200];
1103
+ int len;
1104
+
1105
+ Export_TypeMetric(&tm, self);
1106
+
1107
+ len = sprintf(temp, "pixels_per_em=(x=%g,y=%g) ", tm.pixels_per_em.x, tm.pixels_per_em.y);
1108
+ str = rb_str_new(temp, len);
1109
+ len = sprintf(temp, "ascent=%g descent=%g ",tm.ascent, tm.descent);
1110
+ rb_str_cat(str, temp, len);
1111
+ len = sprintf(temp, "width=%g height=%g max_advance=%g ", tm.width, tm.height, tm.max_advance);
1112
+ rb_str_cat(str, temp, len);
1113
+ len = sprintf(temp, "bounds.x1=%g bounds.y1=%g ", tm.bounds.x1, tm.bounds.y1);
1114
+ rb_str_cat(str, temp, len);
1115
+ len = sprintf(temp, "bounds.x2=%g bounds.y2=%g ", tm.bounds.x2, tm.bounds.y2);
1116
+ rb_str_cat(str, temp, len);
1117
+ len = sprintf(temp, "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
1118
+ rb_str_cat(str, temp, len);
1119
+
1120
+ RB_GC_GUARD(str);
1121
+
1122
+ return str;
1123
+ }
1124
+