Package javax.imageio.stream

Examples of javax.imageio.stream.FileImageInputStream


    @Override
    public ImageInputStream createInputStreamInstance(Object input, boolean useCache,
            File cacheDir) throws IOException {
        if (File.class.isInstance(input)) {
            return new FileImageInputStream((File) input);
        }
        throw new IllegalArgumentException("input is not an instance of java.io.File");
    }
View Full Code Here


* @author Hasan Keklik
*/
public class FileUtil {

  public static void copy(File curFile, File destFile) throws IOException {
    FileImageInputStream fis;
    FileOutputStream fos;
    byte[] buffer = new byte[4096];
    try {
      fos = new FileOutputStream(destFile);
      fis = new FileImageInputStream(curFile);
      int length;
      while ((length = fis.read(buffer)) > 0) {
        fos.write(buffer, 0, length);
      }
      fis.close();
      fos.close();
    } finally {
      fis = null;
      fos = null;
      buffer = null;
View Full Code Here

     * @param width Largura da imagem.
     * @param heigth Comprimento da imagem.
     */
    public static BufferedImage load(String pathImage) throws FileNotFoundException, IOException {
        File f = new File(pathImage);
        FileImageInputStream fiis = new FileImageInputStream(f);
        BufferedImage bi = ImageIO.read(fiis);
        return bi;
    }
View Full Code Here

        }
    }

