pixman_image_t * FbCreateAlphaPicture (pixman_image_t *dst, pixman_format_t *format, uint16_t width, uint16_t height) { pixman_image_t *image; int own_format = 0; if (width > 32767 || height > 32767) return NULL; if (!format) { own_format = 1; if (dst->polyEdge == PolyEdgeSharp) format = pixman_format_create (PIXMAN_FORMAT_NAME_A1); else format = pixman_format_create (PIXMAN_FORMAT_NAME_A8); if (!format) return NULL; } image = pixman_image_create (format, width, height); if (own_format) pixman_format_destroy (format); /* XXX: Is this a reasonable way to clear the image? Would probably be preferable to use pixman_image_fill_rectangle once such a beast exists. */ memset (image->pixels->data, 0, height * image->pixels->stride); return image; }
/** * cairo_image_surface_create: * @format: format of pixels in the surface to create * @width: width of the surface, in pixels * @height: height of the surface, in pixels * * Creates an image surface of the specified format and * dimensions. The initial contents of the surface is undefined; you * must explicitly initialize the surface contents, using, for * example, cairo_paint(). * * Return value: 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 * cairo_image_surface_create (cairo_format_t format, int width, int height) { cairo_surface_t *surface; pixman_format_t *pixman_format; pixman_image_t *pixman_image; if (! CAIRO_FORMAT_VALID (format)) return (cairo_surface_t*) &_cairo_surface_nil; pixman_format = _create_pixman_format (format); if (pixman_format == NULL) { _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_surface_t*) &_cairo_surface_nil; } pixman_image = pixman_image_create (pixman_format, width, height); pixman_format_destroy (pixman_format); if (pixman_image == NULL) { _cairo_error (CAIRO_STATUS_NO_MEMORY); return (cairo_surface_t*) &_cairo_surface_nil; } surface = _cairo_image_surface_create_for_pixman_image (pixman_image, format); return surface; }