Surface.setMimeData

Attach an image in the format mime_type to surface. To remove the data from a surface, call this function with same mime type and NULL for data.

The attached image (or filename) data can later be used by backends which support it (currently: PDF, PS, SVG and Win32 Printing surfaces) to emit this data instead of making a snapshot of the surface. This approach tends to be faster and requires less memory and disk space.

The recognized MIME types are the following: CAIRO_MIME_TYPE_JPEG, CAIRO_MIME_TYPE_PNG, CAIRO_MIME_TYPE_JP2, CAIRO_MIME_TYPE_URI.

See corresponding backend surface docs for details about which MIME types it can handle.

Caution: the associated MIME data will be discarded if you draw on the surface afterwards. Use this function with care.

class Surface
void
setMimeData
(
string type
,
ubyte* data
,
ulong length
,,
void* closure
)

Parameters

data ubyte*

the image data to attach to the surface

length ulong

the length of the image data

destroy cairo_destroy_func_t

a cairo_destroy_func_t which will be called when the surface is destroyed or when new image data is attached using the same mime type.

closure void*

the data to be passed to the destroy notifier

Throws

OutOfMemoryError if a slot could not be allocated for the user data.

TODO: More D-like API

Note: Only use this if you know what your doing! Make sure you get memory management of the passed in data right!

Meta