RE: transparent pixels with pixmap
- From: martyn 2 russell bt com
- To: gbabusia ulb ac be, gtk-app-devel-list gnome org
- Subject: RE: transparent pixels with pixmap
- Date: Wed, 20 Mar 2002 10:35:49 -0000
This is how to do it, first I usually have a function to create the pixmap
(where the widget passed is the usually the window):
GtkWidget * getPixmapFromFile(GtkWidget *widget, const gchar *filename)
{
GtkWidget *pixmap;
GdkColormap *colormap;
GdkPixmap *gdkpixmap;
GdkBitmap *mask;
if(!filename || !filename[0])
return NULL;
colormap = gtk_widget_get_colormap (widget);
gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
NULL, filename);
if(gdkpixmap == NULL)
{
printf("**** couldn't create pixmap from file: '%s'\n",filename);
return NULL;
}
pixmap = gtk_pixmap_new (gdkpixmap, mask);
gdk_pixmap_unref (gdkpixmap);
gdk_bitmap_unref (mask);
return pixmap;
}
Then, I load the pixmap into the GtkObject:
.
.
.
GtkWidget *window = ...
GtkWidget *pixmap = NULL;
/* get image */
pixmap = getPixmapFromFile(window, filename);
if(pixmap != NULL)
{
gtk_pixmap_set(GTK_PIXMAP(mycontrol),
GTK_PIXMAP(pixmap)->pixmap,
GTK_PIXMAP(pixmap)->mask);
}
gtk_widget_show(mycontrol);
.
.
.
Hope this helps,
Regards,
Martyn
-----Original Message-----
From: Gregory Babusiaux [mailto:gbabusia ulb ac be]
Sent: 19 March 2002 22:24
To: gtk-app-devel-list gnome org
Subject: transparent pixels with pixmap
Hi !
I have a .xpm with some transparent pixels (made with gimp) I wish to load
in a GdkPixmap but transparent pixels are white displayed.
Here is how I try to do that :
pixmap=gdk_pixmap_colormap_create_from_xpm(NULL,
gtk_widget_get_colormap(window), &trans_mask, NULL, "/.pic.xpm");
where 'window' is correctly initialised and trans_mask copied/pasted from a
.xbm made with gimp (representing the pixels I don't want to diplay, I
changed 'static unsigned short' with 'static unsigned char' to match the
second parameter of gdk_bitmap_create_from_data() )
I tried with a GdkColor as transparent color and change the .xpm to match
the color(transparent pixel -> white), doesn't work too.
Can you give me an advice please ?
Greg
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]