Next: PDF Surfaces, Previous: cairo_surface_t, Up: Top [Index]
Rendering to memory buffers
Image surfaces provide the ability to render to memory buffers either
allocated by cairo or by the calling code. The supported image formats
are those defined in <cairo-format-t>
.
<cairo-format-t>
) (width <int>
) ⇒ (ret <int>
)This function provides a stride value that will respect all alignment requirements of the accelerated image-rendering code within cairo. Typical usage will be of the form:
int stride; unsigned char *data; cairo_surface_t *surface; stride = cairo_format_stride_for_width (format, width); data = malloc (stride * height); surface = cairo_image_surface_create_for_data (data, format, width, height, stride);
A <cairo-format-t>
value
The desired width of an image surface to be created.
the appropriate stride to use given the desired format and width, or -1 if either the format is invalid or the width too large.
Since 1.6
<cairo-format-t>
) (width <int>
) (height <int>
) ⇒ (ret <cairo-surface-t >
)Creates an image surface of the specified format and dimensions. Initially the surface contents are all 0. (Specifically, within each pixel, each color or alpha channel belonging to format will be 0. The contents of bits within a pixel, but not belonging to the given format are undefined).
format of pixels in the surface to create
width of the surface, in pixels
height of the surface, in pixels
a pointer to the newly created surface. The caller owns the surface and
should call cairo-surface-destroy
when done with it. This
function always returns a valid pointer, but it will return a pointer to
a "nil" surface if an error such as out of memory occurs. You can use
cairo-surface-status
to check for this.
<cairo-surface-t>
) ⇒ (ret <cairo-format-t>
)Get the format of the surface.
a <cairo-image-surface-t>
the format of the surface
Since 1.2
<cairo-surface-t>
) ⇒ (ret <int>
)Get the width of the image surface in pixels.
a <cairo-image-surface-t>
the width of the surface in pixels.
<cairo-surface-t>
) ⇒ (ret <int>
)Get the height of the image surface in pixels.
a <cairo-image-surface-t>
the height of the surface in pixels.
<cairo-surface-t>
) ⇒ (ret <int>
)Get the stride of the image surface in bytes
a <cairo-image-surface-t>
the stride of the image surface in bytes (or 0 if surface is not an image surface). The stride is the distance in bytes from the beginning of one row of the image data to the beginning of the next row.
Since 1.2
Next: PDF Surfaces, Previous: cairo_surface_t, Up: Top [Index]