Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] GTK graphics status

Silenio_Quarti@xxxxxxx writes:
> When a image has transparency (e.g. icons, gifs with transparent pixel), 
> SWT creates
> a GdkPixmap for the color part of the image and a GdkBitmap for the mask.
>

I guess the hard bit is "Image implements Drawable" - otherwise you
could just implement Image as a pixbuf instead of a pixmap.

> We are using GdkPixBuf to scale the GdkPixmap. If we use a different
> algorithm to scale the GdkBitmap, we might have problems, since different
> algorithms might replicate different pixels.

Good point.

> So if we use our own algorithm the scale a GdkBitmap, I believe we will 
> have to
> use it the scale its associated GdkPixmap too.

As you probably know that's a world of pain, since you have around 20
common GdkImage pixel formats to deal with, each in two possible byte
orders...

> Right now, we are getting a GdkPixBuf with alha channel from the 
> GdkPixmap,
> getting the mask data using GdkImage, combining them by replacing the 
> alpha
> channel with appropriate values (e.g. 1 -> 255, 0 -> 0), scaling the 
> GdkPixBuf and
> then redering to the destination drawable by calling 
> gdk_pixbuf_render_to_drawable_alpha.
> 
> This is somewhat inneficient though.

Yeah it's pretty ugly, but I can't think of anything much better.  It
will be slow but not _that_ bad, as long as you don't do it on every
expose event or something.

There's a gdk_pixbuf_render_pixmap_and_mask() convenience function
too, FWIW, which you can use to generate a new pixmap/mask after
scaling the pixbuf.

Havoc


Back to the top