Can "XImage->bytes_per_line" be negative...? - Xwindows

This is a discussion on Can "XImage->bytes_per_line" be negative...? - Xwindows ; Hello, I'm porting a program to X and when I draw images with XPutImage() I found they come out flipped in the vertical direction. It seems XPutImage wants the data to be upside down (compared to the rest of the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Can "XImage->bytes_per_line" be negative...?

  1. Can "XImage->bytes_per_line" be negative...?

    Hello,

    I'm porting a program to X and when I draw images
    with XPutImage() I found they come out flipped in
    the vertical direction. It seems XPutImage wants
    the data to be upside down (compared to the rest
    of the program).

    As a fix I tried setting "XImage->bytes_per_line"
    to a negative value and adjusting "XImage->data"
    accordingly.

    This worked on my SUSE Linux machine (ie. the images
    draw correctly) but is it legal?

    Will this hack work and be portable across different
    X implementations and graphics drivers?


    Rewriting the rest of the program to fit isn't really
    an option and I really don't want to flip the data by
    hand on every image draw as it would be a big performance
    hit.

    Thanks...



    --
    <\___/>
    / O O \
    \_____/ FTB. For email, remove my socks.

    In science it often happens that scientists say, 'You know
    that's a really good argument; my position is mistaken,'
    and then they actually change their minds and you never
    hear that old view from them again. They really do it.
    It doesn't happen as often as it should, because scientists
    are human and change is sometimes painful. But it happens
    every day. I cannot recall the last time something like
    that happened in politics or religion.

    - Carl Sagan, 1987 CSICOP keynote address


  2. Re: Can "XImage->bytes_per_line" be negative...?


    "fungus" wrote in message
    news:8AaAg.8547$MA3.6271@news.ono.com...
    > Hello,
    >
    > I'm porting a program to X and when I draw images
    > with XPutImage() I found they come out flipped in
    > the vertical direction. It seems XPutImage wants
    > the data to be upside down (compared to the rest
    > of the program).


    Remember the coordinate system in X - the top of the screen is zero,
    with positive Y axis going down the screen.

    >
    > As a fix I tried setting "XImage->bytes_per_line"
    > to a negative value and adjusting "XImage->data"
    > accordingly.
    >
    > This worked on my SUSE Linux machine (ie. the images
    > draw correctly) but is it legal?
    >
    > Will this hack work and be portable across different
    > X implementations and graphics drivers?
    >
    >
    > Rewriting the rest of the program to fit isn't really
    > an option and I really don't want to flip the data by
    > hand on every image draw as it would be a big performance
    > hit.
    >
    > Thanks...
    >
    > --
    > <\___/>
    > / O O \
    > \_____/ FTB. For email, remove my socks.


    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



+ Reply to Thread