rmagick 2.16.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (405) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +63 -0
  3. data/.devcontainer/Dockerfile +14 -0
  4. data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
  5. data/.devcontainer/devcontainer.json +11 -0
  6. data/.devcontainer/setup-repo.sh +10 -0
  7. data/.devcontainer/setup-user.sh +45 -0
  8. data/.editorconfig +3 -0
  9. data/.github/ISSUE_TEMPLATE.md +17 -0
  10. data/.github/workflows/ci.yml +79 -0
  11. data/.gitignore +5 -1
  12. data/.rspec +1 -0
  13. data/.rubocop.yml +37 -340
  14. data/.rubocop_todo.yml +448 -0
  15. data/.yardopts +5 -0
  16. data/CHANGELOG.md +435 -0
  17. data/CODE_OF_CONDUCT.md +122 -7
  18. data/CONTRIBUTING.md +37 -6
  19. data/Gemfile +0 -6
  20. data/README.md +317 -0
  21. data/Rakefile +37 -35
  22. data/before_install_linux.sh +65 -28
  23. data/before_install_osx.sh +58 -2
  24. data/ext/RMagick/extconf.rb +286 -393
  25. data/ext/RMagick/rmagick.c +106 -111
  26. data/ext/RMagick/rmagick.h +235 -331
  27. data/ext/RMagick/rmagick_gvl.h +224 -0
  28. data/ext/RMagick/rmdraw.c +484 -842
  29. data/ext/RMagick/rmenum.c +316 -755
  30. data/ext/RMagick/rmfill.c +281 -191
  31. data/ext/RMagick/rmilist.c +450 -455
  32. data/ext/RMagick/rmimage.c +6247 -5289
  33. data/ext/RMagick/rminfo.c +721 -894
  34. data/ext/RMagick/rmkinfo.c +228 -0
  35. data/ext/RMagick/rmmain.c +727 -519
  36. data/ext/RMagick/rmmontage.c +127 -172
  37. data/ext/RMagick/rmpixel.c +638 -431
  38. data/ext/RMagick/rmstruct.c +102 -282
  39. data/ext/RMagick/rmutil.c +450 -363
  40. data/lib/rmagick/version.rb +5 -4
  41. data/lib/rmagick.rb +2 -0
  42. data/lib/rmagick_internal.rb +349 -413
  43. data/lib/rvg/clippath.rb +3 -4
  44. data/lib/rvg/container.rb +30 -22
  45. data/lib/rvg/deep_equal.rb +11 -11
  46. data/lib/rvg/describable.rb +2 -2
  47. data/lib/rvg/embellishable.rb +63 -68
  48. data/lib/rvg/misc.rb +136 -139
  49. data/lib/rvg/paint.rb +2 -1
  50. data/lib/rvg/pathdata.rb +7 -8
  51. data/lib/rvg/rvg.rb +47 -46
  52. data/lib/rvg/stretchable.rb +22 -28
  53. data/lib/rvg/stylable.rb +12 -10
  54. data/lib/rvg/text.rb +169 -165
  55. data/lib/rvg/transformable.rb +17 -16
  56. data/lib/rvg/units.rb +5 -5
  57. data/rmagick.gemspec +16 -39
  58. metadata +118 -395
  59. data/.hound.yml +0 -2
  60. data/.simplecov +0 -27
  61. data/.travis.yml +0 -74
  62. data/Doxyfile +0 -1514
  63. data/README.textile +0 -251
  64. data/deprecated/RMagick.rb +0 -6
  65. data/doc/.cvsignore +0 -1
  66. data/doc/comtasks.html +0 -287
  67. data/doc/constants.html +0 -1581
  68. data/doc/css/doc.css +0 -299
  69. data/doc/css/popup.css +0 -34
  70. data/doc/css/ref.css +0 -67
  71. data/doc/draw.html +0 -3272
  72. data/doc/ex/InitialCoords.rb +0 -22
  73. data/doc/ex/NewCoordSys.rb +0 -30
  74. data/doc/ex/OrigCoordSys.rb +0 -16
  75. data/doc/ex/PreserveAspectRatio.rb +0 -204
  76. data/doc/ex/RotateScale.rb +0 -36
  77. data/doc/ex/Skew.rb +0 -38
  78. data/doc/ex/Use01.rb +0 -15
  79. data/doc/ex/Use02.rb +0 -20
  80. data/doc/ex/Use03.rb +0 -16
  81. data/doc/ex/ViewBox.rb +0 -31
  82. data/doc/ex/adaptive_threshold.rb +0 -9
  83. data/doc/ex/add_noise.rb +0 -16
  84. data/doc/ex/affine.rb +0 -48
  85. data/doc/ex/affine_transform.rb +0 -20
  86. data/doc/ex/arc.rb +0 -49
  87. data/doc/ex/arcpath.rb +0 -32
  88. data/doc/ex/arcs01.rb +0 -28
  89. data/doc/ex/arcs02.rb +0 -59
  90. data/doc/ex/average.rb +0 -15
  91. data/doc/ex/axes.rb +0 -64
  92. data/doc/ex/baseline_shift01.rb +0 -17
  93. data/doc/ex/bilevel_channel.rb +0 -8
  94. data/doc/ex/blur_image.rb +0 -12
  95. data/doc/ex/border.rb +0 -10
  96. data/doc/ex/bounding_box.rb +0 -42
  97. data/doc/ex/cbezier1.rb +0 -41
  98. data/doc/ex/cbezier2.rb +0 -41
  99. data/doc/ex/cbezier3.rb +0 -41
  100. data/doc/ex/cbezier4.rb +0 -42
  101. data/doc/ex/cbezier5.rb +0 -42
  102. data/doc/ex/cbezier6.rb +0 -53
  103. data/doc/ex/channel.rb +0 -25
  104. data/doc/ex/charcoal.rb +0 -12
  105. data/doc/ex/chop.rb +0 -29
  106. data/doc/ex/circle.rb +0 -33
  107. data/doc/ex/circle01.rb +0 -16
  108. data/doc/ex/clip_path.rb +0 -60
  109. data/doc/ex/coalesce.rb +0 -57
  110. data/doc/ex/color_fill_to_border.rb +0 -29
  111. data/doc/ex/color_floodfill.rb +0 -28
  112. data/doc/ex/color_histogram.rb +0 -47
  113. data/doc/ex/color_reset.rb +0 -11
  114. data/doc/ex/colorize.rb +0 -16
  115. data/doc/ex/colors.rb +0 -64
  116. data/doc/ex/compose_mask.rb +0 -22
  117. data/doc/ex/composite.rb +0 -133
  118. data/doc/ex/composite_layers.rb +0 -53
  119. data/doc/ex/composite_tiled.rb +0 -21
  120. data/doc/ex/contrast.rb +0 -36
  121. data/doc/ex/crop.rb +0 -31
  122. data/doc/ex/crop_with_gravity.rb +0 -42
  123. data/doc/ex/cubic01.rb +0 -43
  124. data/doc/ex/cubic02.rb +0 -91
  125. data/doc/ex/cycle_colormap.rb +0 -21
  126. data/doc/ex/dissolve.rb +0 -12
  127. data/doc/ex/drawcomp.rb +0 -42
  128. data/doc/ex/drop_shadow.rb +0 -60
  129. data/doc/ex/edge.rb +0 -11
  130. data/doc/ex/ellipse.rb +0 -45
  131. data/doc/ex/ellipse01.rb +0 -21
  132. data/doc/ex/emboss.rb +0 -11
  133. data/doc/ex/enhance.rb +0 -28
  134. data/doc/ex/equalize.rb +0 -11
  135. data/doc/ex/evenodd.rb +0 -42
  136. data/doc/ex/fill_pattern.rb +0 -23
  137. data/doc/ex/flatten_images.rb +0 -36
  138. data/doc/ex/flip.rb +0 -11
  139. data/doc/ex/flop.rb +0 -11
  140. data/doc/ex/font_styles.rb +0 -32
  141. data/doc/ex/fonts.rb +0 -20
  142. data/doc/ex/frame.rb +0 -12
  143. data/doc/ex/gaussian_blur.rb +0 -11
  144. data/doc/ex/get_multiline_type_metrics.rb +0 -41
  145. data/doc/ex/get_pixels.rb +0 -47
  146. data/doc/ex/get_type_metrics.rb +0 -141
  147. data/doc/ex/gradientfill.rb +0 -27
  148. data/doc/ex/grav.rb +0 -45
  149. data/doc/ex/gravity.rb +0 -80
  150. data/doc/ex/group.rb +0 -26
  151. data/doc/ex/hatchfill.rb +0 -27
  152. data/doc/ex/image.rb +0 -44
  153. data/doc/ex/images/Apple.miff +0 -0
  154. data/doc/ex/images/Ballerina.jpg +0 -0
  155. data/doc/ex/images/Ballerina3.jpg +0 -0
  156. data/doc/ex/images/Button_0.gif +0 -0
  157. data/doc/ex/images/Button_1.gif +0 -0
  158. data/doc/ex/images/Button_2.gif +0 -0
  159. data/doc/ex/images/Button_3.gif +0 -0
  160. data/doc/ex/images/Button_4.gif +0 -0
  161. data/doc/ex/images/Button_5.gif +0 -0
  162. data/doc/ex/images/Button_6.gif +0 -0
  163. data/doc/ex/images/Button_7.gif +0 -0
  164. data/doc/ex/images/Button_8.gif +0 -0
  165. data/doc/ex/images/Button_9.gif +0 -0
  166. data/doc/ex/images/Button_A.gif +0 -0
  167. data/doc/ex/images/Button_B.gif +0 -0
  168. data/doc/ex/images/Button_C.gif +0 -0
  169. data/doc/ex/images/Button_D.gif +0 -0
  170. data/doc/ex/images/Button_E.gif +0 -0
  171. data/doc/ex/images/Button_F.gif +0 -0
  172. data/doc/ex/images/Button_G.gif +0 -0
  173. data/doc/ex/images/Button_H.gif +0 -0
  174. data/doc/ex/images/Button_I.gif +0 -0
  175. data/doc/ex/images/Button_J.gif +0 -0
  176. data/doc/ex/images/Button_K.gif +0 -0
  177. data/doc/ex/images/Button_L.gif +0 -0
  178. data/doc/ex/images/Button_M.gif +0 -0
  179. data/doc/ex/images/Button_N.gif +0 -0
  180. data/doc/ex/images/Button_O.gif +0 -0
  181. data/doc/ex/images/Button_P.gif +0 -0
  182. data/doc/ex/images/Button_Q.gif +0 -0
  183. data/doc/ex/images/Button_R.gif +0 -0
  184. data/doc/ex/images/Button_S.gif +0 -0
  185. data/doc/ex/images/Button_T.gif +0 -0
  186. data/doc/ex/images/Button_U.gif +0 -0
  187. data/doc/ex/images/Button_V.gif +0 -0
  188. data/doc/ex/images/Button_W.gif +0 -0
  189. data/doc/ex/images/Button_X.gif +0 -0
  190. data/doc/ex/images/Button_Y.gif +0 -0
  191. data/doc/ex/images/Button_Z.gif +0 -0
  192. data/doc/ex/images/Cheetah.jpg +0 -0
  193. data/doc/ex/images/Coffee.wmf +0 -0
  194. data/doc/ex/images/Flower_Hat.jpg +0 -0
  195. data/doc/ex/images/Gold_Statue.jpg +0 -0
  196. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  197. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  198. data/doc/ex/images/Leaf.miff +0 -0
  199. data/doc/ex/images/No.wmf +0 -0
  200. data/doc/ex/images/Polynesia.jpg +0 -0
  201. data/doc/ex/images/Red_Rocks.jpg +0 -0
  202. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  203. data/doc/ex/images/Shorts.jpg +0 -0
  204. data/doc/ex/images/Snake.wmf +0 -0
  205. data/doc/ex/images/Violin.jpg +0 -0
  206. data/doc/ex/images/Yellow_Rose.miff +0 -0
  207. data/doc/ex/images/big-duck.gif +0 -0
  208. data/doc/ex/images/duck.gif +0 -0
  209. data/doc/ex/images/duck0.gif +0 -0
  210. data/doc/ex/images/duck1.gif +0 -0
  211. data/doc/ex/images/duck10.gif +0 -0
  212. data/doc/ex/images/duck11.gif +0 -0
  213. data/doc/ex/images/duck12.gif +0 -0
  214. data/doc/ex/images/duck13.gif +0 -0
  215. data/doc/ex/images/duck14.gif +0 -0
  216. data/doc/ex/images/duck15.gif +0 -0
  217. data/doc/ex/images/duck2.gif +0 -0
  218. data/doc/ex/images/duck3.gif +0 -0
  219. data/doc/ex/images/duck4.gif +0 -0
  220. data/doc/ex/images/duck5.gif +0 -0
  221. data/doc/ex/images/duck6.gif +0 -0
  222. data/doc/ex/images/duck7.gif +0 -0
  223. data/doc/ex/images/duck8.gif +0 -0
  224. data/doc/ex/images/duck9.gif +0 -0
  225. data/doc/ex/images/graydient230x6.gif +0 -0
  226. data/doc/ex/images/image_with_profile.jpg +0 -0
  227. data/doc/ex/images/logo400x83.gif +0 -0
  228. data/doc/ex/images/model.miff +0 -0
  229. data/doc/ex/images/notimplemented.gif +0 -0
  230. data/doc/ex/images/smile.miff +0 -0
  231. data/doc/ex/images/spin.gif +0 -0
  232. data/doc/ex/implode.rb +0 -34
  233. data/doc/ex/level.rb +0 -11
  234. data/doc/ex/level_colors.rb +0 -11
  235. data/doc/ex/line.rb +0 -41
  236. data/doc/ex/line01.rb +0 -21
  237. data/doc/ex/mask.rb +0 -35
  238. data/doc/ex/matte_fill_to_border.rb +0 -39
  239. data/doc/ex/matte_floodfill.rb +0 -32
  240. data/doc/ex/matte_replace.rb +0 -39
  241. data/doc/ex/median_filter.rb +0 -28
  242. data/doc/ex/modulate.rb +0 -11
  243. data/doc/ex/mono.rb +0 -23
  244. data/doc/ex/morph.rb +0 -25
  245. data/doc/ex/mosaic.rb +0 -35
  246. data/doc/ex/motion_blur.rb +0 -11
  247. data/doc/ex/negate.rb +0 -11
  248. data/doc/ex/negate_channel.rb +0 -9
  249. data/doc/ex/nested_rvg.rb +0 -21
  250. data/doc/ex/nonzero.rb +0 -42
  251. data/doc/ex/normalize.rb +0 -11
  252. data/doc/ex/oil_paint.rb +0 -11
  253. data/doc/ex/opacity.rb +0 -37
  254. data/doc/ex/ordered_dither.rb +0 -11
  255. data/doc/ex/path.rb +0 -63
  256. data/doc/ex/pattern1.rb +0 -25
  257. data/doc/ex/pattern2.rb +0 -26
  258. data/doc/ex/polaroid.rb +0 -27
  259. data/doc/ex/polygon.rb +0 -23
  260. data/doc/ex/polygon01.rb +0 -21
  261. data/doc/ex/polyline.rb +0 -22
  262. data/doc/ex/polyline01.rb +0 -21
  263. data/doc/ex/posterize.rb +0 -8
  264. data/doc/ex/preview.rb +0 -8
  265. data/doc/ex/qbezierpath.rb +0 -52
  266. data/doc/ex/quad01.rb +0 -34
  267. data/doc/ex/quantize-m.rb +0 -25
  268. data/doc/ex/radial_blur.rb +0 -9
  269. data/doc/ex/raise.rb +0 -8
  270. data/doc/ex/random_threshold_channel.rb +0 -13
  271. data/doc/ex/rect01.rb +0 -14
  272. data/doc/ex/rect02.rb +0 -20
  273. data/doc/ex/rectangle.rb +0 -34
  274. data/doc/ex/reduce_noise.rb +0 -28
  275. data/doc/ex/remap.rb +0 -11
  276. data/doc/ex/remap_images.rb +0 -19
  277. data/doc/ex/resize_to_fill.rb +0 -8
  278. data/doc/ex/resize_to_fit.rb +0 -8
  279. data/doc/ex/roll.rb +0 -9
  280. data/doc/ex/rotate.rb +0 -44
  281. data/doc/ex/rotate_f.rb +0 -14
  282. data/doc/ex/roundrect.rb +0 -33
  283. data/doc/ex/rubyname.rb +0 -30
  284. data/doc/ex/rvg_clippath.rb +0 -12
  285. data/doc/ex/rvg_linecap.rb +0 -42
  286. data/doc/ex/rvg_linejoin.rb +0 -40
  287. data/doc/ex/rvg_opacity.rb +0 -18
  288. data/doc/ex/rvg_pattern.rb +0 -26
  289. data/doc/ex/rvg_stroke_dasharray.rb +0 -11
  290. data/doc/ex/segment.rb +0 -11
  291. data/doc/ex/sepiatone.rb +0 -7
  292. data/doc/ex/shade.rb +0 -11
  293. data/doc/ex/shadow.rb +0 -30
  294. data/doc/ex/shave.rb +0 -15
  295. data/doc/ex/shear.rb +0 -10
  296. data/doc/ex/sketch.rb +0 -17
  297. data/doc/ex/skewx.rb +0 -51
  298. data/doc/ex/skewy.rb +0 -47
  299. data/doc/ex/smile.rb +0 -125
  300. data/doc/ex/solarize.rb +0 -11
  301. data/doc/ex/sparse_color.rb +0 -54
  302. data/doc/ex/splice.rb +0 -8
  303. data/doc/ex/spread.rb +0 -11
  304. data/doc/ex/stegano.rb +0 -55
  305. data/doc/ex/stroke_dasharray.rb +0 -42
  306. data/doc/ex/stroke_fill.rb +0 -10
  307. data/doc/ex/stroke_linecap.rb +0 -44
  308. data/doc/ex/stroke_linejoin.rb +0 -48
  309. data/doc/ex/stroke_width.rb +0 -49
  310. data/doc/ex/swirl.rb +0 -17
  311. data/doc/ex/text.rb +0 -37
  312. data/doc/ex/text01.rb +0 -16
  313. data/doc/ex/text_align.rb +0 -36
  314. data/doc/ex/text_antialias.rb +0 -37
  315. data/doc/ex/text_styles.rb +0 -19
  316. data/doc/ex/text_undercolor.rb +0 -28
  317. data/doc/ex/texture_fill_to_border.rb +0 -34
  318. data/doc/ex/texture_floodfill.rb +0 -32
  319. data/doc/ex/texturefill.rb +0 -24
  320. data/doc/ex/threshold.rb +0 -13
  321. data/doc/ex/to_blob.rb +0 -13
  322. data/doc/ex/translate.rb +0 -39
  323. data/doc/ex/transparent.rb +0 -38
  324. data/doc/ex/transpose.rb +0 -9
  325. data/doc/ex/transverse.rb +0 -9
  326. data/doc/ex/tref01.rb +0 -24
  327. data/doc/ex/triangle01.rb +0 -15
  328. data/doc/ex/trim.rb +0 -23
  329. data/doc/ex/tspan01.rb +0 -17
  330. data/doc/ex/tspan02.rb +0 -17
  331. data/doc/ex/tspan03.rb +0 -19
  332. data/doc/ex/unsharp_mask.rb +0 -28
  333. data/doc/ex/viewex.rb +0 -33
  334. data/doc/ex/vignette.rb +0 -12
  335. data/doc/ex/watermark.rb +0 -27
  336. data/doc/ex/wave.rb +0 -9
  337. data/doc/ex/wet_floor.rb +0 -58
  338. data/doc/ex/writing_mode01.rb +0 -26
  339. data/doc/ex/writing_mode02.rb +0 -26
  340. data/doc/ilist.html +0 -2056
  341. data/doc/image1.html +0 -4680
  342. data/doc/image2.html +0 -3665
  343. data/doc/image3.html +0 -4522
  344. data/doc/imageattrs.html +0 -1638
  345. data/doc/imusage.html +0 -514
  346. data/doc/index.html +0 -416
  347. data/doc/info.html +0 -1499
  348. data/doc/magick.html +0 -565
  349. data/doc/optequiv.html +0 -2435
  350. data/doc/rvg.html +0 -975
  351. data/doc/rvgclip.html +0 -248
  352. data/doc/rvggroup.html +0 -305
  353. data/doc/rvgimage.html +0 -289
  354. data/doc/rvgpattern.html +0 -475
  355. data/doc/rvgshape.html +0 -406
  356. data/doc/rvgstyle.html +0 -270
  357. data/doc/rvgtext.html +0 -465
  358. data/doc/rvgtspan.html +0 -238
  359. data/doc/rvgtut.html +0 -530
  360. data/doc/rvguse.html +0 -145
  361. data/doc/rvgxform.html +0 -294
  362. data/doc/scripts/doc.js +0 -22
  363. data/doc/scripts/stripeTables.js +0 -23
  364. data/doc/struct.html +0 -1339
  365. data/doc/usage.html +0 -1621
  366. data/examples/constitute.rb +0 -7
  367. data/examples/crop_with_gravity.rb +0 -42
  368. data/examples/demo.rb +0 -324
  369. data/examples/describe.rb +0 -43
  370. data/examples/find_similar_region.rb +0 -34
  371. data/examples/histogram.rb +0 -321
  372. data/examples/identify.rb +0 -185
  373. data/examples/image_opacity.rb +0 -29
  374. data/examples/import_export.rb +0 -31
  375. data/examples/pattern_fill.rb +0 -38
  376. data/examples/rotating_text.rb +0 -44
  377. data/examples/spinner.rb +0 -49
  378. data/examples/thumbnail.rb +0 -64
  379. data/examples/vignette.rb +0 -78
  380. data/spec/rmagick/ImageList1_spec.rb +0 -24
  381. data/spec/rmagick/draw_spec.rb +0 -156
  382. data/spec/rmagick/image/blue_shift_spec.rb +0 -16
  383. data/spec/rmagick/image/composite_spec.rb +0 -140
  384. data/spec/rmagick/image/constitute_spec.rb +0 -15
  385. data/spec/rmagick/image/dispatch_spec.rb +0 -18
  386. data/spec/rmagick/image/from_blob_spec.rb +0 -14
  387. data/spec/rmagick/image/ping_spec.rb +0 -14
  388. data/spec/rmagick/image/properties_spec.rb +0 -29
  389. data/spec/spec_helper.rb +0 -4
  390. data/test/Image1.rb +0 -565
  391. data/test/Image2.rb +0 -1304
  392. data/test/Image3.rb +0 -1030
  393. data/test/ImageList1.rb +0 -806
  394. data/test/ImageList2.rb +0 -385
  395. data/test/Image_attributes.rb +0 -697
  396. data/test/Import_Export.rb +0 -121
  397. data/test/Info.rb +0 -345
  398. data/test/Magick.rb +0 -321
  399. data/test/Pixel.rb +0 -116
  400. data/test/Preview.rb +0 -57
  401. data/test/cmyk.icm +0 -0
  402. data/test/srgb.icm +0 -0
  403. data/test/test_all_basic.rb +0 -38
  404. data/test/tmpnam_test.rb +0 -50
  405. data/wercker.yml +0 -10
