33 import java.awt.image.WritableRaster; 34 35 import javax.imageio.IIOException; 36 import javax.imageio.ImageReader; 37 import javax.imageio.ImageReadParam; 38 import javax.imageio.ImageTypeSpecifier; 39 import javax.imageio.metadata.IIOMetadata; 40 import javax.imageio.spi.ImageReaderSpi; 41 import javax.imageio.stream.ImageInputStream; 42 43 import java.io.*; 44 import java.util.ArrayList; 45 import java.util.Iterator; 46 47 import com.sun.imageio.plugins.common.I18N; 48 import com.sun.imageio.plugins.common.ReaderUtil; 49 50 /** This class is the Java Image IO plugin reader for WBMP images. 51 * It may subsample the image, clip the image, 52 * and shift the decoded image origin if the proper decoding parameter 53 * are set in the provided <code>WBMPImageReadParam</code>. 54 */ 55 public class WBMPImageReader extends ImageReader { 56 /** The input stream where reads from */ 57 private ImageInputStream iis = null; 58 59 /** Indicates whether the header is read. */ 60 private boolean gotHeader = false; 61 62 /** The original image width. */ 63 private int width; 64 65 /** The original image height. */ 66 private int height; 67 68 private int wbmpType; 69 70 private WBMPMetadata metadata; 71 72 /** Constructs <code>WBMPImageReader</code> from the provided 73 * <code>ImageReaderSpi</code>. 74 */ 75 public WBMPImageReader(ImageReaderSpi originator) { 76 super(originator); 77 } 78 79 /** Overrides the method defined in the superclass. */ 80 public void setInput(Object input, 81 boolean seekForwardOnly, 82 boolean ignoreMetadata) { 83 super.setInput(input, seekForwardOnly, ignoreMetadata); 84 iis = (ImageInputStream) input; // Always works 85 gotHeader = false; 86 } 87 88 /** Overrides the method defined in the superclass. */ 89 public int getNumImages(boolean allowSearch) throws IOException { 90 if (iis == null) { 91 throw new IllegalStateException(I18N.getString("GetNumImages0")); 92 } 93 if (seekForwardOnly && allowSearch) { | 33 import java.awt.image.WritableRaster; 34 35 import javax.imageio.IIOException; 36 import javax.imageio.ImageReader; 37 import javax.imageio.ImageReadParam; 38 import javax.imageio.ImageTypeSpecifier; 39 import javax.imageio.metadata.IIOMetadata; 40 import javax.imageio.spi.ImageReaderSpi; 41 import javax.imageio.stream.ImageInputStream; 42 43 import java.io.*; 44 import java.util.ArrayList; 45 import java.util.Iterator; 46 47 import com.sun.imageio.plugins.common.I18N; 48 import com.sun.imageio.plugins.common.ReaderUtil; 49 50 /** This class is the Java Image IO plugin reader for WBMP images. 51 * It may subsample the image, clip the image, 52 * and shift the decoded image origin if the proper decoding parameter 53 * are set in the provided {@code WBMPImageReadParam}. 54 */ 55 public class WBMPImageReader extends ImageReader { 56 /** The input stream where reads from */ 57 private ImageInputStream iis = null; 58 59 /** Indicates whether the header is read. */ 60 private boolean gotHeader = false; 61 62 /** The original image width. */ 63 private int width; 64 65 /** The original image height. */ 66 private int height; 67 68 private int wbmpType; 69 70 private WBMPMetadata metadata; 71 72 /** Constructs {@code WBMPImageReader} from the provided 73 * {@code ImageReaderSpi}. 74 */ 75 public WBMPImageReader(ImageReaderSpi originator) { 76 super(originator); 77 } 78 79 /** Overrides the method defined in the superclass. */ 80 public void setInput(Object input, 81 boolean seekForwardOnly, 82 boolean ignoreMetadata) { 83 super.setInput(input, seekForwardOnly, ignoreMetadata); 84 iis = (ImageInputStream) input; // Always works 85 gotHeader = false; 86 } 87 88 /** Overrides the method defined in the superclass. */ 89 public int getNumImages(boolean allowSearch) throws IOException { 90 if (iis == null) { 91 throw new IllegalStateException(I18N.getString("GetNumImages0")); 92 } 93 if (seekForwardOnly && allowSearch) { |