[Mono-winforms-list] Jonathan Gilbert's indexed colorsupport patch
Jonathan Gilbert
2a5gjx302 at sneakemail.com
Mon May 30 17:48:53 EDT 2005
At 11:21 AM 30/05/2005 -0600, Peter Dennis Bartok wrote:
>Jonathan,
>
>The images used by the file dialog are PNGs, not BMPs.
>
>Peter
Ah :-) Useful information, that. I tracked it down. In fact, it was a Real
Bug (tm), affecting *all* platforms, not just an endian issue. The file
pngcodec.c had this block of code translating the palette from libpng's
structures into the ColorPalette struct in libgdiplus:
set_pixel_bgra (&palette->Entries[i], 0,
info_ptr->palette[i].red,
info_ptr->palette[i].green,
info_ptr->palette[i].blue,
0xFF); /* alpha */
This looks all fine and good. The only problem is, the set_pixel_bgra macro
takes its arguments in the same order as they are listed in the function's
name: blue, green, red, alpha. I didn't catch this initially because
winforms/endian didn't try to read indexed PNG files. I wasn't really
thinking with regards to testing, and I should have been :-)
So, I have an updated version of the patch up now at the same ol' address:
http://israel.logiclrd.cx/patch/
It has an added bonus: I have implemented decoders for 4- and 8-bit RLE BMP
files. I have tested them on half a dozen sample files of varying
dimensions & content, and they work perfectly as far as I can tell. I have
included a simple test case with 2 sample files that can be added to
winforms if you want (that's where I created it on my end).
I doubt there are any other endian issues. If you don't see anything else
wrong with the patch, can you commit it to SVN? Even if someone does
uncover an endianness issue (or other bug), bugs are much easier to fix
when they are being properly tracked in bugzilla, and that tracking can
only take place once the patch is committed. In particular, the people
posting bug reports often have the time to provide additional information
and test fixes that don't necessarily apply to the author's platform :-)
Thanks,
Jonathan Gilbert
More information about the Mono-winforms-list
mailing list