Gtk Pixmap and png
- From: Arno <dark-arno ifrance com>
- To: Mailling List gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Gtk Pixmap and png
- Date: Thu, 25 Jul 2002 01:37:59 +0200
Hello,
I have a little problem with the creation of gtk pixmap. I have my icone
in png with transparent background. I want to use it to create my icone
to insert in my toolbar. So I do :
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *icone;
pixbuf = gdk_pixbuf_new_from_file("../Back-prelight.png", NULL);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 0);
icone = gtk_pixmap_new (pixmap, mask);
gtk_toolbar_insert_item (GTK_TOOLBAR (toolbar),
"Back",
"bla bla",
NULL,
icone,
NULL,
NULL,
-1);
But the background of the icone doesn't have to good color as you can
see in this picture (The first one at left)
http://www.arnoraes.freesurf.fr/Forum/icone.png.
So I convert my picture in xpm and with the same code, I obtain the
second icone. The icone doesn't have the good background color.
Finally, I create this function :
GtkWidget*
pixmap_to_widget(GtkWidget *window, char *xpm[])
{
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *gtkpixmap;
GtkStyle *style;
gtk_widget_show(window);
style = gtk_widget_get_style (window);
pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask,
&style->bg[GTK_STATE_NORMAL], xpm);
gtkpixmap = gtk_pixmap_new (pixmap, mask);
gtk_widget_show (gtkpixmap);
gdk_pixmap_unref(pixmap);
gdk_pixmap_unref(mask);
return (gtkpixmap);
}
And, I create my icone with :
#include "../Back-prelight.xpm"
gtk_toolbar_insert_item (GTK_TOOLBAR (toolbar),
"Back",
"bla bla",
NULL,
pixmap_to_widget(win, Back_prelight_xpm),
NULL,
NULL,
-1);
Now it's good, the background of the icone is good. But like you can see
in the screenshot (http://www.arnoraes.freesurf.fr/Forum/icone.png), the
contour of the icones is not fuzzy.
So, how could I use png picture with transparent background.
Thank you
Arno
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]