cairo::image_surface+x86_64 +linux

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.

Index

Functions

fn create(format: cairo::format_t, width: int, height: int) (*cairo::surface_t | cairo::error);
fn create_for_data(data: *u8, format: cairo::format_t, width: int, height: int, stride: int) (*cairo::surface_t | cairo::error);
fn create_from_png(filename: str) (*cairo::surface_t | cairo::error);
fn get_data(surface: *cairo::surface_t) (*u8 | cairo::error);
fn get_format(surface: *cairo::surface_t) cairo::format_t;
fn get_height(surface: *cairo::surface_t) int;
fn get_stride(surface: *cairo::surface_t) int;
fn get_width(surface: *cairo::surface_t) int;

Functions

fn create[link]

fn create(format: cairo::format_t, width: int, height: int) (*cairo::surface_t | cairo::error);

Creates an image surface of the specified format and dimensions. Initially the surface contents are set to 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).

Parameters

Returns the newly created surface. The caller owns the surface and should call cairo::surface::destroy when done with it. If an error such as out of memory occurs, cairo::error is returned instead.

fn create_for_data[link]

fn create_for_data(data: *u8, format: cairo::format_t, width: int, height: int, stride: int) (*cairo::surface_t | cairo::error);

XXX: Creates an image surface for the provided pixel data. The output buffer must be kept around until the cairo::surface_t is destroyed or cairo::surface::finish is called on the surface. The initial contents of data will be used as the initial image contents; you must explicitly clear the buffer, using, for example, cairo::rectangle and cairo::fill if you want it cleared.

Note that the stride may be larger than width*bytes_per_pixel to provide proper alignment for each pixel and row. This alignment is required to allow high-performance rendering within cairo. The correct way to obtain a legal stride value is to call format_stride_for_width with the desired format and maximum image width value, and then use the resulting stride value to allocate the data and to create the image surface. See format_stride_for_width for example code.

Parameters

Returns the newly created surface. The caller owns the surface and should call cairo::surface::destroy when done with it. In case of an error such as out of memory or an invalid stride value, cairo::error is returned instead.

See cairo::surface::set_user_data for a means of attaching a destroy-notification fallback to the surface if necessary.

fn create_from_png[link]

fn create_from_png(filename: str) (*cairo::surface_t | cairo::error);

Returns a new cairo::surface_t initialized with the contents of the PNG file, or a cairo::error if any error occurred.

fn get_data[link]

fn get_data(surface: *cairo::surface_t) (*u8 | cairo::error);

XXX: Get a pointer to the data of the image surface, for direct inspection or modification.

A call to cairo::surface::flush is required before accessing the pixel data to ensure that all pending drawing operations are finished. A call to cairo::surface::mark_dirty is required after the data is modified.

Returns a pointer to the image data of this surface or cairo::error if surface is not an image surface, or if cairo::surface::finish has been called.

fn get_format[link]

fn get_format(surface: *cairo::surface_t) cairo::format_t;

Get the format cairo::format_t of the surface.

fn get_height[link]

fn get_height(surface: *cairo::surface_t) int;

Get the height of the image surface in pixels.

fn get_stride[link]

fn get_stride(surface: *cairo::surface_t) int;

Returns 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.

fn get_width[link]

fn get_width(surface: *cairo::surface_t) int;

Get the width of the image surface in pixels.