@Test(expected = IllegalArgumentException.class) public void readOnlyJpegImageNullFile() { ReadOnlyFilteredCOSStream.readOnlyJpegImage(null, 10, 10, 1, mock(PDColorSpace.class)); }
public static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height, int bitsPerComponent, PDColorSpace colorSpace) { requireNotNullArg(imageFile, "input file cannot be null"); requireNotNullArg(colorSpace, "color space cannot be null"); COSDictionary dictionary = new COSDictionary(); dictionary.setItem(COSName.TYPE, COSName.XOBJECT); dictionary.setItem(COSName.SUBTYPE, COSName.IMAGE); dictionary.setItem(COSName.FILTER, COSName.DCT_DECODE); dictionary.setInt(COSName.BITS_PER_COMPONENT, bitsPerComponent); dictionary.setInt(COSName.HEIGHT, height); dictionary.setInt(COSName.WIDTH, width); of(colorSpace).map(PDColorSpace::getCOSObject).ifPresent(cs -> dictionary.setItem(COSName.COLORSPACE, cs)); return new ReadOnlyFilteredCOSStream(dictionary, () -> new FileInputStream(imageFile), imageFile.length()); }
ReadOnlyFilteredCOSStream extends COSStream { public static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height, int bitsPerComponent, PDColorSpace colorSpace) { requireNotNullArg(imageFile, "input file cannot be null"); requireNotNullArg(colorSpace, "color space cannot be null"); COSDictionary dictionary = new COSDictionary(); dictionary.setItem(COSName.TYPE, COSName.XOBJECT); dictionary.setItem(COSName.SUBTYPE, COSName.IMAGE); dictionary.setItem(COSName.FILTER, COSName.DCT_DECODE); dictionary.setInt(COSName.BITS_PER_COMPONENT, bitsPerComponent); dictionary.setInt(COSName.HEIGHT, height); dictionary.setInt(COSName.WIDTH, width); of(colorSpace).map(PDColorSpace::getCOSObject).ifPresent(cs -> dictionary.setItem(COSName.COLORSPACE, cs)); return new ReadOnlyFilteredCOSStream(dictionary, () -> new FileInputStream(imageFile), imageFile.length()); } }
ReadOnlyFilteredCOSStream extends COSStream { public static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height, int bitsPerComponent, PDColorSpace colorSpace) { requireNotNullArg(imageFile, "input file cannot be null"); requireNotNullArg(colorSpace, "color space cannot be null"); COSDictionary dictionary = new COSDictionary(); dictionary.setItem(COSName.TYPE, COSName.XOBJECT); dictionary.setItem(COSName.SUBTYPE, COSName.IMAGE); dictionary.setItem(COSName.FILTER, COSName.DCT_DECODE); dictionary.setInt(COSName.BITS_PER_COMPONENT, bitsPerComponent); dictionary.setInt(COSName.HEIGHT, height); dictionary.setInt(COSName.WIDTH, width); of(colorSpace).map(PDColorSpace::getCOSObject).ifPresent(cs -> dictionary.setItem(COSName.COLORSPACE, cs)); return new ReadOnlyFilteredCOSStream(dictionary, () -> new FileInputStream(imageFile), imageFile.length()); } ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStream stream, long length);  ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStreamSupplier<InputStream> stream,
            long length); }
ReadOnlyFilteredCOSStream extends COSStream { public static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height, int bitsPerComponent, PDColorSpace colorSpace) { requireNotNullArg(imageFile, "input file cannot be null"); requireNotNullArg(colorSpace, "color space cannot be null"); COSDictionary dictionary = new COSDictionary(); dictionary.setItem(COSName.TYPE, COSName.XOBJECT); dictionary.setItem(COSName.SUBTYPE, COSName.IMAGE); dictionary.setItem(COSName.FILTER, COSName.DCT_DECODE); dictionary.setInt(COSName.BITS_PER_COMPONENT, bitsPerComponent); dictionary.setInt(COSName.HEIGHT, height); dictionary.setInt(COSName.WIDTH, width); of(colorSpace).map(PDColorSpace::getCOSObject).ifPresent(cs -> dictionary.setItem(COSName.COLORSPACE, cs)); return new ReadOnlyFilteredCOSStream(dictionary, () -> new FileInputStream(imageFile), imageFile.length()); } ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStream stream, long length);  ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStreamSupplier<InputStream> stream,
            long length); @Override long getFilteredLength(); @Override long getUnfilteredLength(); @Override InputStream getUnfilteredStream(); @Override SeekableSource getUnfilteredSource(); @Override OutputStream createFilteredStream(); @Override OutputStream createFilteredStream(COSBase filters); @Override void setFilters(COSBase filters); @Override boolean addCompression(); @Override boolean encryptable(); @Override void encryptable(boolean encryptable); @Override OutputStream createUnfilteredStream(); @Override boolean isEmpty(); @Override boolean indirectLength(); @Override void indirectLength(boolean indirectLength); @Override IndirectCOSObjectIdentifier id(); @Override void idIfAbsent(IndirectCOSObjectIdentifier id); @Override void close(); static ReadOnlyFilteredCOSStream readOnly(COSStream existing); static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height,
            int bitsPerComponent, PDColorSpace colorSpace); static final ReadOnlyFilteredCOSStream readOnlyEmbeddedFile(Source<?> source); }
ReadOnlyFilteredCOSStream extends COSStream { public static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height, int bitsPerComponent, PDColorSpace colorSpace) { requireNotNullArg(imageFile, "input file cannot be null"); requireNotNullArg(colorSpace, "color space cannot be null"); COSDictionary dictionary = new COSDictionary(); dictionary.setItem(COSName.TYPE, COSName.XOBJECT); dictionary.setItem(COSName.SUBTYPE, COSName.IMAGE); dictionary.setItem(COSName.FILTER, COSName.DCT_DECODE); dictionary.setInt(COSName.BITS_PER_COMPONENT, bitsPerComponent); dictionary.setInt(COSName.HEIGHT, height); dictionary.setInt(COSName.WIDTH, width); of(colorSpace).map(PDColorSpace::getCOSObject).ifPresent(cs -> dictionary.setItem(COSName.COLORSPACE, cs)); return new ReadOnlyFilteredCOSStream(dictionary, () -> new FileInputStream(imageFile), imageFile.length()); } ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStream stream, long length);  ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStreamSupplier<InputStream> stream,
            long length); @Override long getFilteredLength(); @Override long getUnfilteredLength(); @Override InputStream getUnfilteredStream(); @Override SeekableSource getUnfilteredSource(); @Override OutputStream createFilteredStream(); @Override OutputStream createFilteredStream(COSBase filters); @Override void setFilters(COSBase filters); @Override boolean addCompression(); @Override boolean encryptable(); @Override void encryptable(boolean encryptable); @Override OutputStream createUnfilteredStream(); @Override boolean isEmpty(); @Override boolean indirectLength(); @Override void indirectLength(boolean indirectLength); @Override IndirectCOSObjectIdentifier id(); @Override void idIfAbsent(IndirectCOSObjectIdentifier id); @Override void close(); static ReadOnlyFilteredCOSStream readOnly(COSStream existing); static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height,
            int bitsPerComponent, PDColorSpace colorSpace); static final ReadOnlyFilteredCOSStream readOnlyEmbeddedFile(Source<?> source);  }