GDK Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gdk/gdk.h> void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int alpha_threshold); void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, GdkDrawable *drawable, GdkGC *gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkRgbDither dither, int x_dither, int y_dither); void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkPixbufAlphaMode alpha_mode, int alpha_threshold, GdkRgbDither dither, int x_dither, int y_dither); void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold); GdkPixbuf* gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height); |
void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int alpha_threshold); |
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. |
void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, GdkDrawable *drawable, GdkGC *gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkRgbDither dither, int x_dither, int y_dither); |
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_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkPixbufAlphaMode alpha_mode, int alpha_threshold, GdkRgbDither dither, int x_dither, int y_dither); |
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 GDK_PIXBUF_ALPHA_BILEVEL, this function has to create a bitmap out of the thresholded alpha channel of the image and, it has to set this bitmap as the clipping mask for the GC used for drawing. This can be a significant performance penalty depending on the size and the complexity of the alpha channel of the image. If performance is crucial, consider handling the alpha channel yourself (possibly by caching it in your application) and using gdk_pixbuf_render_to_drawable() or GdkRGB directly instead.
The GDK_PIXBUF_ALPHA_FULL mode involves round trips to the X server, and may also be somewhat slow in its current implementation (though in the future it could be made significantly faster, in principle).
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_pixmap_and_mask (GdkPixbuf *pixbuf, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold); |
Creates a pixmap and a mask bitmap which are returned in the pixmap_return and mask_return arguments, respectively, and renders a pixbuf and its corresponding tresholded alpha mask to them. This is merely a convenience function; applications that need to render pixbufs with dither offsets or to given drawables should use gdk_pixbuf_render_to_drawable_alpha() or gdk_pixbuf_render_to_drawable(), and gdk_pixbuf_render_threshold_alpha().
If the pixbuf does not have an alpha channel, then *mask_return will be set to NULL.
pixbuf : | A pixbuf. |
pixmap_return : | Return value for the created pixmap. |
mask_return : | Return value for the created mask. |
alpha_threshold : | Threshold value for opacity values. |
GdkPixbuf* gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height); |
Transfers image data from a Gdk drawable and converts it to an RGB(A) representation inside a GdkPixbuf.
If the drawable src is a pixmap, then a suitable colormap must be specified, since pixmaps are just blocks of pixel data without an associated colormap. If the drawable is a window, the cmap argument will be ignored and the window's own colormap will be used instead.
If the specified destination pixbuf dest is NULL, then this function will create an RGB pixbuf with 8 bits per channel and no alpha, with the same size specified by the width and height arguments. In this case, the dest_x and dest_y arguments must be specified as 0, otherwise the function will return NULL. If the specified destination pixbuf is not NULL and it contains alpha information, then the filled pixels will be set to full opacity.
If the specified drawable is a pixmap, then the requested source rectangle must be completely contained within the pixmap, otherwise the function will return NULL.
If the specified drawable is a window, then it must be viewable, i.e. all of its ancestors up to the root window must be mapped. Also, the specified source rectangle must be completely contained within the window and within the screen. If regions of the window are obscured by noninferior windows, the contents of those regions are undefined. The contents of regions obscured by inferior windows of a different depth than that of the source window will also be undefined.
dest : | Destination pixbuf, or NULL if a new pixbuf should be created. |
src : | Source drawable. |
cmap : | A colormap if src is a pixmap. If it is a window, this argument will be ignored. |
src_x : | Source X coordinate within drawable. |
src_y : | Source Y coordinate within drawable. |
dest_x : | Destination X coordinate in pixbuf, or 0 if dest is NULL. |
dest_y : | Destination Y coordinate in pixbuf, or 0 if dest is NULL. |
width : | Width in pixels of region to get. |
height : | Height in pixels of region to get. |
Returns : | The same pixbuf as dest if it was non-NULL, or a newly-created pixbuf with a reference count of 1 if no destination pixbuf was specified; in the latter case, NULL will be returned if not enough memory could be allocated for the pixbuf to be created. |