wr.writeFile(ms);
streamContentType = ImageBytesType.CCITT;
imageBytes = ms.toByteArray();
return;
} else {
PngWriter png = new PngWriter(ms);
if (decode != null){
if (pngBitDepth == 1){
// if the decode array is 1,0, then we need to invert the image
if(decode.getAsNumber(0).intValue() == 1 && decode.getAsNumber(1).intValue() == 0){
int len = imageBytes.length;
for (int t = 0; t < len; ++t) {
imageBytes[t] ^= 0xff;
}
} else {
// if the decode array is 0,1, do nothing. It's possible that the array could be 0,0 or 1,1 - but that would be silly, so we'll just ignore that case
}
} else {
// todo: add decode transformation for other depths
}
}
png.writeHeader(width, height, pngBitDepth, pngColorType);
if (icc != null)
png.writeIccProfile(icc);
if (palette != null)
png.writePalette(palette);
png.writeData(imageBytes, stride);
png.writeEnd();
streamContentType = ImageBytesType.PNG;
imageBytes = ms.toByteArray();
}
}