List of usage examples for javax.imageio.stream ImageInputStream readLine
String readLine() throws IOException;
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; }