FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

From an ImageSurface to a Pixbuf

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
teales



Joined: 21 May 2007
Posts: 24
Location: Bangalore

PostPosted: Fri Sep 02, 2011 12:53 pm    Post subject: From an ImageSurface to a Pixbuf Reply with quote

The GTK documentation is a bit cryptic around this point. The following might help:

extern(C) cairo_status_t imgWriteFunc(void* closure,
uchar* data, uint len)
{
PixbufLoader pbl = cast(PixbufLoader) closure;
char[] t;
t.length = len;
t[] = cast(char[]) data[0..len];
int rv = pbl.write(t);
return rv? cairo_status_t.SUCCESS: cairo_status_t.WRITE_ERROR;
}

Pixbuf getPixbuf()
{
ImageSurface isf = ImageSurface.create(cairo_format_t.RGB24,
width, height);
Context isc = Context.create(isf);
render(isc);
PixbufLoader pbl = new PixbufLoader();
isf.writeToPngStream (&imgWriteFunc, cast(void*) pbl);
pbl.close();
return pbl.getPixbuf();
}

This is hacked out of my code, and not tested, but it should show the way.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group