Hi,
Lately, I've been working on my 24-bpp blitting code. Before setting a mode, I do certain checks on it to find whether it's usable or not. One of this includes checking whether the pixel format for the mode is acceptable or not. As of now, "acceptable" includes only 8:8:8 RGB for 24-bpp.
To verify this, I use the *MaskSize and *FieldPosition fields provided by VBE Function 01h.
Now comes the strange part.
On Bochs, QEMU (without "-std xyz"), QEMU (with "-std vga") and virtualbox, the reported 24-bpp modes are in the 8:8:8 RGB format, as desired.
On QEMU (without "-std xyz"), the colors come up exactly as expected. On every other emulator, the colors are a little messed up, as would happen if a 8:8:8 RGB input image is interpreted as 8:8:8 BGR. I've attached two screenshots, which describe the scenario.
(oh, and I'm pretty sure my input image is RGB)
Screenshot 1
QEMU (without "-std xyz")
Screenshot 2
Every other emulator
Unfortunately, both of my test beds don't support 24-bpp modes, so I've been unable to record the output on real machines. I'm pretty sure I'm doing something wrong - so guidance would be wanted.
Regards,
Shikhin
RGB interpreted as BGR
RGB interpreted as BGR
Last edited by shikhin on Tue Dec 27, 2011 11:27 am, edited 1 time in total.
Re: RGB interpreted as BGR
There is no evidence that a video card should use the RGB order of bytes. The fields and their position are defined in the struct of the video mode taken from vbe
Re: RGB interpreted as BGR
Hi,
EDIT: Doh. Had typed in Function 02h in both the posts, instead of Function 01h.
Regards,
Shikhin
Karlosoft wrote:There is no evidence that a video card should use the RGB order of bytes. The fields and their position are defined in the struct of the video mode taken from vbe
Shikhin wrote:As of now, "acceptable" includes only 8:8:8 RGB for 24-bpp.
Shikhin wrote:To verify this, I use the *MaskSize and *FieldPosition fields provided by VBE Function 01h.
Hmm.Shikhin wrote:On Bochs, QEMU (without "-std xyz"), QEMU (with "-std vga") and virtualbox, the reported 24-bpp modes are in the 8:8:8 RGB format, as desired.
EDIT: Doh. Had typed in Function 02h in both the posts, instead of Function 01h.
Regards,
Shikhin
Re: RGB interpreted as BGR
Hi,
Recently, I discovered that I was setting a 16-bpp mode on it, which is why the colors were right over there.
However, that still doesn't resolve my issue.
However, I might be mis-interpreting the colors everywhere.
Regards,
Shikhin
Well, before that, I discovered something which truly deserves http://tinyurl.com/cmqjumd. Since the code worked on QEMU without any command line options, I never bothered verifying the mode I set there. Moreover, when I changed the input stream to BGR, the colors over there got reversed. So, I thought that everything was right on itberkus wrote:Can you provide the values for the field positions and masks please?
Recently, I discovered that I was setting a 16-bpp mode on it, which is why the colors were right over there.
However, that still doesn't resolve my issue.
My input image is generated from a BMP. As far as I know, BMP is in BGR format. I convert this into RGB by inter-changing the Blue and Red bytes. The same input data is used by the 8-bpp, 15-bpp and 16-bpp code, which convert the pixel into the required format. The colors in these modes are absolutely fine, which makes me believe that the input data is in RGB.RedFieldPosition = 16, RedMaskSize = 8;
GreenFieldPosition = 8, GreenMaskSize = 8;
BlueFieldPosition = 0, BlueMaskSize = 8;
However, I might be mis-interpreting the colors everywhere.
Regards,
Shikhin
Re: RGB interpreted as BGR
Hi,
Regards,
Shikhin
Yeah. Before the latest finding on QEMU without any command line flag, I wasn't so sure where the bug existed. Should be easier to find now. Thanks (for all the fish)!berkus wrote:Which makes me believe there must be a bug in your code, debug.
(EDIT: it seems obvious to me that a good test images will be the all-Red, all-Green and all-Blue bitmaps)
Regards,
Shikhin