private ImageInputStream createImageInputStream(InputStream is) throws IOException { if (this.cacheDir != null) { return new FileCacheImageInputStream(is, this.cacheDir); } else { return new MemoryCacheImageInputStream(is); } }
private ImageInputStream createImageInputStream(InputStream is) throws IOException { if (this.cacheDir != null) { return new FileCacheImageInputStream(is, this.cacheDir); } else { return new MemoryCacheImageInputStream(is); } }
closeMe = false; if (ImageIO.getUseCache()) inStream = new FileCacheImageInputStream((InputStream) input, null); else inStream = new MemoryCacheImageInputStream((InputStream) input);
public ImageInputStream getInputStream(InputStream is) { try { return new FileCacheImageInputStream(is, null); } catch (IOException e) { return new MemoryCacheImageInputStream(is); } }
private ImageInputStream createImageInputStream(InputStream is) throws IOException { if (this.cacheDir != null) { return new FileCacheImageInputStream(is, this.cacheDir); } else { return new MemoryCacheImageInputStream(is); } }
public ImageInputStream createImageInputStream(int tileX, int tileY) throws IOException { final String entryName = getTileBasename(tileX, tileY) + ".raw"; final File file = new File(imageDir.getBasePath(), entryName + ".zip"); final ZipFile zipFile = new ZipFile(file); final ZipEntry zipEntry = zipFile.getEntry(entryName); final InputStream inputStream = zipFile.getInputStream(zipEntry); return new FileCacheImageInputStream(inputStream, tmpDir); } }
private ImageInputStream createImageInputStream(InputStream is) throws IOException { if (this.cacheDir != null) { return new FileCacheImageInputStream(is, cacheDir); } else { return new MemoryCacheImageInputStream(is); } }
public ImageInputStream getInputStream(InputStream is) { try { return new FileCacheImageInputStream(is, null); } catch (IOException e) { return new MemoryCacheImageInputStream(is); } }
private ImageInputStream createImageInputStream(InputStream is) throws IOException { if (this.cacheDir != null) { return new FileCacheImageInputStream(is, cacheDir); } else { return new MemoryCacheImageInputStream(is); } }
public ImageInputStream getInputStream(InputStream is) { try { return new FileCacheImageInputStream(is, null); } catch (IOException e) { return new MemoryCacheImageInputStream(is); } }
public ImageInputStream createImageInputStream(int tileX, int tileY) throws IOException { final String entryName = getTileBasename(tileX, tileY); final File file = new File(imageDir.getBasePath()); final ZipFile zipFile = new ZipFile(file); final Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { final ZipEntry zipEntry = entries.nextElement(); if (zipEntry.getName().startsWith(entryName)) { final InputStream inputStream = zipFile.getInputStream(zipEntry); return new FileCacheImageInputStream(inputStream, tmpDir); } } throw new IOException("No tile for coordinates " + tileX + ", " + tileY + "."); } }
private static ImageInputStream getImageInputStream(final File file) throws IOException { final String name = file.getName().toLowerCase(); if (name.endsWith(".zip") || name.endsWith(".gz")) { return new FileCacheImageInputStream(EnvisatProductReaderPlugIn.getInflaterInputStream(file), null); } else { return new FileImageInputStream(file); } }
public static ImageInputStream createImageInputStream(final InputStream inStream, final Dimension bandDimensions) throws IOException { long size = bandDimensions.width*bandDimensions.height; return useFileCache || size > 500000000 ? new FileCacheImageInputStream(inStream, createCacheDir()) : new MemoryCacheImageInputStream(inStream); } }
public final static ImageInputStream getStream(InputStream stream) { if (stream.markSupported() && !(stream instanceof InflaterInputStream)) return new ImageInputStreamAdapter(stream); if (ImageIO.getUseCache()) try { return new FileCacheImageInputStream(stream, null); } catch (IOException e) { } return new MemoryCacheImageInputStream(stream); } }
/** * * @see javax.imageio.spi.ImageInputStreamSpi#createInputStreamInstance(java.lang.Object, * boolean, java.io.File) */ public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) { // is it a URL? if (!(input instanceof URL)) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("The provided input is not a valid URL."); return null; } try { // URL that points to a file? final URL sourceURL = ((URL) input); final File tempFile = Utilities.urlToFile(sourceURL); if (tempFile.exists() && tempFile.isFile() && tempFile.canRead()) return fileStreamSPI.createInputStreamInstance(tempFile,useCache, cacheDir); // URL that does NOT points to a file, let's open up a stream if (useCache) return new MemoryCacheImageInputStream(sourceURL.openStream()); else return new FileCacheImageInputStream(sourceURL.openStream(), cacheDir); } catch (IOException e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); return null; } }
public final static ImageInputStream getStream(InputStream stream) { if (stream.markSupported() && !(stream instanceof InflaterInputStream)) return new ImageInputStreamAdapter(stream); if (ImageIO.getUseCache()) try { return new FileCacheImageInputStream(stream, null); } catch (IOException e) { } return new MemoryCacheImageInputStream(stream); }
public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) throws IOException { if(input == null || !(input instanceof ReadableByteChannel)) { throw new IllegalArgumentException("XXX"); } ImageInputStream stream = null; if(input instanceof FileChannel) { stream = new FileChannelImageInputStream((FileChannel)input); } else { InputStream inStream = Channels.newInputStream((ReadableByteChannel)input); if(useCache) { try { stream = new FileCacheImageInputStream(inStream, cacheDir); } catch(IOException e) { // Cache file could not be created. } } if(stream == null) { stream = new MemoryCacheImageInputStream(inStream); } } return stream; }
public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) throws IOException { if(input == null || !(input instanceof ReadableByteChannel)) { throw new IllegalArgumentException("XXX"); } ImageInputStream stream = null; if(input instanceof FileChannel) { stream = new FileChannelImageInputStream((FileChannel)input); } else { InputStream inStream = Channels.newInputStream((ReadableByteChannel)input); if(useCache) { try { stream = new FileCacheImageInputStream(inStream, cacheDir); } catch(IOException e) { // Cache file could not be created. } } if(stream == null) { stream = new MemoryCacheImageInputStream(inStream); } } return stream; }
public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) throws IOException { if(input == null || !(input instanceof ReadableByteChannel)) { throw new IllegalArgumentException("XXX"); } ImageInputStream stream = null; if(input instanceof FileChannel) { stream = new FileChannelImageInputStream((FileChannel)input); } else { InputStream inStream = Channels.newInputStream((ReadableByteChannel)input); if(useCache) { try { stream = new FileCacheImageInputStream(inStream, cacheDir); } catch(IOException e) { // Cache file could not be created. } } if(stream == null) { stream = new MemoryCacheImageInputStream(inStream); } } return stream; }
@Test public void testSmallImageNearGreenwichMeridian() throws Exception { final URL resource = getClass().getResource("nearGreenwichMeridian.tif"); final String filePath = resource.getFile(); final GeoTiffProductReader reader = new GeoTiffProductReader(new GeoTiffProductReaderPlugIn()); final Product product = reader.readGeoTIFFProduct(new FileCacheImageInputStream(resource.openStream(), null), new File(filePath)); final GeoCoding geoCoding = product.getGeoCoding(); final GeoPos ul = geoCoding.getGeoPos(new PixelPos(0, 0), null); assertEquals(1.92584, ul.lon, 1.0e-5); assertEquals(48.28314, ul.lat, 1.0e-5); final GeoPos lr = geoCoding.getGeoPos(new PixelPos(49, 49), null); assertEquals(2.03596, lr.lon, 1.0e-5); assertEquals(48.17303, lr.lat, 1.0e-5); } }