public static ByteArrayOutputStream exportImage(final BufferedImage image, final String targetExt) { // generate an byte array from the given image final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.setUseCache(false); // because we write into ram here try { ImageIO.write(image, targetExt, baos); return baos; } catch (final IOException e) { // should not happen return null; } }
public Image load(InputStream in, boolean flipY) throws IOException{ ImageIO.setUseCache(false); BufferedImage img = ImageIO.read(in); if (img == null){ return null; } return load(img, flipY); }
public static Point getImageSizeFromStream(InputStream is) { if (!initialized) { // Stops ImageIO from creating temp files when reading images // from input stream. ImageIO.setUseCache(false); initialized = true; } try { ImageInputStream imageStream = ImageIO.createImageInputStream(is); Iterator<ImageReader> readers = ImageIO.getImageReaders(imageStream); if (!readers.hasNext()) return null; ImageReader reader = readers.next(); try { reader.setInput(imageStream); return new Point(reader.getWidth(0), reader.getHeight(0)); } finally { reader.dispose(); } } catch (IOException e) { throw new RuntimeException(e); } }
ImageIO.setUseCache(false); // do not write a cache to disc; keep in RAM return ImageIO.read(new ByteArrayInputStream(tileb)); } catch (final EOFException e) {
/** * Get image using relative path in resources. * * @param path * @return */ public static Image getImageFromResources(String path) { try(InputStream stream = UI.class.getResourceAsStream(path)) { ImageIO.setUseCache(false); BufferedImage image = ImageIO.read(stream); return image; } catch (IOException e) { e.printStackTrace(); } return null; } }
/** * Read the image stream of the signature and set height and width. * * @param stream stream of your visible signature image * @throws IOException If we can't read, flush, or close stream of image */ private void readImageStream(InputStream stream) throws IOException { ImageIO.setUseCache(false); setImage(ImageIO.read(stream)); }
private static Raster readJPEGRaster(InputStream stream) throws IOException { // find suitable image reader Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG"); ImageReader reader = null; while (readers.hasNext()) { reader = readers.next(); if (reader.canReadRaster()) { break; } } if (reader == null) { throw new MissingImageReaderException( "Cannot read JPEG image: a suitable JAI I/O image filter is not installed"); } try (ImageInputStream iis = ImageIO.createImageInputStream(stream)) { reader.setInput(iis); ImageIO.setUseCache(false); return reader.readRaster(0, null); } finally { reader.dispose(); } }
public static void main(final String[] args) throws IOException { ImageIO.setUseCache(false);
public static void main(final String[] args) throws IOException { ImageIO.setUseCache(false);
ImageIO.setUseCache(false); Raster raster;
ImageIO.setUseCache(false);
/** * Read the image stream of the signature and set height and width. * * @param stream stream of your visible signature image * @throws IOException If we can't read, flush, or close stream of image */ private void readImageStream(InputStream stream) throws IOException { ImageIO.setUseCache(false); setImage(ImageIO.read(stream)); }
public Image load(InputStream in, boolean flipY) throws IOException{ ImageIO.setUseCache(false); BufferedImage img = ImageIO.read(in); if (img == null) return null; return load(img, flipY); }
/** * Read the image stream of the signature and set height and width. * * @param stream stream of your visible signature image * @throws IOException If we can't read, flush, or close stream of image */ private void readImageStream(InputStream stream) throws IOException { ImageIO.setUseCache(false); setImage(ImageIO.read(stream)); }
public Image load(InputStream in, boolean flipY) throws IOException{ ImageIO.setUseCache(false); BufferedImage img = ImageIO.read(in); if (img == null){ return null; } return load(img, flipY); }
@Activate protected void activate(ComponentContext context) { // Do not use cache. Images must be download locally before reading them. ImageIO.setUseCache(false); // SPI Issue Resolution // Register imageio SPI with the classloader of this bundle // and unregister imageio SPI if imageio.jar is also in the jre/lib/ext folder Class<?>[] jaiCodecs = { ChannelImageInputStreamSpi.class, ChannelImageOutputStreamSpi.class }; for (Class<?> c : jaiCodecs) { ImageioUtil.registerServiceProvider(c); } }
private static void initialize() { ImageIO.setUseCache(false); ImageIO.scanForPlugins(); // probably not necessary... initialized = true; }
public static File inject() { // Speed up imageloading System.out.println("Turning off ImageIO disk-caching"); ImageIO.setUseCache(false); loadIconsOnFrames(); // Set the workdir, return value will get assigned System.out.println("Setting gameDir to: " + Launch.minecraftHome); return Launch.minecraftHome; }
public KaptchaExtend() { // Switch off disk based caching. ImageIO.setUseCache(false); this.props.put("kaptcha.border", "no"); this.props.put("kaptcha.textproducer.font.color", "black"); this.props.put("kaptcha.textproducer.char.space", "5"); Config config = new Config(this.props); this.kaptchaProducer = config.getProducerImpl(); this.sessionKeyValue = config.getSessionKey(); this.sessionKeyDateValue = config.getSessionDate(); }
@Override public void init() { // Switch off disk based caching. ImageIO.setUseCache(false); this.props.put("kaptcha.border", "no"); this.props.put("kaptcha.textproducer.font.color", "black"); this.props.put("kaptcha.textproducer.char.space", "5"); Config config = new Config(this.props); this.kaptchaProducer = config.getProducerImpl(); this.sessionKeyValue = config.getSessionKey(); this.sessionKeyDateValue = config.getSessionDate(); }