PDA

View Full Version : conversion yuv to rgb or bmp to data raw



10-31-2003, 07:53 AM
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?

10-31-2003, 08:52 AM
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 http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/wink.gif

Deiussum
10-31-2003, 09:12 AM
Originally posted by BGR:
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 http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/wink.gif

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)

10-31-2003, 09:19 AM
Originally posted by Deiussum:
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)



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?

Deiussum
11-03-2003, 04:22 AM
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).]