Example usage for javax.imageio.stream ImageInputStream readLine

List of usage examples for javax.imageio.stream ImageInputStream readLine

Introduction

In this page you can find the example usage for javax.imageio.stream ImageInputStream readLine.

Prototype

String readLine() throws IOException;

Source Link

Document

Reads the next line of text from the input stream.

Usage

From source file:ch5ImageReader.java

/**
 * this method sets the stream metadata for the images represented by the
 * ImageInputStream iis. This method is specific for the ch5 format and thus
 * only sets the numberImages field./* w  w w.  j a v a2 s.c o m*/
 */
private void setStreamMetadata(ImageInputStream iis) {
    streammd = new ch5StreamMetadata();
    try {
        String magicNumber = iis.readLine();
        int numImages = Integer.parseInt(iis.readLine().trim());
        streammd.numberImages = numImages;
        imagemd = new ch5ImageMetadata[streammd.numberImages];
    } catch (IOException exception) {
    }
}

From source file:ch5ImageReader.java

/**
 * this method sets the image metadata for the image indexed by index
 * imageIndex. This method is specific for the ch5 format and thus only sets
 * the image width and image height//  w w  w.  j a  v  a 2 s.  c  om
 */
private void setImageMetadata(ImageInputStream iis, int imageIndex) {
    imagemd[imageIndex] = new ch5ImageMetadata();
    try {
        String s;
        s = iis.readLine();
        while (s.length() == 0)
            s = iis.readLine();
        imagemd[imageIndex].imageWidth = Integer.parseInt(s.trim());
        s = iis.readLine();
        imagemd[imageIndex].imageHeight = Integer.parseInt(s.trim());
    } catch (IOException exception) {
    }
}

From source file:ch5ImageReaderSpi.java

/**
 * This method gets called when an application wants to see if the input
 * image's format can be decoded by this ImageReader. In this case, we'll
 * simply check the first byte of data to see if its a 5 which is the format
 * type's magic number// ww w.  j a  v  a  2 s . c o m
 */
public boolean canDecodeInput(Object input) {
    boolean reply = false;

    ImageInputStream iis = (ImageInputStream) input;
    iis.mark(); // mark where we are in ImageInputStream
    try {
        String magicNumber = iis.readLine().trim();
        iis.reset(); // reset stream back to marked location
        if (magicNumber.equals("5"))
            reply = true;
    } catch (IOException exception) {
    }
    return reply;
}