incorrect result of copyplane function - Xwindows

This is a discussion on incorrect result of copyplane function - Xwindows ; Hi, I have a code segment that draws a x image using the GXxor logical function, with xsetfunction set gxxor and i make use of copyplane function to xor. The code segment looks like this: static void copysmall( int gcFunction, ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: incorrect result of copyplane function

  1. incorrect result of copyplane function

    Hi,

    I have a code segment that draws a x image using the GXxor logical
    function, with xsetfunction set gxxor and i make use of copyplane
    function to xor.
    The code segment looks like this:
    static void copysmall( int gcFunction, int dest_x, int dest_y )
    {
    XSetFunction( XtDisplay(drawing_a), drawing_gc, gcFunction ); //Sets
    the function to be GXxor

    XSetForeground( XtDisplay( drawing_a ), drawing_gc,BlackPixelOfScreen(
    XtScreen(drawing_a) ) );

    XSetBackground( XtDisplay( drawing_a ),
    drawing_gc,colorBackGround.pixel );

    XCopyPlane(
    XtDisplay(drawing_a),small_pixmap,drawing_pixmap,d rawing_gc,0, 0, 50,
    50, dest_x, dest_y, 1 );
    }


    This code segment gets called repeatedly as the user is drawing three x
    images, one x iamge from gxcopy which is working fine and this x image
    is overlapped twice with gxxor function. I USING XOR BETWEEN THE PIXEL
    VALUES I HAVE.


    The problem is that the GXxor function isn't returning the correct
    values.
    There are some other drawing functions going on such as drawing
    rectangles.

    I am drawing three rectangleS and filling them with red(65535,0,0),
    Green(0, 65535, 0)and
    Blue (0, 0, 65535) over the background color grey filled with some
    values (55704, 55704, 55704).

    This when displayed on the x server i have pixel values displayed for
    red as 5, green as 6, blue as 7, and grey as 8 by the colormap (!!i
    guess so).

    the code is using default colormap which pseudocolormap of the server,
    so when use xor function it draws x image over green rectangle.so xor
    of green and background ( 6 ^ 8 = 14)
    but i see a pixel value of 238 with RGB intensities (0,0,0) with
    magenta color.
    similarly on blue i see a yellow colordrawn with pixel value of 80
    with RGB intensities (0,0,0),but xor of (7 ^ 8 = 15) and when i make
    use of xor on red i get cyan color with pixel value of 127 with RGB
    intensities (0,0,0) but xor of 5 ^ 8 = 13.


    I am making use of two gcs (DRAWING GC, SMALLGC, COLORGC ) and two
    pixmaps (drawing pixmap, small pixmap). drwing gc and drawing pixmap
    for the creation of rectangles and smallgc and small pixmap for the
    creation of x image.

    Has anyone experienced this and know a fix or know what I'm doing
    wrong? let me know is xor working fine or something going wrong with
    server or something fishy in the code snippet ??


  2. Re: incorrect result of copyplane function


    "naveen" wrote in message
    news:1153457383.585298.57470@b28g2000cwb.googlegro ups.com...
    > Hi,
    >
    > I have a code segment that draws a x image using the GXxor logical
    > function, with xsetfunction set gxxor and i make use of copyplane
    > function to xor.
    > The code segment looks like this:
    > static void copysmall( int gcFunction, int dest_x, int dest_y )
    > {
    > XSetFunction( XtDisplay(drawing_a), drawing_gc, gcFunction ); //Sets
    > the function to be GXxor
    >
    > XSetForeground( XtDisplay( drawing_a ), drawing_gc,BlackPixelOfScreen(
    > XtScreen(drawing_a) ) );
    >
    > XSetBackground( XtDisplay( drawing_a ),
    > drawing_gc,colorBackGround.pixel );
    >
    > XCopyPlane(
    > XtDisplay(drawing_a),small_pixmap,drawing_pixmap,d rawing_gc,0, 0, 50,
    > 50, dest_x, dest_y, 1 );
    > }
    >
    >
    > This code segment gets called repeatedly as the user is drawing three x
    > images, one x iamge from gxcopy which is working fine and this x image
    > is overlapped twice with gxxor function. I USING XOR BETWEEN THE PIXEL
    > VALUES I HAVE.
    >
    >
    > The problem is that the GXxor function isn't returning the correct
    > values.
    > There are some other drawing functions going on such as drawing
    > rectangles.
    >
    > I am drawing three rectangleS and filling them with red(65535,0,0),
    > Green(0, 65535, 0)and
    > Blue (0, 0, 65535) over the background color grey filled with some
    > values (55704, 55704, 55704).
    >
    > This when displayed on the x server i have pixel values displayed for
    > red as 5, green as 6, blue as 7, and grey as 8 by the colormap (!!i
    > guess so).
    >
    > the code is using default colormap which pseudocolormap of the server,
    > so when use xor function it draws x image over green rectangle.so xor
    > of green and background ( 6 ^ 8 = 14)
    > but i see a pixel value of 238 with RGB intensities (0,0,0) with
    > magenta color.
    > similarly on blue i see a yellow colordrawn with pixel value of 80
    > with RGB intensities (0,0,0),but xor of (7 ^ 8 = 15) and when i make
    > use of xor on red i get cyan color with pixel value of 127 with RGB
    > intensities (0,0,0) but xor of 5 ^ 8 = 13.
    >
    >
    > I am making use of two gcs (DRAWING GC, SMALLGC, COLORGC ) and two
    > pixmaps (drawing pixmap, small pixmap). drwing gc and drawing pixmap
    > for the creation of rectangles and smallgc and small pixmap for the
    > creation of x image.
    >
    > Has anyone experienced this and know a fix or know what I'm doing
    > wrong? let me know is xor working fine or something going wrong with
    > server or something fishy in the code snippet ??
    >


    Are you sure that you want to use XOR? It is not clear exactly what you
    are trying to accomplish.

    When you draw image A using XCOPY, then draw image B using XOR, your
    next operation should be to draw image B again using XOR, so that the screen
    now shows image A again. If instead you draw something eles (C) using XOR,
    you mess things up unless you back out correctly (draw C again using XOR to
    produce the A+B image, then draw B again using XOR to product A).

    Note that B and C cannot be modified in the meantime.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



  3. Re: incorrect result of copyplane function

    Perhaps a word of clarification: The code snippet
    quoted by naveen above, is part of a program
    submitted by me as part of
    an error report to the vendor of a particular
    X-server. This X-server apparently incorrectly
    implements the GxXor function, the demonstration
    program is designed to show this, not to do anything
    particularly useful.

    I can only assume, that naveen is working on this
    problem, since I did not publish this program
    anywhere else.

    Jesper Naur


+ Reply to Thread