PageRenderTime 15ms CodeModel.GetById 7ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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