Re: Creating GdkPixbuf from PNG data



On Fri, Jan 07, 2005 at 11:19:13AM -0500, Tristan Van Berkom wrote:
> On Fri, 7 Jan 2005 16:38:25 +0100, David Necas (Yeti)
> <yeti physics muni cz> wrote:
> [...]
> > I don't think so.  This function creates a pixbuf from
> > a `serialized' GdkPixbuf, created by gdk-pixbuf-csource.
> > 
> > I would probably dump the data to a PNG file and use
> > gdk_pixbuf_load().  That's not optimal, but if it's not
> > a something the app needs to do often...  Another question
> > is how did you get the `essentially the contents of a png
> > file'?  It may be easier to create a pixbuf from some
> > original data...
> 
> Ouch, your right; there seems to be no way to do this, 
> that would really bite :-/
> 
> Cheers,
>                                      -Tristan

the current interface is more flexible:

GdkPixbuf *load_from_mem (gconstpointer buf, gsize count)
{
  GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
  GError *error = NULL;
  if (!gdk_pixbuf_loader_write (loader, buf, count, &error)
   || !gdk_pixbuf_loader_close (loader, &error))
    g_error("error parsing image: %s", error->message);
  GdkPixbuf *rv = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));
  g_object_unref (loader);
  return rv;
} // untested
 
- dave



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