I'm trying to debug a problem in which 24-bit .bmps don't display correctly from a winelib application on a big-endian sparc host when displaying on a little-endian intel PC. In this case, the image is garbled, with most of the colors being wrong and a pattern of vertical stripes over the image. The code passes through convert_888_to_0888_reverse_dst_byteswap which is what mangles the image data.
I looked through the other conversion functions, and it seems the corresponding 'src' function (convert_888_to_0888_reverse_src_byteswap) actually does the correct transformation. I don't have a very good grasp of why the conversions are chosen, but it seemed like a likely fix would be to edit dib.c and make the lines in the SetImageBits functions that select the conversion structure look like:
#ifdef WORDS_BIGENDIAN const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_src_byteswap; #else const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? &dib_normal : &dib_dst_byteswap; #endif
Doing this fixed my problem and didn't seem to cause any others, but I'm wondering whether this fix is correct or if I just got lucky. Can someone who knows this code tell me if this makes logical sense?
(If it's correct, there probably needs to be a related patch in the GetImageBits functions, just going in the other direction).
Eric