nanogui: Transparent pixmap


Previous by date: 24 Feb 2008 15:44:09 -0000 Transparent pixmap, nanogui.reliableembeddedsystems.com
Next by date: 24 Feb 2008 15:44:09 -0000 Re: Transparent pixmap, Fredrik Johansson
Previous in thread: 24 Feb 2008 15:44:09 -0000 Transparent pixmap, nanogui.reliableembeddedsystems.com
Next in thread: 24 Feb 2008 15:44:09 -0000 Re: Transparent pixmap, Fredrik Johansson

Subject: Transparent pixmap
From: ####@####.####
Date: 24 Feb 2008 15:44:09 -0000
Message-Id: <32829.127.0.0.1.1203867837.squirrel@localhost>

Hello,

i want to copy the contents of a pixmap on to the screen. The pixmap
contains a gif with a transparent background (=> alpha = 0). When i
copy the pixmap to the screen the transparent background is visible. I
run nano-x for the Linux-X86 platform using the X11 library. When
drawing the gif directly to the screen the transparent background is,
correctly, not visisble. I attach a simple example which demonstrates
the problem. In the example i do not load the gif, instead i have two
pixmaps: one painted with red color (alpha = 0) and the other with
blue (alpha = 255). Still, the red is visible. I also tried the
SRCTRANSCOPY mode as arhument in the GrCopyArea, but i am not sure if
this mode of operation is actually implemented. Any help is greatly
appreciated.

-------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#define MWINCLUDECOLORS
#include "nano-X.h"

int main(int argc, char **argv)
{
        GR_WINDOW_ID pid1, pid2;
        GR_GC_ID gc;
        GR_EVENT event;
        int width, height;
        char c;

        if( GrOpen() < 0 )
        {
                printf("cannot open graphics\n");
                exit(1);
        }

        width = height = 100;

        GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_KEY_DOWN);

        gc = GrNewGC();

        pid1 = GrNewPixmap(width, height, NULL);
        GrSetGCForeground(gc, MWARGB(0,255,0,0));
        GrFillRect(pid1, gc, 0, 0, width, height);

        pid2 = GrNewPixmap(width, height, NULL);
        GrSetGCForeground(gc, MWARGB(255,0,0,255));
        GrFillRect(pid2, gc, 0, 0, width, height);

        GrCopyArea(GR_ROOT_WINDOW_ID, gc, 100, 100, width, height, pid2, 0,
0, MWMODE_COPY);

        GrCopyArea(GR_ROOT_WINDOW_ID, gc, 150, 150, width, height, pid1, 0,
0, MWMODE_COPY);

        while(1)
        {
                GrGetNextEvent(&event);
                switch (event.type)
                {
                        case GR_EVENT_TYPE_KEY_DOWN:
                                c = event.keystroke.ch;
                                if(c == 'q')
                                {
                                        GrClose();
                                        exit(0);
                                }
                                break;
                        default:
                                break;
                }
        }
}
--------------------------------------------------------------------------

Thanks in advance

Previous by date: 24 Feb 2008 15:44:09 -0000 Transparent pixmap, nanogui.reliableembeddedsystems.com
Next by date: 24 Feb 2008 15:44:09 -0000 Re: Transparent pixmap, Fredrik Johansson
Previous in thread: 24 Feb 2008 15:44:09 -0000 Transparent pixmap, nanogui.reliableembeddedsystems.com
Next in thread: 24 Feb 2008 15:44:09 -0000 Re: Transparent pixmap, Fredrik Johansson


Powered by ezmlm-browse 0.20.