static DataInputStream createZipStream(final ImageInputStream pInput, long pLength) { return new DataInputStream(new ZipInputStream(IIOUtil.createStreamAdapter(pInput, pLength))); }
@SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { ImageReaderSpi defaultProvider = lookupProviderByName(registry, "com.sun.imageio.plugins.bmp.BMPImageReaderSpi", ImageReaderSpi.class); if (defaultProvider != null) { // Order before com.sun provider, to aid ImageIO in selecting our reader registry.setOrdering((Class<ImageReaderSpi>) category, this, defaultProvider); } }
/** * Utility method for getting the area of interest (AOI) of an image. * The AOI is defined by the {@link javax.imageio.IIOParam#setSourceRegion(java.awt.Rectangle)} * method. * <p/> * Note: If it is possible for the writer to write the AOI directly, such a * method should be used instead, for efficiency. * * @param pImage the image to get AOI from * @param pParam the param optionally specifying the AOI * * @return a {@code BufferedImage} containing the area of interest (source * region), or the original image, if no source region was set, or * {@code pParam} was {@code null} */ protected static BufferedImage fakeAOI(final BufferedImage pImage, final ImageWriteParam pParam) { return IIOUtil.fakeAOI(pImage, getSourceRegion(pParam, pImage.getWidth(), pImage.getHeight())); }
@SuppressWarnings({"unchecked", "deprecation"}) @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { if (delegateProvider == null) { // Install delegate now delegateProvider = lookupProviderByName(registry, "com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi", ImageReaderSpi.class); } if (delegateProvider != null) { // Order before com.sun provider, to aid ImageIO in selecting our reader registry.setOrdering((Class<ImageReaderSpi>) category, this, delegateProvider); } else { // Or, if no delegate is found, silently deregister from the registry IIOUtil.deregisterProvider(registry, this, category); } }
/** * Utility method for getting the subsampled image. * The subsampling is defined by the * {@link javax.imageio.IIOParam#setSourceSubsampling(int, int, int, int)} * method. * <p/> * NOTE: This method does not take the subsampling offsets into * consideration. * <p/> * Note: If it is possible for the writer to subsample directly, such a * method should be used instead, for efficiency. * * @param pImage the image to subsample * @param pParam the param optionally specifying subsampling * * @return an {@code Image} containing the subsampled image, or the * original image, if no subsampling was specified, or * {@code pParam} was {@code null} */ protected static Image fakeSubsampling(final Image pImage, final ImageWriteParam pParam) { return IIOUtil.fakeSubsampling(pImage, pParam); } }
public static void main(String[] pArgs) throws IOException { BufferedImage image = ImageIO.read(new File(pArgs[0])); if (image == null) { System.err.println("Supported formats: " + Arrays.toString(IIOUtil.getNormalizedReaderFormatNames())); System.exit(1); } showIt(image, pArgs[0]); }
protected static Rectangle getSourceRegion(final ImageWriteParam pParam, final int pWidth, final int pHeight) { return IIOUtil.getSourceRegion(pParam, pWidth, pHeight); }
@SuppressWarnings({"unchecked"}) @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { if (delegateProvider == null) { // Install delegate now delegateProvider = lookupProviderByName(registry, "com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi", ImageWriterSpi.class); } if (delegateProvider != null) { // Order before com.sun provider, to aid ImageIO in selecting our writer registry.setOrdering((Class<ImageWriterSpi>) category, this, delegateProvider); } else { // Or, if no delegate is found, silently deregister from the registry deregisterProvider(registry, this, category); } }
/** * Utility method for getting the subsampled image. * The subsampling is defined by the * {@link javax.imageio.IIOParam#setSourceSubsampling(int, int, int, int)} * method. * <p/> * NOTE: This method does not take the subsampling offsets into * consideration. * <p/> * Note: If it is possible for the reader to subsample directly, such a * method should be used instead, for efficiency. * * @param pImage the image to subsample * @param pParam the param optionally specifying subsampling * * @return an {@code Image} containing the subsampled image, or the * original image, if no subsampling was specified, or * {@code pParam} was {@code null} */ protected static Image fakeSubsampling(Image pImage, ImageReadParam pParam) { return IIOUtil.fakeSubsampling(pImage, pParam); }
format, ICNSUtil.intToStr(resource.type), Arrays.toString(IIOUtil.getNormalizedReaderFormatNames()) ));
protected static Rectangle getSourceRegion(final ImageWriteParam pParam, final int pWidth, final int pHeight) { return IIOUtil.getSourceRegion(pParam, pWidth, pHeight); }
private static File dumpToFile(final ImageInputStream stream) throws IOException { File tempFile = File.createTempFile("imageio-icns-", ".png"); tempFile.deleteOnExit(); FileOutputStream out = new FileOutputStream(tempFile); try { FileUtil.copy(IIOUtil.createStreamAdapter(stream), out); } finally { out.close(); } return tempFile; }
private static void deregisterOSXTIFFImageReaderSpi() { IIORegistry registry = IIORegistry.getDefaultInstance(); ImageReaderSpi provider = lookupProviderByName(registry, "com.sun.imageio.plugins.tiff.TIFFImageReaderSpi", ImageReaderSpi.class); if (provider != null) { registry.deregisterServiceProvider(provider); } } }
@SuppressWarnings({"unchecked", "deprecation"}) @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { if (delegateProvider == null) { // Install delegate now delegateProvider = lookupProviderByName(registry, "com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi", ImageReaderSpi.class); } if (delegateProvider != null) { // Order before com.sun provider, to aid ImageIO in selecting our reader registry.setOrdering((Class<ImageReaderSpi>) category, this, delegateProvider); } else { // Or, if no delegate is found, silently deregister from the registry IIOUtil.deregisterProvider(registry, this, category); } }
/** * Utility method for getting the area of interest (AOI) of an image. * The AOI is defined by the {@link javax.imageio.IIOParam#setSourceRegion(java.awt.Rectangle)} * method. * <p/> * Note: If it is possible for the reader to read the AOI directly, such a * method should be used instead, for efficiency. * * @param pImage the image to get AOI from * @param pParam the param optionally specifying the AOI * * @return a {@code BufferedImage} containing the area of interest (source * region), or the original image, if no source region was set, or * {@code pParam} was {@code null} */ protected static BufferedImage fakeAOI(BufferedImage pImage, ImageReadParam pParam) { return IIOUtil.fakeAOI(pImage, getSourceRegion(pParam, pImage.getWidth(), pImage.getHeight())); }
/** * Utility method for getting the subsampled image. * The subsampling is defined by the * {@link javax.imageio.IIOParam#setSourceSubsampling(int, int, int, int)} * method. * <p/> * NOTE: This method does not take the subsampling offsets into * consideration. * <p/> * Note: If it is possible for the reader to subsample directly, such a * method should be used instead, for efficiency. * * @param pImage the image to subsample * @param pParam the param optionally specifying subsampling * * @return an {@code Image} containing the subsampled image, or the * original image, if no subsampling was specified, or * {@code pParam} was {@code null} */ protected static Image fakeSubsampling(Image pImage, ImageReadParam pParam) { return IIOUtil.fakeSubsampling(pImage, pParam); }
public static void main(String[] pArgs) throws IOException { BufferedImage image = ImageIO.read(new File(pArgs[0])); if (image == null) { System.err.println("Supported formats: " + Arrays.toString(IIOUtil.getNormalizedReaderFormatNames())); System.exit(1); } showIt(image, pArgs[0]); }
protected static Rectangle getSourceRegion(final ImageWriteParam pParam, final int pWidth, final int pHeight) { return IIOUtil.getSourceRegion(pParam, pWidth, pHeight); }
@Override protected void readData(ImageInputStream pInput) throws IOException { InputStream stream = IIOUtil.createStreamAdapter(pInput, size); try { profile = ICC_Profile.getInstance(stream); } finally { // Make sure stream has correct position after read stream.close(); } }
@SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { // Make sure we're ordered before the new JEP 262 JRE bundled TIFF plugin ImageWriterSpi sunSpi = lookupProviderByName(registry, "com.sun.imageio.plugins.tiff.TIFFImageWriterSpi", ImageWriterSpi.class); if (sunSpi != null && sunSpi.getVendorName() != null && sunSpi.getVendorName().startsWith("Oracle")) { registry.setOrdering((Class<ImageWriterSpi>) category, this, sunSpi); } }