The GdkPixbuf Library | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gdk-pixbuf/gdk-pixbuf.h> enum GdkPixbufAlphaMode; void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, |
The GdkPixbuf library provides several convenience functions to render pixbufs to GDK drawables. It uses the GdkRGB to render the image data.
At this point there is not a standard alpha channel extension for the X Window System, so it is not possible to use full opacity information when painting images to arbitrary drawables. The GdkPixbuf convenience functions will threshold the opacity information to create a bi-level clipping mask (black and white), and use that to draw the image onto a drawable.
typedef enum { GDK_PIXBUF_ALPHA_BILEVEL, GDK_PIXBUF_ALPHA_FULL } GdkPixbufAlphaMode; |
These values can be passed to gdk_pixbuf_render_to_drawable_alpha() to control how the alpha chanel of an image should be handled. This function can create a bilevel clipping mask (black and white) and use it while painting the image. In the future, when the X Window System gets an alpha channel extension, it will be possible to do full alpha compositing onto arbitrary drawables. For now both cases fall back to a bilevel clipping mask.
GDK_PIXBUF_ALPHA_BILEVEL | A bilevel clipping mask (black and white) will be created and used to draw the image. Pixels below 0.5 opacity will be considered fully transparent, and all others will be considered fully opaque. |
GDK_PIXBUF_ALPHA_FULL | For now falls back to |
void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, |
Renders a rectangular portion of a pixbuf to a drawable. This is done using GdkRGB, so the specified drawable must have the GdkRGB visual and colormap.
When used with
pixbuf : | A pixbuf. |
drawable : | Destination drawable. |
src_x : | Source X coordinate within pixbuf. |
src_y : | Source Y coordinates within pixbuf. |
dest_x : | Destination X coordinate within drawable. |
dest_y : | Destination Y coordinate within drawable. |
width : | Width of region to render, in pixels. |
height : | Height of region to render, in pixels. |
alpha_mode : | If the image does not have opacity information, this is ignored. Otherwise, specifies how to handle transparency when rendering. |
alpha_threshold : | If the image does have opacity information and alpha_mode is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity values. |
dither : | Dithering mode for GdkRGB. |
x_dither : | X offset for dither. |
y_dither : | Y offset for dither. |
void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, |
Renders a rectangular portion of a pixbuf to a drawable while using the specified GC. This is done using GdkRGB, so the specified drawable must have the GdkRGB visual and colormap. Note that this function will ignore the opacity information for images with an alpha channel; the GC must already have the clipping mask set if you want transparent regions to show through.
For an explanation of dither offsets, see the GdkRGB documentation. In brief, the dither offset is important when re-rendering partial regions of an image to a rendered version of the full image, or for when the offsets to a base position change, as in scrolling. The dither matrix has to be shifted for consistent visual results. If you do not have any of these cases, the dither offsets can be both zero.
pixbuf : | A pixbuf. |
drawable : | Destination drawable. |
gc : | GC used for rendering. |
src_x : | Source X coordinate within pixbuf. |
src_y : | Source Y coordinate within pixbuf. |
dest_x : | Destination X coordinate within drawable. |
dest_y : | Destination Y coordinate within drawable. |
width : | Width of region to render, in pixels. |
height : | Height of region to render, in pixels. |
dither : | Dithering mode for GdkRGB. |
x_dither : | X offset for dither. |
y_dither : | Y offset for dither. |
void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, |
Takes the opacity values in a rectangular portion of a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.
pixbuf : | A pixbuf. |
bitmap : | Bitmap where the bilevel mask will be painted to. |
src_x : | Source X coordinate. |
src_y : | source Y coordinate. |
dest_x : | Destination X coordinate. |
dest_y : | Destination Y coordinate. |
width : | Width of region to threshold. |
height : | Height of region to threshold. |
alpha_threshold : | Opacity values below this will be painted as zero; all other values will be painted as one. |