    public FileImageInputStream createImageInputStream()
            throws IOException {
        return new FileImageInputStream(file);
    }
View Full Code Here

        }
    }

    public BufferedImage readFrame(int frameIndex) throws IOException {
        if (iis == null)
            iis = new FileImageInputStream(file);

        if (decompressor != null)
            return decompressFrame(iis, frameIndex);

        iis.setByteOrder(pixeldata.bigEndian
View Full Code Here

    public void setUp() throws Exception {
        String imageResourceDir = System.getProperty("basedir",".")+"/"+"test-resources"+File.separator+"image";

        File file = new File(imageResourceDir+File.separator+"test.jpg");
        ImageInputStream fiis = new FileImageInputStream(file);
        Image image = ImageIO.read(fiis);
        imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);

        String textResourceDir = System.getProperty("basedir",".")+"/"+"test/org/apache/axis2/jaxws/xmlhttp";
        File file2 = new File(textResourceDir+File.separator+"README.txt");
View Full Code Here

                return false;
            }
        }
        if (input != null) {
            NetcdfFile file = null;
            FileImageInputStream fis = null;
            try {

                // Checking Magic Number
                fis = new FileImageInputStream(input);
                byte[] b = new byte[4];
                fis.mark();
                fis.readFully(b);
                fis.reset();
                boolean cdfCheck = (b[0] == (byte)0x43 && b[1] == (byte)0x44 && b[2] == (byte)0x46);
                boolean hdf5Check = (b[0] == (byte)0x89 && b[1] == (byte)0x48 && b[2] == (byte)0x44);
                boolean gribCheck = (b[0] == (byte)0x47 && b[1] == (byte)0x52 && b[2] == (byte)0x49 && b[3] == (byte)0x42);

                // Check if the GRIB library is available
                gribCheck &= NetCDFUtilities.isGribAvailable();
               
                boolean isNetCDF = true;
                if (!cdfCheck && !hdf5Check && !gribCheck) {
                    if (!isNcML(input)) {
                        isNetCDF = false;
                    }
                }
                if (!isNetCDF) {
                    return false;
                }
                file = NetcdfDataset.acquireDataset(input.getPath(), null);
                if (file != null) {
                    if (LOGGER.isLoggable(Level.FINE))
                        LOGGER.fine("File successfully opened");
                    canDecode = true;
                }
            } catch (IOException ioe) {
                canDecode = false;
            } finally {
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (Throwable t) {

                    }
                }
View Full Code Here

    @Test
    public void testJAIReadType() throws IOException {
        // Definition of the reader
        ImageReader reader = new TIFFImageReaderSpi().createReaderInstance();
        FileImageInputStream in = new FileImageInputStream(DataUtilities.urlToFile(granuleUrl));

        try {
            reader.setInput(in);

            // Definition of the read type
            ReadType jaiImageRead = ReadType.JAI_IMAGEREAD;

            // Check if the default read type is JAI
            ReadType defaultRead = ReadType.getDefault();
            assertEquals(jaiImageRead, defaultRead);

            // Test 1 = wrong region
            RenderedImage output = jaiImageRead.read(readParameters, IMAGE_INDEX, granuleUrl,
                    rasterDimensionsWrong, reader, hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 2 = null URL
            output = jaiImageRead.read(readParameters, IMAGE_INDEX, null, rasterDimensions, reader,
                    hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 3 = null Reader
            output = jaiImageRead.read(readParameters, IMAGE_INDEX, granuleUrl, rasterDimensions,
                    null, hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 4 = correct
            output = jaiImageRead.read(readParameters, IMAGE_INDEX, granuleUrl, rasterDimensions,
                    reader, hints, CLOSE_ELEMENTS);
            assertNotNull(output);
            Rectangle sourceRegion = readParameters.getSourceRegion();
            // Calculate the intersection between the raster dimension and the read parameters
            Rectangle.intersect(sourceRegion, rasterDimensions, sourceRegion);
            // Check dimensions
            assertEquals(output.getMinX(), sourceRegion.x);
            assertEquals(output.getMinY(), sourceRegion.y);
            assertEquals(output.getWidth(), sourceRegion.width);
            assertEquals(output.getHeight(), sourceRegion.height);
        } finally {
            if (in != null) {
                in.close();
            }
            if(reader != null){
                reader.dispose();
            }
        }
View Full Code Here

    @Test
    public void testDirectReadType() throws IOException {
        // Definition of the reader
        ImageReader reader = new TIFFImageReaderSpi().createReaderInstance();
        FileImageInputStream in = new FileImageInputStream(DataUtilities.urlToFile(granuleUrl));

        try {
            reader.setInput(in);
            // Definition of the read type
            ReadType directRead = ReadType.DIRECT_READ;

            // Test 1 = wrong region
            RenderedImage output = directRead.read(readParameters, IMAGE_INDEX, granuleUrl,
                    rasterDimensionsWrong, reader, hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 2 = null URL
            output = directRead.read(readParameters, IMAGE_INDEX, null, rasterDimensions, reader,
                    hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 3 = null Reader
            output = directRead.read(readParameters, IMAGE_INDEX, granuleUrl, rasterDimensions,
                    null, hints, CLOSE_ELEMENTS);
            assertNull(output);

            // Test 4 = correct
            output = directRead.read(readParameters, IMAGE_INDEX, granuleUrl, rasterDimensions,
                    reader, hints, CLOSE_ELEMENTS);
            assertNotNull(output);
            Rectangle sourceRegion = readParameters.getSourceRegion();
            // Calculate the intersection between the raster dimension and the read parameters
            Rectangle.intersect(sourceRegion, rasterDimensions, sourceRegion);
            // Check dimensions
            assertEquals(output.getMinX(), sourceRegion.x);
            assertEquals(output.getMinY(), sourceRegion.y);
            assertEquals(output.getWidth(), sourceRegion.width);
            assertEquals(output.getHeight(), sourceRegion.height);
        } finally {
            if (in != null) {
                in.close();
            }
            if(reader != null){
                reader.dispose();
            }
        }
View Full Code Here

     * @throws FileNotFoundException
     */
    private RenderedImage getSWAN() throws IOException, FileNotFoundException {
      final AsciiGridsImageReader reader = (AsciiGridsImageReader) new AsciiGridsImageReaderSpi()
          .createReaderInstance();
      reader.setInput(new FileImageInputStream(TestData.file(this,
          "arcgrid/SWAN_NURC_LigurianSeaL07_HSIGN.asc")));
      final RenderedImage image = reader.readAsRenderedImage(0, null);
      return image;
    }
View Full Code Here

TOP

Related Classes of javax.imageio.stream.FileImageInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.