data/ext/RMagick/rmfill.c CHANGED
@@ -12,6 +12,11 @@
12
12
 
13
13
  #include "rmagick.h"
14
14
 
15
+ static void GradientFill_free(void *fill);
16
+ static size_t GradientFill_memsize(const void *ptr);
17
+ static void TextureFill_free(void *fill_obj);
18
+ static size_t TextureFill_memsize(const void *ptr);
19
+
15
20
  /** Data associated with a GradientFill */
16
21
  typedef struct
17
22
  {
@@ -19,8 +24,8 @@ typedef struct
19
24
  double y1; /**< y position of first point */
20
25
  double x2; /**< x position of second point */
21
26
  double y2; /**< y position of second point */
22
- PixelPacket start_color; /**< the start color */
23
- PixelPacket stop_color; /**< the stop color */
27
+ PixelColor start_color; /**< the start color */
28
+ PixelColor stop_color; /**< the stop color */
24
29
  } rm_GradientFill;
25
30
 
26
31
  /** Data associated with a TextureFill */
@@ -29,49 +34,76 @@ typedef struct
29
34
  Image *texture; /**< the texture */
30
35
  } rm_TextureFill;
31
36
 
37
+ const rb_data_type_t rm_gradient_fill_data_type = {
38
+ "Magick::GradientFill",
39
+ { NULL, GradientFill_free, GradientFill_memsize, },
40
+ 0, 0,
41
+ RUBY_TYPED_FROZEN_SHAREABLE,
42
+ };
43
+
44
+ const rb_data_type_t rm_texture_fill_data_type = {
45
+ "Magick::TextureFill",
46
+ { NULL, TextureFill_free, TextureFill_memsize, },
47
+ 0, 0,
48
+ RUBY_TYPED_FROZEN_SHAREABLE,
49
+ };
50
+
51
+
52
+ DEFINE_GVL_STUB2(SyncAuthenticPixels, Image *, ExceptionInfo *);
53
+
54
+
32
55
  /**
33
- * Free Fill or Fill subclass object (except for TextureFill).
56
+ * Free GradientFill or GradientFill subclass object (except for TextureFill).
34
57
  *
35
58
  * No Ruby usage (internal function)
36
59
  *
37
60
  * @param fill the fill
38
61
  */
