Re: GdkBitmap structure - 3 questions



>    Thanks to Sven for the advice, I tried with no luck... what I want to do
>is to load a bitmap from a png (and I do this with GdkPixbuf, fine), then
>create another one with the negative image of it, and use them both with
>gtk_widget_shape_combine_mask. So, I wrote this:

if you're trying to get non-rectangular windows (which is what
shape_combine_mask operations are typically used for), then you just
use the bitmap that gets created along with the pixmap as the mask.
forget about "manually" inverting the image. partial example code
(from a C++ context) below:

--p

void
Pix::generate (GdkWindow *win, GdkColor *transparent)

{
	size_t i;
	size_t w, h;

	if (generated) {
		return;
	}

	for (i = 0; i < pixmap_count; i++) {
		string *strp;
		
		strp = (*files)[i];

		if (win == NULL) {
			pixmaps[i] = gdk_pixmap_colormap_create_from_xpm 
				(NULL, gdk_colormap_get_system(),
				 &bitmaps[i], NULL, strp->c_str());
		} else {
			pixmaps[i] = gdk_pixmap_create_from_xpm 
				(win, &bitmaps[i], transparent, strp->c_str());
		}

		gdk_window_get_size (pixmaps[i],  (gint *) &w, (gint *) &h);
		if (w > max_pixwidth) max_pixwidth = w;
		if (h > max_pixheight) max_pixheight = h;
	}

	generated = true;
}

  class Pix { 
        ....

        GdkBitmap *shape_mask (size_t n) {
		if (n < pixmap_count) {
			return bitmaps[n];
		} 
		return 0;
	}
        ....
  }


	pix->generate(get_window(),(GdkColor *)&mystyle->bg[GTK_STATE_NORMAL]);
	gdk_window_get_size (pix->pixmap (0), &width, &height);
	set_usize (width, height);
	gtk_widget_shape_combine_mask (GTK_WIDGET(parent->gtkobj()),
				       pix->shape_mask (0),
				       0, 0);








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