conversion yuv to rgb or bmp to data raw

hi, im using the yuv color space in a project to implement a video player, but I can´t convert correctly the yuv data to rgb using the various algorithms from the web. I have found one that convert yuv to bmp data (24 bits/pixel), but it doesn´t work, the image appears wrong. Does anybody know how to convert yuv data (4:2:0) in data raw? Or, does anybody know any function that convert bmp data in data raw, which can be displayed correctly?

Let me guess:

You are using Windows, right?
Are you aware that Windows uses BGR rather then RGB?

I strongly believe BGR is just an acronym for Bill Gates Rulez

Originally posted by BGR:
[b]Let me guess:

You are using Windows, right?
Are you aware that Windows uses BGR rather then RGB?

I strongly believe BGR is just an acronym for Bill Gates Rulez [/b]

It’s not so much that Windows uses BGR, as much as it is that the BMP file format uses BGR. But then, so does the TGA file format. Also, the BMP file format was co-developed by both Microsoft and IBM. (Thus the flag in the BMP header for OS/2 BMPs)

Originally posted by Deiussum:
[b] It’s not so much that Windows uses BGR, as much as it is that the BMP file format uses BGR. But then, so does the TGA file format. Also, the BMP file format was co-developed by both Microsoft and IBM. (Thus the flag in the BMP header for OS/2 BMPs)

[/b]

yes, im using windows, but i have tried to change the order of the r,g and b components… but even doesn´t work. Do you know any function to convert the bmp data representation to data raw?

As I said, it doesn’t matter if you are using Windows. Even using Linux, BMP files are still stored in BGR format. It’s not a matter of the OS you use, but of the file format you use.

To convert a BMP file into an array of raw RGB (or BGR) data, you could try either getting a copy of the file format specification and writing your own loader, or use a library that does that for you.

Once you have the raw RGB data, you should just be able to use the proper conversions to get YUV. (I don’t remember what those conversion formulas are offhand, but I’m sure a Google search will turn them up.)

Edit: Oops. Sorry. You are looking to convert YUV to a BMP? Or YUV to raw RGB data? How are you using the resulting data? Are you just saving it to a BMP file, trying to use it in OpenGL, or what?

[This message has been edited by Deiussum (edited 11-03-2003).]