Hi, I am trying to find out whether I can use Render to modify the alpha
channel in a frame buffer that's in ARGB 8888 format.   I modified Keith's
sample code slightly to render a red rectangle into the frame buffer with
the destination alpha set to 0x80.  But I get 0x00FF0000 in the frame buffer
instead of the desired 0x80FF0000.

I have included the test program below.  Is there any way to do this with
Render/fb or does it require special hacks?

Jonathan Bian

#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>

Pixmap      color_pix;
Picture     color;
Window      window;
Picture     picture;
Display     *dpy;
int         screen;
Visual      *visual;
XRenderPictFormat   *format_win, *format_pix;

#define     SIZE    200

main ()
{
    XRenderPictureAttributes    pa;
    XRenderPictFormat           pf;
    XEvent                      ev;
    XRenderColor                rc;
    
    rc.red = 0xffff;
    rc.green = 0x0;
    rc.blue = 0x0;
    rc.alpha = 0x8000;

    dpy = XOpenDisplay (0);
    XSynchronize (dpy, 1);
    if (!dpy) exit(1);
    screen = DefaultScreen (dpy);
    visual = DefaultVisual (dpy, screen);
    format_win = XRenderFindVisualFormat (dpy, visual);
    if (!format_win) exit(1);

    pf.depth = 32;
    pf.type = PictTypeDirect;
    pf.direct.alpha = 24;
    pf.direct.alphaMask = 0xff;
    pf.direct.red = 16;
    pf.direct.redMask = 0xff;
    pf.direct.green = 8;
    pf.direct.greenMask = 0xff;
    pf.direct.blue = 0;
    pf.direct.blueMask = 0xff;

    format_pix = XRenderFindFormat(dpy, 
                                     PictFormatType|
                                     PictFormatDepth|
                                     PictFormatRed|
                                     PictFormatRedMask|
                                     PictFormatGreen|
                                     PictFormatGreenMask|
                                     PictFormatBlue|
                                     PictFormatBlueMask|
                                     PictFormatAlpha|
                                     PictFormatAlphaMask,
                                     &pf, 0);
    if (!format_pix) exit (1);
    
    window = XCreateSimpleWindow(dpy, RootWindow (dpy, screen),
                                 0, 0, SIZE, SIZE, 1, BlackPixel (dpy,
screen),
                                 WhitePixel (dpy, screen));
    picture = XRenderCreatePicture (dpy, window, format_win, 0, 0);

    color_pix = XCreatePixmap(dpy, window, 1, 1, 32);
    pa.repeat = True;
    color = XRenderCreatePicture (dpy, color_pix, format_pix, 
                                  CPRepeat, &pa);

    XSelectInput (dpy, window, ExposureMask);
    
    XMapWindow (dpy, window);
    for (;;)
    {
        XNextEvent (dpy, &ev);
        if (ev.type == Expose && ev.xexpose.count == 0)
        {
            XClearArea (dpy, window, 0, 0, 0, 0, False);
            
            XRenderFillRectangle(dpy, PictOpSrc, color, &rc, 0, 0, 1, 1);
            XRenderComposite (dpy,
                              PictOpSrc,
                              color,
                              0,
                              picture,
                              0, 0, 0, 0, 0, 0, SIZE, SIZE);
        }
    }
}
_______________________________________________
Render mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/render

Reply via email to