x11drv: question about byte-swapping for DIBs

Eric Frias efrias at syncad.com
Wed Apr 19 15:50:47 CDT 2006

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 

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:

    const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? 
&dib_normal : &dib_src_byteswap;
    const dib_conversions *convs = (bmpImage->byte_order == LSBFirst) ? 
&dib_normal : &dib_dst_byteswap;

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).


More information about the wine-devel mailing list