[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcaca] Re: Bitmap is shown vertically flipped



On Sat, Dec 13, 2003, Zeeshan Ali wrote:

>   Attached with this email is a sample code of mine
> that i wrote to learn to use libcaca, as i inted to
> write a caca plugin for Gstreamer (www.gstreamer.net).
> But I am faced with these problems:
> (1) The picture is shown vertically flipped.
> (2) The Red & Blue component of the pixels are swapped.

   Well, you did nothing wrong but have just been bitten by the two
BMP oddities: they are stored upside-down, and in BGR format instead
of RGB. You'll need to replace:

            pixels[j+0] = rgb.rgbtRed; // Red component
            pixels[j+1] = rgb.rgbtGreen; // Red component
            pixels[j+2] = rgb.rgbtBlue; // Red component

   with:

            pixels[j+0] = rgb.rgbtBlue; // Blue component
            pixels[j+1] = rgb.rgbtGreen; // Green component
            pixels[j+2] = rgb.rgbtRed; // Red component

   and split your for() loop in two to handle one line at a time so that
you can store them in reverse order.

Regards,
-- 
Sam.
-- 
This is the libcaca mailing-list, see http://sam.zoy.org/projects/libcaca/
Trouble unsubscribing? Please contact <sam@zoy.org>