bos.write4Bytes(BI_RGB); // Compression
bos.write4Bytes(imagedata.length); // Bitmap Data Size
bos.write4Bytes(pixelDensity != null ? (int) Math
.round(pixelDensity.horizontalDensityMetres()) : 0); // HResolution
bos.write4Bytes(pixelDensity != null ? (int) Math
.round(pixelDensity.verticalDensityMetres()) : 0); // VResolution
if (palette == null) {
bos.write4Bytes(0); // Colors
} else {
bos.write4Bytes(palette.length()); // Colors
}