39
- static void free_Fill(void *fill)
62
+ static void
63
+ GradientFill_free(void *fill)
40
64
  {
41
65
  xfree(fill);
42
66
  }
43
67
 
68
+
69
+ /**
70
+ * Get GradientFill object size.
71
+ *
72
+ * No Ruby usage (internal function)
73
+ *
74
+ * @param ptr pointer to the GradientFill object
75
+ */
76
+ static size_t
77
+ GradientFill_memsize(const void *ptr)
78
+ {
79
+ return sizeof(rm_GradientFill);
80
+ }
81
+
82
+
44
83
  /**
45
84
  * Create new GradientFill object.
46
85
  *
47
- * No Ruby usage (internal function)
48
- *
49
- * @param class the Ruby class to use
50
- * @return a new GradientFill object
86
+ * @return [Magick::GradientFill] a new GradientFill object
51
87
  */
52
88
  VALUE
53
89
  GradientFill_alloc(VALUE class)
54
90
  {
55
91
  rm_GradientFill *fill;
56
92
 
57
- return Data_Make_Struct(class, rm_GradientFill, NULL, free_Fill, fill);
93
+ return TypedData_Make_Struct(class, rm_GradientFill, &rm_gradient_fill_data_type, fill);
58
94
  }
59
95
 
