Gdk.Pixbuf.GetFromImage Method
Gets an image from a Gdk.Image

Syntax

public Pixbuf GetFromImage (Image src, Colormap cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)

Parameters

src
Source Gdk.Image.
cmap
A colormap (if src does not have one set) (A Gdk.Colormap
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 value of the Pixbuf (the same one that was passed) or null on error. See the remarks below for details on the possible ways on which this function might fail.

Remarks

Transfers image data from a Gdk.Image and converts it to an RGB(A) representation inside a Gdk.Pixbuf. In other words, copies image data from the Image (which might be potentially shared using shared memory between the client and the server) to a client-side RGB(A) buffer (the Pixbuf). This allows you to efficiently read individual pixels on the client side.

If the image has no colormap (Image.Colormap returns null), then a suitable colormap must be specified. Typically a Gdk.Window or a pixmap created by passing a Gdk.Window to the Gdk.Pixmap constructor will already have a colormap associated with it. If the image has a colormap, the cmap argument will be ignored. If the image is a bitmap (1 bit per pixel pixmap), then a colormap is not required; pixels with a value of 1 are assumed to be white, and pixels with a value of 0 are assumed to be black. For taking screenshots, the Colormap.System property returns the correct colormap to use.

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. If the specified destination pixbuf is not null and it contains alpha information, then the filled pixels will be set to full opacity (alpha = 255).

If the specified image is a pixmap, then the requested source rectangle must be completely contained within the pixmap, otherwise the function will return null. For pixmaps only (not for windows) passing -1 for width or height is allowed, to mean the full width or height of the pixmap.

If the specified image is a window, and the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf. The contents of portions of the Gdk.Pixbuf corresponding to the offscreen region are undefined.

If the window you are obtaining data from is partially obscured by other windows, then the contents of the Pixbuf areas corresponding to the obscured regions are undefined.

If the target image is not mapped (typically because it's iconified/minimized or not on the current workspace), then null will be returned.

If memory can't be allocated for the return value, null will be returned instead.

(In short, there are several ways this function can fail, and if it fails it returns null; so check the return value.)

Requirements

Namespace: Gdk
Assembly: gdk-sharp (in gdk-sharp.dll)