if ((colorType & 4) != 0)
--components;
int bpc = bitDepth;
if (bpc == 16)
bpc = 8;
Image img;
if (image != null) {
if (colorType == 3)
img = new ImgRaw(width, height, components, bpc, image);
else
img = Image.getInstance(width, height, components, bpc, image);
}
else {
img = new ImgRaw(width, height, components, bpc, idat.toByteArray());
img.setDeflated(true);
PdfDictionary decodeparms = new PdfDictionary();
decodeparms.put(PdfName.BITSPERCOMPONENT, new PdfNumber(bitDepth));
decodeparms.put(PdfName.PREDICTOR, new PdfNumber(15));
decodeparms.put(PdfName.COLUMNS, new PdfNumber(width));
decodeparms.put(PdfName.COLORS, new PdfNumber((colorType == 3 || (colorType & 2) == 0) ? 1 : 3));
additional.put(PdfName.DECODEPARMS, decodeparms);
}
if (additional.get(PdfName.COLORSPACE) == null)
additional.put(PdfName.COLORSPACE, getColorspace());
if (intent != null)
additional.put(PdfName.INTENT, intent);
if (additional.size() > 0)
img.setAdditional(additional);
if (icc_profile != null)
img.tagICC(icc_profile);
if (palShades) {
Image im2 = Image.getInstance(width, height, 1, 8, smask);
im2.makeMask();
img.setImageMask(im2);
}
if (genBWMask) {
Image im2 = Image.getInstance(width, height, 1, 1, smask);
im2.makeMask();
img.setImageMask(im2);
}
img.setDpi(dpiX, dpiY);
img.setXYRatio(XYRatio);
img.setOriginalType(Image.ORIGINAL_PNG);