/src/wrappers/gdk/library/gdk_pixbuf.e

http://github.com/tybor/Liberty · Specman e · 638 lines · 409 code · 55 blank · 174 comment · 30 complexity · 567040f2babd33f8c5549bbd7ce98534 MD5 · raw file

  1. indexing
  2. description: "GdkPixbuf -- Information that describes an image."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team and others
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. -- The GdkPixbuf structure contains information that describes
  21. -- an image in memory.
  22. class GDK_PIXBUF
  23. inherit
  24. G_OBJECT
  25. redefine dispose, store_eiffel_wrapper, unstore_eiffel_wrapper end
  26. insert
  27. GDK_PIXBUF_EXTERNALS
  28. GDK_COLORSPACE
  29. creation
  30. make, from_external_pointer_no_ref, from_external_pointer,
  31. from_file, from_file_at_size, from_file_at_scale,
  32. from_drawable, from_pixbuf, from_data
  33. feature {} -- Creation
  34. from_pixbuf (other: like Current) is
  35. require
  36. other_not_void: other /= Void
  37. local
  38. pixbuf_ptr: POINTER
  39. do
  40. pixbuf_ptr := gdk_pixbuf_copy (other.handle)
  41. if pixbuf_ptr.is_not_null then
  42. from_external_pointer_no_ref (pixbuf_ptr)
  43. else
  44. set_handle (invalid_pixbuf_handle)
  45. end
  46. end
  47. from_file (filename: STRING) is
  48. -- New pixbuf by loading an image from `filename'.
  49. -- The file format is detected automatically.
  50. require
  51. filename /= Void
  52. local
  53. error_ptr, pixbuf_ptr: POINTER
  54. do
  55. pixbuf_ptr := gdk_pixbuf_new_from_file (filename.to_external, $error_ptr)
  56. if error_ptr.is_not_null then
  57. create last_error.from_external_pointer (error_ptr)
  58. set_handle (invalid_pixbuf_handle)
  59. elseif pixbuf_ptr.is_not_null then
  60. from_external_pointer_no_ref (pixbuf_ptr)
  61. else
  62. -- No error reported, but no pixbuf either :(
  63. std_error.put_string (once "invalid gdk_pixbuf")
  64. set_handle (invalid_pixbuf_handle)
  65. end
  66. end
  67. from_data (some_data: POINTER; an_alpha: BOOLEAN; a_bits_per_sample, a_width, a_height, a_rowstride: INTEGER) is
  68. -- Creates a new GdkPixbuf out of in-memory image data. Currently
  69. -- only RGB images with 8 bits per sample are supported.
  70. local
  71. pixbuf_ptr: POINTER
  72. do
  73. pixbuf_ptr := gdk_pixbuf_new_from_data (some_data, gdk_colorspace_rgb, an_alpha.to_integer,
  74. a_bits_per_sample, a_width, a_height,
  75. a_rowstride, default_pointer, default_pointer)
  76. if pixbuf_ptr.is_not_null then
  77. from_external_pointer_no_ref (pixbuf_ptr)
  78. else
  79. -- No error reported, but no pixbuf either :(
  80. std_error.put_string (once "invalid gdk_pixbuf")
  81. set_handle (invalid_pixbuf_handle)
  82. end
  83. end
  84. from_file_at_size (filename: STRING; a_width, a_height: INTEGER) is
  85. -- New pixbuf by loading an image from `filename'.
  86. -- The file format is detected automatically.
  87. -- The image will be scaled to fit in a `a_width'x`a_height' area
  88. -- preserving the image's aspect ratio.
  89. -- `a_width ' and `a_height' can be -1 to avoid constraining that dimension
  90. require
  91. a_width >= -1
  92. a_height >= -1
  93. filename /= Void
  94. local
  95. pixbuf_ptr, error_ptr: POINTER
  96. do
  97. pixbuf_ptr := gdk_pixbuf_new_from_file_at_size (filename.to_external,
  98. a_width, a_height, $error_ptr)
  99. if error_ptr.is_not_null then
  100. create last_error.from_external_pointer (error_ptr)
  101. set_handle (invalid_pixbuf_handle)
  102. elseif pixbuf_ptr.is_not_null then
  103. from_external_pointer_no_ref (pixbuf_ptr)
  104. else
  105. -- No error reported, but no pixbuf either :(
  106. std_error.put_string (once "invalid gdk_pixbuf")
  107. set_handle (invalid_pixbuf_handle)
  108. end
  109. end
  110. from_file_at_scale (filename: STRING; a_width, a_height: INTEGER; preserve_aspect_ration: BOOLEAN) is
  111. -- Creates a new pixbuf by loading an image from a file. The file
  112. -- format is detected automatically. The image will be scaled to
  113. -- fit in the requested size, optionally preserving the image's
  114. -- aspect ratio.
  115. --
  116. -- When preserving the aspect ratio, a width of -1 will cause the
  117. -- image to be scaled to the exact given height, and a height of -1
  118. -- will cause the image to be scaled to the exact given width. When
  119. -- not preserving aspect ratio, a width or height of -1 means to
  120. -- not scale the image at all in that dimension. Negative values
  121. -- for width and height are allowed since 2.8.
  122. require
  123. filename /= Void
  124. local
  125. pixbuf_ptr, error_ptr: POINTER
  126. do
  127. pixbuf_ptr := gdk_pixbuf_new_from_file_at_scale (filename.to_external, a_width, a_height,
  128. preserve_aspect_ration.to_integer, $error_ptr)
  129. if error_ptr.is_not_null then
  130. create last_error.from_external_pointer (error_ptr)
  131. set_handle (invalid_pixbuf_handle)
  132. elseif pixbuf_ptr.is_not_null then
  133. from_external_pointer_no_ref (pixbuf_ptr)
  134. else
  135. std_error.put_string (once "invalid gdk_pixbuf")
  136. -- No error reported, but no pixbuf either :(
  137. set_handle (invalid_pixbuf_handle)
  138. end
  139. end
  140. from_drawable (a_drawable: GDK_DRAWABLE; src_x, src_y, a_width, a_height: INTEGER) is
  141. require
  142. a_drawable /= Void
  143. local
  144. pixbuf_ptr: POINTER
  145. do
  146. pixbuf_ptr := gdk_pixbuf_get_from_drawable (default_pointer, a_drawable.handle,
  147. default_pointer, src_x, src_y,
  148. 0, 0, a_width, a_height)
  149. if pixbuf_ptr.is_not_null then
  150. from_external_pointer_no_ref (pixbuf_ptr)
  151. else
  152. std_error.put_string (once "invalid gdk_pixbuf")
  153. -- No error reported, but no pixbuf either :(
  154. set_handle (invalid_pixbuf_handle)
  155. end
  156. end
  157. make (a_alpha: BOOLEAN; a_width, a_height: INTEGER) is
  158. -- Creates a new GdkPixbuf structure and allocates a buffer for it.
  159. -- The buffer has an optimal rowstride. Note that the buffer is not
  160. -- cleared; you will have to fill it completely yourself.
  161. require
  162. a_width >= 0
  163. a_height >= 0
  164. local
  165. pixbuf_ptr: POINTER
  166. do
  167. pixbuf_ptr := gdk_pixbuf_new(gdk_colorspace_rgb, a_alpha.to_integer, 8, a_width, a_height)
  168. if pixbuf_ptr.is_not_null then
  169. from_external_pointer_no_ref (pixbuf_ptr)
  170. else
  171. set_handle (invalid_pixbuf_handle)
  172. end
  173. end
  174. feature -- Access
  175. last_error: G_ERROR
  176. width: INTEGER is
  177. -- The number of columns of the pixbuf.
  178. -- Default value: 1
  179. do
  180. Result := gdk_pixbuf_get_width (handle)
  181. end
  182. height: INTEGER is
  183. -- The number of rows of the pixbuf.
  184. -- Default value: 1
  185. do
  186. Result := gdk_pixbuf_get_height (handle)
  187. end
  188. feature -- Operations
  189. render_pixmap_and_mask (alpha_threshold: INTEGER): TUPLE[GDK_PIXMAP, GDK_BITMAP] is
  190. -- Creates a pixmap and a mask bitmap, and renders a pixbuf
  191. -- and its corresponding thresholded alpha mask to them.
  192. -- This is merely a convenience function; applications that
  193. -- need to render pixbufs with dither offsets or to given
  194. -- drawables should use `draw_pixbuf' and `render_threshold_alpha'.
  195. --
  196. -- The pixmap that is created is created for the colormap
  197. -- returned by gdk_rgb_get_colormap(). You normally will want to
  198. -- instead use the actual colormap for a widget, and use
  199. -- gdk_pixbuf_render_pixmap_and_mask_for_colormap().
  200. --
  201. -- If the pixbuf does not have an alpha channel, then the resulting
  202. -- GDK_BITMAP will be null.
  203. require
  204. alpha_threshold.in_range(0, 255)
  205. local
  206. pixmap_return, bitmap_return: POINTER
  207. a_pixmap: GDK_PIXMAP
  208. a_bitmap: GDK_BITMAP
  209. do
  210. gdk_pixbuf_render_pixmap_and_mask (handle, $pixmap_return, $bitmap_return, alpha_threshold)
  211. create a_pixmap.from_external_pointer (pixmap_return)
  212. if bitmap_return.is_not_null then
  213. create a_bitmap.from_external_pointer (bitmap_return)
  214. end
  215. Result := [a_pixmap, a_bitmap]
  216. ensure
  217. Result.first /= Void
  218. end
  219. fill (a_pixel: INTEGER) is
  220. -- Clears a pixbuf to the given RGBA value,
  221. -- converting the RGBA value into the pixbuf's pixel format.
  222. -- The alpha will be ignored if the pixbuf doesn't have
  223. -- an alpha channel.
  224. --
  225. -- a_pixel: RGBA pixel to clear to (0xffffffff is opaque white, 0x00000000 transparent black)
  226. do
  227. gdk_pixbuf_fill (handle, a_pixel)
  228. end
  229. add_alpha (a_substitute_color: BOOLEAN; a_red, a_green, a_blue: INTEGER): GDK_PIXBUF is
  230. -- Takes an existing pixbuf and adds an alpha channel to it.
  231. -- If the existing pixbuf already had an alpha channel, the channel
  232. -- values are copied from the original; otherwise, the alpha channel
  233. -- is initialized to 255 (full opacity).
  234. -- If a_substitute_color is True, then the color specified by (a_red, a_green, a_blue)
  235. -- will be assigned zero opacity. That is, if you pass (255, 255, 255) for the substitute color,
  236. -- all white pixels will become fully transparent.
  237. --
  238. -- a_substitute_color: Whether to set a color to zero opacity.
  239. -- If this is False, then the (r, g, b) arguments will be ignored.
  240. -- a_red: Red value to substitute.
  241. -- a_green: Green value to substitute.
  242. -- a_blue: Blue value to substitute.
  243. -- Returns: A newly-created pixbuf with a reference count of 1.
  244. require
  245. red_is_valid: a_red.in_range (0, 255)
  246. green_is_valid: a_green.in_range (0, 255)
  247. blue_is_valid: a_blue.in_range (0, 255)
  248. local
  249. pixbuf_ptr: POINTER
  250. do
  251. pixbuf_ptr := gdk_pixbuf_add_alpha (handle,
  252. a_substitute_color, a_red.to_character,
  253. a_green.to_character, a_blue.to_character)
  254. if pixbuf_ptr.is_not_null then
  255. create Result.from_external_pointer_no_ref (pixbuf_ptr)
  256. end
  257. end
  258. save_jpeg_with_quality (a_filename: STRING; a_quality: INTEGER) is
  259. -- Saves pixbuf to a file in JPEG format, with the provided
  260. -- quality.
  261. require
  262. a_filename /= Void
  263. a_quality.in_range (0, 100)
  264. local
  265. error: BOOLEAN
  266. do
  267. error := gdk_pixbuf_save_with_one_arg (handle, a_filename.to_external, "jpeg".to_external,
  268. default_pointer, "quality".to_external, a_quality.to_string.to_external, default_pointer).to_boolean
  269. if error then
  270. debug print (once "Error saving pixbuf!%N") end
  271. end
  272. end
  273. save (a_filename, a_type: STRING) is
  274. -- Saves pixbuf to a file in type, which is currently
  275. -- "jpeg", "png", "tiff", "ico" or "bmp".
  276. require
  277. a_filename /= Void
  278. a_type /= Void
  279. (a_type.is_equal (once "jpeg") or a_type.is_equal (once "png") or
  280. a_type.is_equal (once "tiff") or a_type.is_equal (once "ico") or a_type.is_equal (once "bmp"))
  281. local
  282. error: BOOLEAN
  283. do
  284. error := gdk_pixbuf_savev (handle, a_filename.to_external, a_type.to_external,
  285. default_pointer, default_pointer, default_pointer).to_boolean
  286. if error then
  287. debug print (once "Error saving pixbuf!%N") end
  288. end
  289. end
  290. -- gdk_pixbuf_get_file_info ()
  291. --
  292. -- GdkPixbufFormat* gdk_pixbuf_get_file_info (const gchar *filename,
  293. -- gint *width,
  294. -- gint *height);
  295. --
  296. -- Parses an image file far enough to determine its format and size.
  297. --
  298. -- filename : The name of the file to identify.
  299. -- width : Return location for the width of the image, or NULL
  300. -- height : Return location for the height of the image, or NULL
  301. -- Returns : A GdkPixbufFormat describing the image format of the file or NULL if the image format wasn't recognized. The return value is owned by GdkPixbuf and should not be freed.
  302. --
  303. -- Since 2.4
  304. --
  305. feature -- Properties
  306. bits_per_sample: INTEGER is
  307. do
  308. Result := gdk_pixbuf_get_bits_per_sample (handle)
  309. end
  310. colorspace: INTEGER is
  311. do
  312. Result := gdk_pixbuf_get_colorspace (handle)
  313. end
  314. has_alpha: BOOLEAN is
  315. do
  316. Result := gdk_pixbuf_get_has_alpha (handle).to_boolean
  317. end
  318. n_channels: INTEGER is
  319. do
  320. Result := gdk_pixbuf_get_n_channels (handle)
  321. end
  322. pixels: POINTER is
  323. -- A pointer to the pixel data of the pixbuf.
  324. do
  325. Result := gdk_pixbuf_get_pixels (handle)
  326. end
  327. pixel_rgb (a_row, a_col: INTEGER): TUPLE [INTEGER, INTEGER, INTEGER] is
  328. require
  329. not has_alpha
  330. a_row.in_range (0, height - 1)
  331. a_col.in_range (0, width - 1)
  332. local
  333. packed: INTEGER_32
  334. do
  335. packed := gdk_pixbuf_get_pixel (handle, a_row, a_col)
  336. Result := [packed & 0x000000ff, (packed & 0x0000ff00) |>>> 8, (packed & 0x00ff0000) |>>> 16]
  337. end
  338. set_pixel_rgb (a_row, a_col, a_red, a_green, a_blue: INTEGER) is
  339. require
  340. not has_alpha
  341. a_row.in_range (0, height - 1)
  342. a_col.in_range (0, width - 1)
  343. a_red.in_range (0, 255)
  344. a_green.in_range (0, 255)
  345. a_blue.in_range (0, 255)
  346. do
  347. gdk_pixbuf_set_pixel_byte (handle, a_row, a_col, 0, a_red)
  348. gdk_pixbuf_set_pixel_byte (handle, a_row, a_col, 1, a_green)
  349. gdk_pixbuf_set_pixel_byte (handle, a_row, a_col, 2, a_blue)
  350. end
  351. rowstride: INTEGER is
  352. -- The number of bytes between the start of a row and the
  353. -- start of the next row. This number must (obviously) be
  354. -- at least as large as the width of the pixbuf.
  355. do
  356. Result := gdk_pixbuf_get_rowstride (handle)
  357. end
  358. -- Property Details
  359. -- The "bits-per-sample" property
  360. --
  361. -- "bits-per-sample" gint : Read / Write / Construct Only
  362. --
  363. -- The number of bits per sample. Currently only 8 bit per sample are supported.
  364. --
  365. -- Allowed values: [1,16]
  366. --
  367. -- Default value: 8
  368. -- The "colorspace" property
  369. --
  370. -- "colorspace" GdkColorspace : Read / Write / Construct Only
  371. --
  372. -- The colorspace in which the samples are interpreted.
  373. --
  374. -- Default value: GDK_COLORSPACE_RGB
  375. -- The "has-alpha" property
  376. --
  377. -- "has-alpha" gboolean : Read / Write / Construct Only
  378. --
  379. -- Whether the pixbuf has an alpha channel.
  380. --
  381. -- Default value: FALSE
  382. -- The "n-channels" property
  383. --
  384. -- "n-channels" gint : Read / Write / Construct Only
  385. --
  386. -- The number of samples per pixel. Currently, only 3 or 4 samples per pixel are supported.
  387. --
  388. -- Allowed values: >= 0
  389. --
  390. -- Default value: 3
  391. feature -- Disposing
  392. dispose is
  393. do
  394. if is_valid then
  395. Precursor
  396. else
  397. handle := default_pointer
  398. end
  399. end
  400. store_eiffel_wrapper is
  401. do
  402. g_object_set_qdata (handle, eiffel_key.quark, to_pointer)
  403. -- g_object_class := g_object_get_class (handle)
  404. end
  405. unstore_eiffel_wrapper is
  406. do
  407. g_object_set_qdata (handle, eiffel_key.quark, default_pointer)
  408. end
  409. feature -- Error reporting
  410. is_valid: BOOLEAN is
  411. do
  412. Result := handle /= invalid_pixbuf_handle
  413. end
  414. feature {} -- Error reporting
  415. invalid_pixbuf: GDK_PIXBUF is
  416. -- Pointer to a 1x1 opaque pixbuf
  417. once
  418. create Result.make (False, 1, 1)
  419. end
  420. invalid_pixbuf_handle: POINTER is
  421. once
  422. Result := invalid_pixbuf.handle
  423. end
  424. feature -- size
  425. struct_size: INTEGER is
  426. external "C inline use <gdk/gdk.h>"
  427. alias "sizeof(GdkPixbuf)"
  428. end
  429. feature -- Scaling
  430. scale_simple (a_width, a_height, a_interp_type: INTEGER): GDK_PIXBUF is
  431. -- Create a new GDK_PIXBUF containing a copy of Current scaled to
  432. -- (a_width x a_height). Leaves Current unaffected. a_interp_type
  433. -- should be gdk_interp_nearest if you want maximum speed (but
  434. -- when scaling down gdk_interp_nearest is usually unusably ugly).
  435. -- The default interp_type should be gdk_interp_bilinear which
  436. -- offers reasonable quality and speed.
  437. --
  438. -- You can scale a sub-portion of src by creating a sub-pixbuf
  439. -- pointing into src; see new_subpixbuf().
  440. --
  441. -- For more complicated scaling/compositing see `scale (...)' and
  442. -- `composite (...)'.
  443. require
  444. is_valid_gdk_interp_type (a_interp_type)
  445. local
  446. ptr: POINTER
  447. do
  448. if is_valid then
  449. ptr := gdk_pixbuf_scale_simple (handle, a_width, a_height, a_interp_type)
  450. if ptr.is_not_null then create Result.from_external_pointer_no_ref (ptr) end
  451. end
  452. if Result = Void then Result := invalid_pixbuf end
  453. ensure
  454. Result /= Void
  455. end
  456. scale (other: GDK_PIXBUF; dest_x, dest_y, dest_width, dest_height: INTEGER;
  457. offset_x, offset_y, scale_x, scale_y: REAL_64; interp_type: INTEGER) is
  458. -- Creates a transformation of the Current image by scaling by
  459. -- scale_x and scale_y then translating by offset_x and offset_y,
  460. -- then renders the rectangle (dest_x, dest_y, dest_width, dest_height)
  461. -- of the resulting image onto `other' replacing the previous contents.
  462. --
  463. -- Try to use scale_simple() first, this function is the
  464. -- industrial-strength power tool you can fall back to if
  465. -- scale_simple() isn't powerful enough.
  466. --
  467. -- other : the GDK_PIXBUF into which to render the results
  468. -- dest_x : the left coordinate for region to render
  469. -- dest_y : the top coordinate for region to render
  470. -- dest_width : the width of the region to render
  471. -- dest_height : the height of the region to render
  472. -- offset_x : the offset in the X direction (currently rounded to an integer)
  473. -- offset_y : the offset in the Y direction (currently rounded to an integer)
  474. -- scale_x : the scale factor in the X direction
  475. -- scale_y : the scale factor in the Y direction
  476. -- interp_type : the interpolation type for the transformation.
  477. require
  478. is_valid_gdk_interp_type (interp_type)
  479. do
  480. if not is_valid then
  481. other.dispose
  482. other.set_handle (invalid_pixbuf_handle)
  483. end
  484. if other.is_valid then
  485. gdk_pixbuf_scale (handle, other.handle, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type)
  486. end
  487. end
  488. composite_color_simple (dest_width, dest_height: INTEGER; interp_type: INTEGER;
  489. overall_alpha, check_size: INTEGER; color1, color2: INTEGER_64) : GDK_PIXBUF is
  490. -- Creates a new GDK_PIXBUF by scaling Current to `dest_width' x `dest_height'
  491. -- and compositing the result with a checkboard of colors `color1' and
  492. -- `color2'.
  493. require
  494. colors_conform_guint32: color1 >= 0 and color2 >= 0
  495. valid_alpha: overall_alpha.in_range (0, 255)
  496. valid_check_size: check_size.is_a_power_of_2
  497. valid_interp_type: is_valid_gdk_interp_type (interp_type)
  498. local
  499. res: POINTER
  500. do
  501. if is_valid then
  502. res := gdk_pixbuf_composite_color_simple (handle, dest_width, dest_height, interp_type,
  503. overall_alpha, check_size, color1, color2)
  504. if res.is_not_null then create Result.from_external_pointer_no_ref (res) end
  505. end
  506. if Result = Void then Result := invalid_pixbuf end
  507. ensure
  508. Result /= Void
  509. end
  510. composite (dest: GDK_PIXBUF; dest_x, dest_y, dest_width, dest_height: INTEGER;
  511. offset_x, offset_y, scale_x, scale_y: REAL_64;
  512. interp_type: INTEGER; overall_alpha: INTEGER) is
  513. -- Creates a transformation of the source image Current by scaling by
  514. -- `scale_x' and `scale_y' then translating by `offset_x' and `offset_y'.
  515. -- This gives an image in the coordinates of the destination pixbuf. The
  516. -- rectangle (`dest_x', `dest_y', `dest_width', `dest_height') is then
  517. -- composited onto the corresponding rectangle of the original destination image.
  518. -- When the destination rectangle contains parts not in the source
  519. -- image, the data at the edges of the source image is replicated to infinity.
  520. require
  521. valid_alpha: overall_alpha.in_range (0, 255)
  522. valid_interp_type: is_valid_gdk_interp_type (interp_type)
  523. local
  524. x, y, w, h: INTEGER
  525. do
  526. if not is_valid then
  527. dest.dispose
  528. dest.set_handle (invalid_pixbuf_handle)
  529. end
  530. if dest.is_valid then
  531. x := dest_x
  532. y := dest_y
  533. w := dest_width
  534. h := dest_height
  535. if x < 0 then
  536. w := w + x
  537. x := 0
  538. end
  539. if y < 0 then
  540. h := h + y
  541. y := 0
  542. end
  543. if x + w > dest.width then
  544. w := dest.width - x
  545. end
  546. if y + h > dest.height then
  547. h := dest.height - y
  548. end
  549. gdk_pixbuf_composite (handle, dest.handle, x, y, w, h, offset_x, offset_y,
  550. scale_x, scale_y, interp_type, overall_alpha)
  551. end
  552. end
  553. composite_color (dest: GDK_PIXBUF; dest_x, dest_y, dest_width, dest_height: INTEGER;
  554. offset_x, offset_y, scale_x, scale_y: REAL_64;
  555. interp_type: INTEGER; overall_alpha, check_x, check_y, check_size: INTEGER;
  556. color1, color2: INTEGER_64) is
  557. -- Creates a transformation of the source image Current by
  558. -- scaling by `scale_x' and `scale_y' then translating by `offset_x'
  559. -- and `offset_y', then composites the rectangle (`dest_x' ,`dest_y',
  560. -- `dest_width', `dest_height') of the resulting image with a
  561. -- checkboard of the colors `color1' and `color2' and renders it
  562. -- onto the destination image.
  563. -- See `gdk_pixbuf_composite_color_simple' for a simpler
  564. -- variant of this function suitable for many tasks.
  565. require
  566. colors_conform_guint32: color1 >= 0 and color2 >= 0
  567. valid_alpha: overall_alpha.in_range (0, 255)
  568. valid_check_size: check_size.is_a_power_of_2
  569. valid_interp_type: is_valid_gdk_interp_type (interp_type)
  570. do
  571. if not is_valid then
  572. dest.dispose
  573. dest.set_handle (invalid_pixbuf_handle)
  574. end
  575. if dest.is_valid then
  576. gdk_pixbuf_composite_color (handle, dest.handle, dest_x, dest_y, dest_width, dest_height,
  577. offset_x, offset_y, scale_x, scale_y, interp_type,
  578. overall_alpha, check_x, check_y, check_size, color1, color2)
  579. end
  580. end
  581. invariant
  582. handle.is_not_null
  583. end -- GDK_PIXBUF