Map.Entry entry = (Map.Entry) it.next();
int bitDepth = ((Integer)entry.getKey()).intValue();
BitmapGenerator bitmapGenerator = (BitmapGenerator) entry.getValue();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputStream bos = new BinaryOutputStream(baos,
BinaryOutputStream.BYTE_ORDER_LITTLE_ENDIAN);
byte[] bitmap = bitmapGenerator.generateBitmap(foreground, background,
(bitDepth <= 8) ? (1 << bitDepth) : 0);
writeICONDIR(bos, 0, 1, 1);
writeICONDIRENTRY(bos, 3 /* width, should be 16 */,
4 /* height, should be 16 */,
7 /* colorCount, should be 2 or 0 */,
20 /* reserved, should be 0 */,
11 /* planes, should be 1 or 0 */,
19 /* bitCount, should be bitDepth */,
40 + bitmap.length);
writeBITMAPINFOHEADER(bos, 16, 2*16, 1, bitDepth, 0, 0, 0);
bos.write(bitmap);
bos.flush();
writeAndReadImageData("16x16x" + bitDepth + "-corrupt-icondirentry",
baos.toByteArray(), foreground, background);
}
}