Re: How can I save a PNG file from a GdkPixbuf



On Sun, 2004-10-24 at 16:15 -0400, Jack Chen wrote:
> Hi, dear list members,
> 
> I have a problem that I hope someone can help me with. I would like to
> save a GdkPixbuf to a PNG file using either 
> 
> gdk_pixbuf_savev (GdkPixbuf *pixbuf,
>                   const char *filename,
>                   const char *type,
>                   char **option_keys,
>                   char **option_values,
>                   GError **error);
> 
> or
> 
> gdk_pixbuf_save (GdkPixbuf *pixbuf,
>                  const char *filename,
>                  const char *type,
>                  GError **error,
>                  ...);
> 
> The problem is I don't know what those 'option...s' are for, and if I
> leave them all as NULL, the program can compile, but will crash after
> starting. I think the problem is I don't know what 'options' to specify
> for the PNG format. I can save a JEPG file no problem because there's a
> sample source code in the GdkPixbuf's reference, but there's no example
> for PNG.
> 
> I will really appreciate it if someone can help me out with this
> problem.
> 
> Thank you.
> 
> Jack

The options are for passing metadata to the png module to use when
saving. You should be able to call gdk_pixbuf_save() with a NULL "..."
without it crashing (the savev requires an strv array, though the first
element in the array can be NULL)

e.g.:

char *keys[1] = {
    NULL
};
char *vals[1] = {
    NULL
};

gdk_pixbuf_savev (pixbuf, "some-filename.png", "image/png", keys,
values, NULL);

or

gdk_pixbuf_save (pixbuf, "some-filename.png", "image/png", NULL, NULL);

-- 
Peace,

    Jim Cape
    http://esco.mine.nu
    http://ignore-your.tv

    "If even one reporter had stood up during a pre-Iraq Bush press
     conference last year and shouted, `Bullshit!' it might have made a
     difference."
        -- Matt Taibbi, New York Press

Attachment: signature.asc
Description: This is a digitally signed message part



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