Drawing data from cairo surface to a pixbuf



Hello.

I have a problem with loading data that I got from an cairo image
surface with cairo_image_surface_get_data(). I got the data with:
-------------------------------
long width, height, len;
char *data, *data_tmp;

data_tmp = cairo_image_surface_get_data(surface);
width = cairo_image_surface_get_width(surface);
stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, width);
height = cairo_image_surface_get_height(surface);
data = g_malloc(stride * height);
memcpy(data, data_tmp, stride * height);
len = stride * height;
ï-------------------------------

Then I try to load that data with PixbufLoader:
ï-------------------------------
...
loader = gdk_pixbuf_loader_new();
gdk_pixbuf_loader_write(loader, data, len, &error);
...
ï-------------------------------

But loading from data failed with error "unknown image file format".

Is there another way to load that data? Please help.

Greets,
Luka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]