pngColorType = 2;
}
}
else if (colorspace instanceof PdfArray) {
PdfArray ca = (PdfArray)colorspace;
PdfObject tyca = ca.getDirectObject(0);
if (PdfName.CALGRAY.equals(tyca)) {
stride = (width * bpc + 7) / 8;
pngColorType = 0;
}
else if (PdfName.CALRGB.equals(tyca)) {
if (bpc == 8 || bpc == 16) {
stride = (width * bpc * 3 + 7) / 8;
pngColorType = 2;
}
}
else if (PdfName.ICCBASED.equals(tyca)) {
PRStream pr = (PRStream)ca.getDirectObject(1);
int n = pr.getAsNumber(PdfName.N).intValue();
if (n == 1) {
stride = (width * bpc + 7) / 8;
pngColorType = 0;
icc = PdfReader.getStreamBytes(pr);
}
else if (n == 3) {
stride = (width * bpc * 3 + 7) / 8;
pngColorType = 2;
icc = PdfReader.getStreamBytes(pr);
}
}
else if (allowIndexed && PdfName.INDEXED.equals(tyca)) {
findColorspace(ca.getDirectObject(1), false);
if (pngColorType == 2) {
PdfObject id2 = ca.getDirectObject(3);
if (id2 instanceof PdfString) {
palette = ((PdfString)id2).getBytes();
}
else if (id2 instanceof PRStream) {
palette = PdfReader.getStreamBytes(((PRStream)id2));