public void writeImage(final BufferedImage src, final OutputStream os)
throws ImageWriteException, IOException {
final PaletteFactory paletteFactory = new PaletteFactory();
final SimplePalette palette = paletteFactory
.makeExactRgbPaletteSimple(src, 256);
final BinaryOutputStream bos = new BinaryOutputStream(os,
ByteOrder.LITTLE_ENDIAN);
if (palette == null || bitDepth == 24 || bitDepth == 32) {
if (bitDepth == 32) {
write32BppPCX(src, bos);
} else {