Name
cairo.ImageSurface -- create image surface
Synopsis
handle = cairo.ImageSurface(format, width, height)
Function
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).

The format argument can be one of the following pixel formats:

#CAIRO_FORMAT_ARGB32
Each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. (That is, 50% transparent red is $80800000, not $80ff0000.)

#CAIRO_FORMAT_RGB24
Each pixel is a 32-bit quantity, with the upper 8 bits unused. Red, green, and blue are stored in the remaining 24 bits in that order.

#CAIRO_FORMAT_A8
Each pixel is a 8-bit quantity holding an alpha value.

#CAIRO_FORMAT_A1
Each pixel is a 1-bit quantity holding an alpha value. Pixels are packed together into 32-bit quantities. The ordering of the bits matches the endianness of the platform. On a big-endian machine, the first pixel is in the uppermost bit, on a little-endian machine the first pixel is in the least-significant bit.

#CAIRO_FORMAT_RGB16_565
Each pixel is a 16-bit quantity with red in the upper 5 bits, then green in the middle 6 bits, and blue in the lower 5 bits.

#CAIRO_FORMAT_RGB30
Like RGB24 but with 10bpc.

This function returns a handle to the newly created surface. The caller owns the surface and should call csurface:Free() when done with it.

This function always returns a valid handle, but it will return a handle to a "nil" surface if an error such as out of memory occurs. You can use csurface:Status() to check for this.

Inputs
format
format of pixels in the surface to create (see above)
width
width of the surface, in pixels
height
height of the surface, in pixels
Results
handle
image surface

Show TOC