if (!decoded) {
// if the stream hasn't been decoded, check to see if it is a single stage JPG or JPX encoded stream. If it is,
// then we can just use stream as-is
PdfName filter = dictionary.getAsName(PdfName.FILTER);
if (filter == null){
PdfArray filterArray = dictionary.getAsArray(PdfName.FILTER);
if (filterArray.size() == 1){
filter = filterArray.getAsName(0);
} else {
throw new UnsupportedPdfException("Multi-stage filters not supported here (" + filterArray + ")");
}
}
if (PdfName.DCTDECODE.equals(filter)) {
fileType = TYPE_JPG;
return streamBytes;
}
else if (PdfName.JPXDECODE.equals(filter)) {
fileType = TYPE_JP2;
return streamBytes;
}
throw new UnsupportedPdfException("Unsupported stream filter " + filter);
}
pngColorType = -1;
width = dictionary.getAsNumber(PdfName.WIDTH).intValue();
height = dictionary.getAsNumber(PdfName.HEIGHT).intValue();
bpc = dictionary.getAsNumber(PdfName.BITSPERCOMPONENT).intValue();
pngBitDepth = bpc;
PdfObject colorspace = dictionary.getDirectObject(PdfName.COLORSPACE);
palette = null;
icc = null;
stride = 0;
findColorspace(colorspace, true);
ByteArrayOutputStream ms = new ByteArrayOutputStream();
if (pngColorType < 0) {
if (bpc != 8)
return null;
if (PdfName.DEVICECMYK.equals(colorspace)) {
}
else if (colorspace instanceof PdfArray) {
PdfArray ca = (PdfArray)colorspace;
PdfObject tyca = ca.getDirectObject(0);
if (!PdfName.ICCBASED.equals(tyca))
return null;
PRStream pr = (PRStream)ca.getDirectObject(1);
int n = pr.getAsNumber(PdfName.N).intValue();
if (n != 4) {
return null;
}
icc = PdfReader.getStreamBytes(pr);