Re: gtk pixmap with transparent background question - What am I doing wrong???



        I'm not sure if there is a convinient way to
get transperency with Pixmaps (could be) but I know
you can easily do this with GdkPixbuf.

see:
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Drawing-Primitives.html#gdk-draw-pixbuf


What I noticed in your code is that you dont
apply your image with transperency to anything.

        gtk_pixmap_set(pixmapc,pmu,bmu);
        gtk_widget_show(pixmapc);

Don't you need to render this pixmap and bitmask to a
background (that you need also to aquire) in order
to see the transperency ?

Cheers,
        -Tristan


Kimet Adil wrote:

Hi,

I am trying to witre an app that has animated gtkpixmaps crawling over the
page. I am using Anjust+Glade, so there is a lot of code. It all works well
except I want transparent backgrounds and they stay white, and cover each
other if they collide. I know this is a long email but I just dont know how
to ask the question completely without all the code Here are the key
functions:

struct pickies {

        GdkPixmap *pm;
        GdkBitmap *bm;
        struct pickies *next;

};

        struct pickies p1,p2,p3,x1,x2,x3,x4,*xs,*s;
        GdkPixmap *pm1;

        int tx=250,ty=250;
        static int vx=5, vy=0;

/* load the pixmaps

void on_button1_clicked  (GtkButton       *button,    gpointer   user_data)
{
 GtkStyle *style;
        GtkWidget *pixmapa,*pixmapb;
        GtkWidget *window;
        pixmapa = lookup_widget(button,"pixmap2");
        pixmapb = lookup_widget(button,"pixmap1");
        window=lookup_widget(button,"window1");
         style = gtk_widget_get_style( window );
    p1.pm = gdk_pixmap_create_from_xpm( window->window,&p1.bm,NULL,"930e1.xpm"
);
    p1.next=&p2;
        p2.pm = gdk_pixmap_create_from_xpm( window->window, &p2.bm,NULL,"930e2.xpm"
);
    p2.next=&p3;
        p3.pm = gdk_pixmap_create_from_xpm( window->window,
&p3.bm,&style->bg[GTK_STATE_NORMAL],"930e3.xpm" );
    p3.next=&p1;
        s=&p1;


    x1.pm = gdk_pixmap_create_from_xpm( window->window,
x1.bm,NULL,"XPB4100-1.xpm" );
    x1.next=&x2;
        x2.pm = gdk_pixmap_create_from_xpm( window->window,
x2.bm,NULL,"XPB4100-2.xpm" );
    x2.next=&x3;
        x3.pm = gdk_pixmap_create_from_xpm( window->window,
x3.bm,NULL,"XPB4100-3.xpm" );
    x3.next=&x4;
        x4.pm = gdk_pixmap_create_from_xpm( window->window,
x4.bm,NULL,"XPB4100-4.xpm" );
    x4.next=&x1;
        xs=&x1;



}

void anim(GtkWidget *button2)
{
        GtkWidget *pixmapc;
        GtkWidget *window;
        GdkPixmap *pmu;
        GdkBitmap *bmu;
        s=s->next;
        pmu=s->pm;
        bmu=s->bm;
        pixmapc = lookup_widget(button2,"pixmap2");
        gtk_pixmap_set(pixmapc,pmu,bmu);
        gtk_widget_show(pixmapc);
}

void movePM(GtkWidget *widget)
{
GtkPixmap *pixmap2;
tx=tx+vx;
        if(tx>500){
        vx=vx*-1;
        }
        if(tx<50){
        vx=vx*-1;
        }
        ty=ty+vy;
        if(ty>500){
        vy=vy*-1;
        }
        if(ty<50){
        vy=vy*-1;
        }
        pixmap2 = lookup_widget(widget,"pixmap2");
 gtk_widget_set_uposition (pixmap2, tx, ty);
}

void animXPB(GtkWidget *button2)
{
        GtkWidget *pixmapc;
        GtkWidget *window;
        GdkPixmap *pmu;
        xs=xs->next;
        pmu=xs->pm;
        pixmapc = lookup_widget(button2,"pixmap1");
        gtk_pixmap_set(pixmapc,xs->pm,xs->bm);
        //gdk_pixmap_unref(pmu);
        gtk_widget_show(pixmapc);
}

void on_button2_clicked (GtkButton       *button,
                                        gpointer         user_data)
{
        GtkPixmap *pixmapc;
        gtk_timeout_add(140,anim,button);
        gtk_timeout_add(700,animXPB,button);
        pixmapc = lookup_widget(button,"pixmap2");
        gtk_timeout_add(90,movePM,button);

        }

Thanks,
Kim
_______________________________________________
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]