Subject:
Re: [nanogui] Transparent pixmap
From:
"Greg Haerr" ####@####.####
Date:
29 Feb 2008 00:53:05 -0000
Message-Id: <104601c87a6d$638fc6d0$6401a8c0@gregnewport>
> I
> run nano-x for the Linux-X86 platform using the X11 library.
This means the driver you will have to check for
SRCTRANSCOPY support will be drivers/scr_x11.c, see below.
> 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.
You'll want to use the SRCTRANSCOPY rather than MWMODE_COPY
to get the transparent blit. However, not all drivers implement this.
You should look at the code in drivers/fblin16.c, as I think that
driver (RGB565) implements it (I don't have the source here, I'm
traveling). Of course, your running on X11 which means that
scr_x11.c needs to have the support.
When I return I can look at this more deeply for you. Also
look at the code in engine/devdraw.c::GdBlit(), as that's
what GrCopyArea calls (check in nanox/srvfunc.c)
Regards,
Greg
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
>