1 18 package org.apache.batik.ext.awt.image.codec; 19 20 import java.awt.image.Raster ; 21 import java.awt.image.RenderedImage ; 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 25 30 public abstract class ImageDecoderImpl implements ImageDecoder { 31 32 36 protected SeekableStream input; 37 38 42 protected ImageDecodeParam param; 43 44 49 public ImageDecoderImpl(SeekableStream input, 50 ImageDecodeParam param) { 51 this.input = input; 52 this.param = param; 53 } 54 55 64 public ImageDecoderImpl(InputStream input, 65 ImageDecodeParam param) { 66 this.input = new ForwardSeekableStream(input); 67 this.param = param; 68 } 69 70 78 public ImageDecodeParam getParam() { 79 return param; 80 } 81 82 92 public void setParam(ImageDecodeParam param) { 93 this.param = param; 94 } 95 96 100 public SeekableStream getInputStream() { 101 return input; 102 } 103 104 109 public int getNumPages() throws IOException { 110 return 1; 111 } 112 113 119 public Raster decodeAsRaster() throws IOException { 120 return decodeAsRaster(0); 121 } 122 123 133 public Raster decodeAsRaster(int page) throws IOException { 134 RenderedImage im = decodeAsRenderedImage(page); 135 return im.getData(); 136 } 137 138 144 public RenderedImage decodeAsRenderedImage() throws IOException { 145 return decodeAsRenderedImage(0); 146 } 147 148 158 public abstract RenderedImage decodeAsRenderedImage(int page) 159 throws IOException ; 160 } 161 | Popular Tags |