60
96
 
61
97
  /**
62
- * Store the vector points and the start and stop colors.
63
- *
64
- * Ruby usage:
65
- * - @verbatim GradientFill#initialize(x1,y1,x2,y2,start_color,stop_color) @endverbatim
66
- *
67
- * @param self this object
68
- * @param x1 x position of first point
69
- * @param y1 y position of first point
70
- * @param x2 x position of second point
71
- * @param y2 y position of second point
72
- * @param start_color the start color
73
- * @param stop_color the stop color
74
- * @return self
98
+ * Initialize GradientFill object.
99
+ *
100
+ * @param x1 [Float] x position of first point
101
+ * @param y1 [Float] y position of first point
102
+ * @param x2 [Float] x position of second point
103
+ * @param y2 [Float] y position of second point
104
+ * @param start_color [Magick::Pixel, String] the start color
105
+ * @param stop_color [Magick::Pixel, String] the stop color
106
+ * @return [Magick::GradientFill] self
75
107
  */
76
108
  VALUE
77
109
  GradientFill_initialize(
@@ -85,14 +117,14 @@ GradientFill_initialize(
85
117
  {
86
118
  rm_GradientFill *fill;
87
119
 
88
- Data_Get_Struct(self, rm_GradientFill, fill);
120
+ TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
89
121
 
90
122
  fill->x1 = NUM2DBL(x1);
91
123
  fill->y1 = NUM2DBL(y1);
92
124
  fill->x2 = NUM2DBL(x2);
93
125
  fill->y2 = NUM2DBL(y2);
94
- Color_to_PixelPacket(&fill->start_color, start_color);
95
- Color_to_PixelPacket(&fill->stop_color, stop_color);
126
+ Color_to_PixelColor(&fill->start_color, start_color);
127
+ Color_to_PixelColor(&fill->stop_color, stop_color);
96
128
 
97
129
  return self;
98
130
  }
@@ -113,17 +145,15 @@ point_fill(
113
145
  Image *image,
114
146
  double x0,
115
147
  double y0,
116
- PixelPacket *start_color,
117
- PixelPacket *stop_color)
148
+ PixelColor *start_color,
149
+ PixelColor *stop_color)
118
150
  {
119
151
  double steps, distance;
120
- unsigned long x, y;
152
+ ssize_t x, y;
121
153
  MagickRealType red_step, green_step, blue_step;
122
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
123
154
  ExceptionInfo *exception;
124
155
 
125
156
  exception = AcquireExceptionInfo();
126
- #endif
127
157
 
128
158
  steps = sqrt((double)((image->columns-x0)*(image->columns-x0)
129
159
  + (image->rows-y0)*(image->rows-y0)));
@@ -132,38 +162,42 @@ point_fill(
132
162
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
133
163
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
134
164
 
135
- for (y = 0; y < image->rows; y++)
165
+ for (y = 0; y < (ssize_t) image->rows; y++)
136
166
  {
137
- PixelPacket *row_pixels;
138
-
139
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
140
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
141
- CHECK_EXCEPTION()
167
+ #if defined(IMAGEMAGICK_7)
168
+ Quantum *row_pixels;
142
169
  #else
143
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
144
- rm_check_image_exception(image, RetainOnError);
170
+ PixelPacket *row_pixels;
145
171
  #endif
146
- for (x = 0; x < image->columns; x++)
172
+
173
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
174
+ CHECK_EXCEPTION();
175
+
176
+ for (x = 0; x < (ssize_t) image->columns; x++)
147
177
  {
148
178
  distance = sqrt((double)((x-x0)*(x-x0)+(y-y0)*(y-y0)));
179
+
180
+ #if defined(IMAGEMAGICK_7)
181
+ SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
182
+ SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
183
+ SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
184
+ SetPixelAlpha(image, OpaqueAlpha, row_pixels);
185
+
186
+ row_pixels += GetPixelChannels(image);
187
+ #else
149
188
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
150
189
  row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
151
190
  row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
152
191
  row_pixels[x].opacity = OpaqueOpacity;
192
+ #endif
153
193
  }
154
194
 
155
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
156
- SyncAuthenticPixels(image, exception);
157
- CHECK_EXCEPTION()
158
- #else
159
- SyncImagePixels(image);
160
- rm_check_image_exception(image, RetainOnError);
161
- #endif
195
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
196
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
197
+ CHECK_EXCEPTION();
162
198
  }
163
199
 
164
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
165
200
  DestroyExceptionInfo(exception);
166
- #endif
167
201
  }
168
202
 
169
203
  /**
@@ -181,18 +215,18 @@ static void
181
215
  vertical_fill(
182
216
  Image *image,
183
217
  double x1,
184
- PixelPacket *start_color,
185
- PixelPacket *stop_color)
218
+ PixelColor *start_color,
219
+ PixelColor *stop_color)
186
220
  {
187
221
  double steps;
188
- unsigned long x, y;
189
- PixelPacket *master;
222
+ ssize_t x, y;
190
223
  MagickRealType red_step, green_step, blue_step;
191
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
192
224
  ExceptionInfo *exception;
225
+ #if defined(IMAGEMAGICK_6)
226
+ PixelPacket *master;
227
+ #endif
193
228
 
194
229
  exception = AcquireExceptionInfo();
195
- #endif
196
230
 
197
231
  steps = FMAX(x1, ((long)image->columns)-x1);
198
232
 
@@ -208,11 +242,38 @@ vertical_fill(
208
242
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
209
243
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
210
244
 
245
+
246
+ #if defined(IMAGEMAGICK_7)
247
+ for (y = 0; y < (ssize_t) image->rows; y++)
248
+ {
249
+ Quantum *row_pixels;
250
+
251
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
252
+ CHECK_EXCEPTION();
253
+
254
+ for (x = 0; x < (ssize_t) image->columns; x++)
255
+ {
256
+ double distance = fabs(x1 - x);
257
+ SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
258
+ SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
259
+ SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
260
+ SetPixelAlpha(image, OpaqueAlpha, row_pixels);
261
+
262
+ row_pixels += GetPixelChannels(image);
263
+ }
264
+
265
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
266
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
267
+ CHECK_EXCEPTION();
268
+ }
269
+
270
+ DestroyExceptionInfo(exception);
271
+ #else
211
272
  // All the rows are the same. Make a "master row" and simply copy
212
273
  // it to each actual row.
213
274
  master = ALLOC_N(PixelPacket, image->columns);
214
275
 
215
- for (x = 0; x < image->columns; x++)
276
+ for (x = 0; x < (ssize_t) image->columns; x++)
216
277
  {
217
278
  double distance = fabs(x1 - x);
218
279
  master[x].red = ROUND_TO_QUANTUM(start_color->red + (red_step * distance));
@@ -222,34 +283,32 @@ vertical_fill(
222
283
  }
223
284
 
224
285
  // Now copy the master row to each actual row.
225
- for (y = 0; y < image->rows; y++)
286
+ for (y = 0; y < (ssize_t) image->rows; y++)
226
287
  {
227
288
  PixelPacket *row_pixels;
228
289
 
229
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
230
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
231
- CHECK_EXCEPTION()
232
- #else
233
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
234
- rm_check_image_exception(image, RetainOnError);
235
- #endif
290
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
291
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
292
+ {
293
+ xfree((void *)master);
294
+ rm_raise_exception(exception);
295
+ }
236
296
 
237
297
  memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
238
298
 
239
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
240
- SyncAuthenticPixels(image, exception);
241
- CHECK_EXCEPTION()
242
- #else
243
- SyncImagePixels(image);
244
- rm_check_image_exception(image, RetainOnError);
245
- #endif
299
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
300
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
301
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
302
+ {
303
+ xfree((void *)master);
304
+ rm_raise_exception(exception);
305
+ }
246
306
  }
247
307
 
248
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
249
308
  DestroyExceptionInfo(exception);
250
- #endif
251
309
 
252
- xfree((void *)master);
310
+ xfree((void *) master);
311
+ #endif
253
312
  }
254
313
 
255
314
  /**
@@ -266,18 +325,18 @@ static void
266
325
  horizontal_fill(
267
326
  Image *image,
268
327
  double y1,
269
- PixelPacket *start_color,
270
- PixelPacket *stop_color)
328
+ PixelColor *start_color,
329
+ PixelColor *stop_color)
271
330
  {
272
331
  double steps;
273
- unsigned long x, y;
274
- PixelPacket *master;
332
+ ssize_t x, y;
275
333
  MagickRealType red_step, green_step, blue_step;
276
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
277
334
  ExceptionInfo *exception;
335
+ #if defined(IMAGEMAGICK_6)
336
+ PixelPacket *master;
337
+ #endif
278
338
 
279
339
  exception = AcquireExceptionInfo();
280
- #endif
281
340
 
282
341
  steps = FMAX(y1, ((long)image->rows)-y1);
283
342
 
@@ -292,11 +351,37 @@ horizontal_fill(
292
351
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
293
352
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
294
353
 
354
+ #if defined(IMAGEMAGICK_7)
355
+ for (y = 0; y < (ssize_t) image->rows; y++)
356
+ {
357
+ Quantum *row_pixels;
358
+
359
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
360
+ CHECK_EXCEPTION();
361
+
362
+ double distance = fabs(y1 - y);
363
+ for (x = 0; x < (ssize_t) image->columns; x++)
364
+ {
365
+ SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
366
+ SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
367
+ SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
368
+ SetPixelAlpha(image, OpaqueAlpha, row_pixels);
369
+
370
+ row_pixels += GetPixelChannels(image);
371
+ }
372
+
373
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
374
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
375
+ CHECK_EXCEPTION();
376
+ }
377
+
378
+ DestroyExceptionInfo(exception);
379
+ #else
295
380
  // All the columns are the same, so make a master column and copy it to
296
381
  // each of the "real" columns.
297
382
  master = ALLOC_N(PixelPacket, image->rows);
298
383
 
299
- for (y = 0; y < image->rows; y++)
384
+ for (y = 0; y < (ssize_t) image->rows; y++)
300
385
  {
301
386
  double distance = fabs(y1 - y);
302
387
  master[y].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
@@ -305,32 +390,32 @@ horizontal_fill(
305
390
  master[y].opacity = OpaqueOpacity;
306
391
  }
307
392
 
308
- for (x = 0; x < image->columns; x++)
393
+ for (x = 0; x < (ssize_t) image->columns; x++)
309
394
  {
310
395
  PixelPacket *col_pixels;
311
396
 
312
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
313
- col_pixels = QueueAuthenticPixels(image, (long int)x, 0, 1, image->rows, exception);
314
- #else
315
- col_pixels = SetImagePixels(image, (long int)x, 0, 1, image->rows);
316
- rm_check_image_exception(image, RetainOnError);
317
- #endif
397
+ col_pixels = QueueAuthenticPixels(image, x, 0, 1, image->rows, exception);
398
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
399
+ {
400
+ xfree((void *)master);
401
+ rm_raise_exception(exception);
402
+ }
403
+
318
404
  memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
319
405
 
320
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
321
- SyncAuthenticPixels(image, exception);
322
- CHECK_EXCEPTION()
323
- #else
324
- SyncImagePixels(image);
325
- rm_check_image_exception(image, RetainOnError);
326
- #endif
406
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
407
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
408
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
409
+ {
410
+ xfree((void *)master);
411
+ rm_raise_exception(exception);
412
+ }
327
413
  }
328
414
 
329
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
330
415
  DestroyExceptionInfo(exception);
331
- #endif
332
416
 
333
- xfree((PixelPacket *)master);
417
+ xfree((void *) master);
418
+ #endif
334
419
  }
335
420
 
336
421
  /**
@@ -354,18 +439,16 @@ v_diagonal_fill(
354
439
  double y1,
355
440
  double x2,
356
441
  double y2,
357
- PixelPacket *start_color,
358
- PixelPacket *stop_color)
442
+ PixelColor *start_color,
443
+ PixelColor *stop_color)
359
444
  {
360
- unsigned long x, y;
445
+ ssize_t x, y;
361
446
  MagickRealType red_step, green_step, blue_step;
362
447
  double m, b, steps = 0.0;
363
448
  double d1, d2;
364
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
365
449
  ExceptionInfo *exception;
366
450
 
367
451
  exception = AcquireExceptionInfo();
368
- #endif
369
452
 
370
453
  // Compute the equation of the line: y=mx+b
371
454
  m = ((double)(y2 - y1))/((double)(x2 - x1));
@@ -379,7 +462,7 @@ v_diagonal_fill(
379
462
 
380
463
  if (d1 < 0 && d2 < 0)
381
464
  {
382
- steps += FMAX(fabs(d1),fabs(d2));
465
+ steps += FMAX(fabs(d1), fabs(d2));
383
466
  }
384
467
  else if (d1 > (double)image->rows && d2 > (double)image->rows)
385
468
  {
@@ -393,7 +476,7 @@ v_diagonal_fill(
393
476
  // If the line is entirely > image->rows, swap the start & end color
394
477
  if (steps < 0)
395
478
  {
396
- PixelPacket t = *stop_color;
479
+ PixelColor t = *stop_color;
397
480
  *stop_color = *start_color;
398
481
  *start_color = t;
399
482
  steps = -steps;
@@ -403,39 +486,41 @@ v_diagonal_fill(
403
486
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
404
487
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
405
488
 
406
- for (y = 0; y < image->rows; y++)
489
+ for (y = 0; y < (ssize_t) image->rows; y++)
407
490
  {
408
- PixelPacket *row_pixels;
409
-
410
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
411
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
412
- CHECK_EXCEPTION()
491
+ #if defined(IMAGEMAGICK_7)
492
+ Quantum *row_pixels;
413
493
  #else
414
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
415
- rm_check_image_exception(image, RetainOnError);
494
+ PixelPacket *row_pixels;
416
495
  #endif
417
- for (x = 0; x < image->columns; x++)
496
+
497
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
498
+ CHECK_EXCEPTION();
499
+
500
+ for (x = 0; x < (ssize_t) image->columns; x++)
418
501
  {
419
502
  double distance = (double) abs((int)(y-(m * x + b)));
503
+ #if defined(IMAGEMAGICK_7)
504
+ SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
505
+ SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
506
+ SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
507
+ SetPixelAlpha(image, OpaqueAlpha, row_pixels);
508
+
509
+ row_pixels += GetPixelChannels(image);
510
+ #else
420
511
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
421
512
  row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
422
513
  row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
423
514
  row_pixels[x].opacity = OpaqueOpacity;
515
+ #endif
424
516
  }
425
517
 
426
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
427
- SyncAuthenticPixels(image, exception);
428
- CHECK_EXCEPTION()
429
- #else
430
- SyncImagePixels(image);
431
- rm_check_image_exception(image, RetainOnError);
432
- #endif
518
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
519
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
520
+ CHECK_EXCEPTION();
433
521
  }
434
522
 
435
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
436
523
  DestroyExceptionInfo(exception);
437
- #endif
438
-
439
524
  }
440
525
 
441
526
  /**
@@ -459,18 +544,16 @@ h_diagonal_fill(
459
544
  double y1,
460
545
  double x2,
461
546
  double y2,
462
- PixelPacket *start_color,
463
- PixelPacket *stop_color)
547
+ PixelColor *start_color,
548
+ PixelColor *stop_color)
464
549
  {
465
- unsigned long x, y;
550
+ ssize_t x, y;
466
551
  double m, b, steps = 0.0;
467
552
  MagickRealType red_step, green_step, blue_step;
468
553
  double d1, d2;
469
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
470
554
  ExceptionInfo *exception;
471
555
 
472
556
  exception = AcquireExceptionInfo();
473
- #endif
474
557
 
475
558
  // Compute the equation of the line: y=mx+b
476
559
  m = ((double)(y2 - y1))/((double)(x2 - x1));
@@ -486,11 +569,11 @@ h_diagonal_fill(
486
569
  // the number of steps.
487
570
  if (d1 < 0 && d2 < 0)
488
571
  {
489
- steps += FMAX(fabs(d1),fabs(d2));
572
+ steps += FMAX(fabs(d1), fabs(d2));
490
573
  }
491
574
  else if (d1 > (double)image->columns && d2 > (double)image->columns)
492
575
  {
493
- steps += FMAX(abs((int)(image->columns-d1)),abs((int)(image->columns-d2)));
576
+ steps += FMAX(abs((int)(image->columns-d1)), abs((int)(image->columns-d2)));
494
577
  }
495
578
 
496
579
  d1 = FMAX(d1, image->columns-d1);
@@ -500,7 +583,7 @@ h_diagonal_fill(
500
583
  // If the line is entirely > image->columns, swap the start & end color
501
584
  if (steps < 0)
502
585
  {
503
- PixelPacket t = *stop_color;
586
+ PixelColor t = *stop_color;
504
587
  *stop_color = *start_color;
505
588
  *start_color = t;
506
589
  steps = -steps;
@@ -510,60 +593,59 @@ h_diagonal_fill(
510
593
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
511
594
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
512
595
 
513
- for (y = 0; y < image->rows; y++)
596
+ for (y = 0; y < (ssize_t) image->rows; y++)
514
597
  {
515
- PixelPacket *row_pixels;
516
-
517
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
518
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
519
- CHECK_EXCEPTION()
598
+ #if defined(IMAGEMAGICK_7)
599
+ Quantum *row_pixels;
520
600
  #else
521
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
522
- rm_check_image_exception(image, RetainOnError);
601
+ PixelPacket *row_pixels;
523
602
  #endif
524
- for (x = 0; x < image->columns; x++)
603
+
604
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
605
+ CHECK_EXCEPTION();
606
+
607
+ for (x = 0; x < (ssize_t) image->columns; x++)
525
608
  {
526
609
  double distance = (double) abs((int)(x-((y-b)/m)));
610
+ #if defined(IMAGEMAGICK_7)
611
+ SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
612
+ SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
613
+ SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
614
+ SetPixelAlpha(image, OpaqueAlpha, row_pixels);
615
+
616
+ row_pixels += GetPixelChannels(image);
617
+ #else
527
618
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
528
619
  row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
529
620
  row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
530
621
  row_pixels[x].opacity = OpaqueOpacity;
622
+ #endif
531
623
  }
532
624
 
533
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
534
- SyncAuthenticPixels(image, exception);
535
- CHECK_EXCEPTION()
536
- #else
537
- SyncImagePixels(image);
538
- rm_check_image_exception(image, RetainOnError);
539
- #endif
625
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
626
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
627
+ CHECK_EXCEPTION();
540
628
  }
541
629
 
542
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
543
630
  DestroyExceptionInfo(exception);
544
- #endif
545
631
  }
546
632
 
547
633
  /**
548
634
  * Call GradientFill with the start and stop colors specified when this fill
549
635
  * object was created.
550
636
  *
551
- * Ruby usage:
552
- * - @verbatim GradientFill#fill(image) @endverbatim
553
- *
554
- * @param self this object
555
- * @param image_obj the image
556
- * @return self
637
+ * @param image_obj [Magick::Image] the image to fill
638
+ * @return [Magick::GradientFill] self
557
639
  */
558
640
  VALUE
559
641
  GradientFill_fill(VALUE self, VALUE image_obj)
560
642
  {
561
643
  rm_GradientFill *fill;
562
644
  Image *image;
563
- PixelPacket start_color, stop_color;
645
+ PixelColor start_color, stop_color;
564
646
  double x1, y1, x2, y2; // points on the line
565
647
 
566
- Data_Get_Struct(self, rm_GradientFill, fill);
648
+ TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
567
649
  image = rm_check_destroyed(image_obj);
568
650
 
569
651
  x1 = fill->x1;
@@ -626,49 +708,51 @@ GradientFill_fill(VALUE self, VALUE image_obj)
626
708
  * @param fill_obj the TextureFill
627
709
  */
628
710
  static void
629
- free_TextureFill(void *fill_obj)
711
+ TextureFill_free(void *fill_obj)
630
712
  {
631
713
  rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
632
714
 
633
715
  // Do not trace destruction
634
- (void) DestroyImage(fill->texture);
716
+ if (fill->texture)
717
+ {
718
+ DestroyImage(fill->texture);
719
+ }
635
720
  xfree(fill);
636
721
  }
637
722
 
723
+
724
+ /**
725
+ * Get TextureFill object size.
726
+ *
727
+ * No Ruby usage (internal function)
728
+ *
729
+ * @param ptr pointer to the TextureFill object
730
+ */
731
+ static size_t
732
+ TextureFill_memsize(const void *ptr)
733
+ {
734
+ return sizeof(rm_TextureFill);
735
+ }
736
+
737
+
638
738
  /**
639
739
  * Create new TextureFill object.
640
740
  *
641
- * No Ruby usage (internal function)
642
- *
643
- * Notes:
644
- * - The texture is an Image or Image *object
645
- *
646
- * @param class the Ruby class to use
647
- * @return a new TextureFill object
741
+ * @return [Magick::TextureFill] a new TextureFill object
648
742
  */
649
743
  VALUE
650
744
  TextureFill_alloc(VALUE class)
651
745
  {
652
746
  rm_TextureFill *fill;
653
- return Data_Make_Struct(class
654
- , rm_TextureFill
655
- , NULL
656
- , free_TextureFill
657
- , fill);
747
+ return TypedData_Make_Struct(class, rm_TextureFill, &rm_texture_fill_data_type, fill);
658
748
  }
659
749
 
660
750
  /**
661
- * Store the texture image.
662
- *
663
- * Ruby usage:
664
- * - @verbatim TextureFill#initialize(texture) @endverbatim
665
- *
666
- * Notes:
667
- * - The texture is an Image or Image *object
751
+ * Initialize TextureFill object.
668
752
  *
669
- * @param self this object
670
- * @param texture_arg the texture
671
- * @return self
753
+ * @param texture_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
754
+ * imagelist, uses the current image.
755
+ * @return [Magick::TextureFill] self
672
756
  */
673
757
  VALUE
674
758
  TextureFill_initialize(VALUE self, VALUE texture_arg)
@@ -677,13 +761,13 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
677
761
  Image *texture;
678
762
  VALUE texture_image;
679
763
 
680
- Data_Get_Struct(self, rm_TextureFill, fill);
764
+ TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
681
765
 
682
766
  texture_image = rm_cur_image(texture_arg);
683
767
 
684
768
  // Bump the reference count on the texture image.
685
769
  texture = rm_check_destroyed(texture_image);
686
- (void) ReferenceImage(texture);
770
+ ReferenceImage(texture);
687
771
 
688
772
  fill->texture = texture;
689
773
 
@@ -696,24 +780,30 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
696
780
  * Call TextureFill with the texture specified when this fill object was
697
781
  * created.
698
782
  *
699
- * Ruby usage:
700
- * - @verbatim TextureFill#fill(image) @endverbatim
701
- *
702
- * @param self this object
703
- * @param image_obj the image
704
- * @return self
783
+ * @param image_obj [Magick::Image] the image to fill
784
+ * @return [Magick::TextureFill] self
705
785
  */
706
786
  VALUE
707
787
  TextureFill_fill(VALUE self, VALUE image_obj)
708
788
  {
709
789
  rm_TextureFill *fill;
710
790
  Image *image;
791
+ #if defined(IMAGEMAGICK_7)
792
+ ExceptionInfo *exception;
793
+ #endif
711
794
 
712
795
  image = rm_check_destroyed(image_obj);
713
- Data_Get_Struct(self, rm_TextureFill, fill);
796
+ TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
714
797
 
715
- (void) TextureImage(image, fill->texture);
798
+ #if defined(IMAGEMAGICK_7)
799
+ exception = AcquireExceptionInfo();
800
+ TextureImage(image, fill->texture, exception);
801
+ CHECK_EXCEPTION();
802
+ DestroyExceptionInfo(exception);
803
+ #else
804
+ TextureImage(image, fill->texture);
716
805
  rm_check_image_exception(image, RetainOnError);
806
+ #endif
717
807
 
718
808
  return self;
719
809
  }