libertyernie/brawltools — pull request #14 by PeterHatch (2014-11-29 22:04:17+00:00)
Title: Made pixel format conversions more accurate.

This change is about making converting a color from 8 bit to 6, 5, 4, or 3 bits, and vice versa, more accurate. (It also makes it slower, but that's not an issue for BrawlBox.)

Conversion from 4 bits to 8 remains the same - that should be a multiplication by 17, and that's what the implementation does, though bit manipulations. Converting 8 bits to 4, conversely, should be done by dividing by 17 and rounding to the nearest integer, but was instead being done by dividing by 16 and rounding down.

In general, conversion is done by multiplying by the max value in the desired new bit depth, and dividing by the max value in the current bit depth. I've used Convert.ToInt32 for the rounding and conversion from Float to Int.

For an example of how this improves things, here are three images of a CSP from Smash 3 - the original 32 bit depth version, one converted to RGB5A3 then exported after these changes, and one converted before these changes:
![zelda_00_csp](https://cloud.githubusercontent.com/assets/3161425/5235937/e4ae25a6-77cf-11e4-97c3-17972010be87.png)![zelda_00_csp updated brawlbox](https://cloud.githubusercontent.com/assets/3161425/5235938/ed84e6b0-77cf-11e4-8928-6f0dccc0d3c9.png)![zelda_00_csp original brawlbox conversion](https://cloud.githubusercontent.com/assets/3161425/5235939/f01c94d6-77cf-11e4-959f-b4ae2622ece8.png)
The most noticeable difference is that the white of the gloves is whiter after conversion without these changes. (That is much more obvious when switching between the two images being displayed in the same position than when looking at them side-by-side.)