Re: quick Qs about pixbuf manipulation



Bill Haneman <bill haneman sun com> writes:

> Hi:
> 
> I have a couple of quick questions that I hope someone can answer
> regarding the most efficient ways to:
> 
> * modify a gdk-pixbuf's colormap on-the-fly

GdkPixbufs don't really have colormaps.  Do you mean the colormap of the
drawable you're drawing to?  What are you trying to do?

> * access pixels on-the-fly

If you want to look at the actual pixels of a pixbuf, use
gdk_pixbuf_get_pixels().  This is an array of chars in rgb or rgba
format, gdk_pixbuf_get_rowstride () wide by gdk_pixbuf_get_height()
tall.

> I need to grab an image, recolor and/or scale it, and render it back
> into a GdkDrawable.  Using gtk_image_get/put_pixel is *waaaay* slow.

You prolly want gdk_pixbuf_render_to_drawable instead.

> Mostly I use gdk_pixbuf_scale () for the rescaling, but sometimes I need
> a different scaling algorithm.  

Why?  What's wrong with the existing scaling algorithms?

> * should I write new gdk_pixbuf scaling algorithms for submission? or
> * is there a better way to access the pixbuf internals?

You can do either, but I'd only do that as a last resort.  What exactly
are your problems here?

> As for recoloring it, seems like replacing the colormap before rendering
> the image would do the trick, but I can't seem to find the right API.
> 
> Thanks in advance, apologies for posting a mostly "how-do-I" type of
> question to *dev.

Indeed.  This may be better brought up on gtk-app-devel-list gnome org
in the followups.

Thanks,
-Jonathan



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