590
|
1 /**
|
|
2 *
|
|
3 */
|
|
4 package digilib.io;
|
|
5
|
906
|
6 import java.io.IOException;
|
590
|
7 import java.io.InputStream;
|
|
8
|
906
|
9 import javax.imageio.ImageIO;
|
590
|
10 import javax.imageio.stream.ImageInputStream;
|
|
11
|
|
12 /**
|
|
13 * @author casties
|
|
14 *
|
|
15 */
|
|
16 public class ImageCacheStream extends ImageStream {
|
|
17
|
906
|
18 private ImageInputStream iis = null;
|
|
19
|
|
20 /** Create ImageCacheStream from InputStream and mime-type.
|
|
21 *
|
|
22 * @param stream
|
|
23 * @param mimeType
|
|
24 * @throws IOException
|
|
25 */
|
|
26 public ImageCacheStream(InputStream stream, String mimeType) throws IOException {
|
590
|
27 super(stream, mimeType);
|
906
|
28 /*
|
|
29 * Type of stream backing configured via ImageIO.setUseCache().
|
|
30 * [...] In general, it is preferable to
|
|
31 * use a FileCacheImageInputStream when reading from a regular
|
|
32 * InputStream. This class is provided for cases where it is not
|
|
33 * possible to create a writable temporary file.
|
|
34 */
|
|
35 iis = ImageIO.createImageInputStream(stream);
|
590
|
36 }
|
|
37
|
|
38 /*
|
|
39 * (non-Javadoc)
|
|
40 *
|
|
41 * @see digilib.io.ImageInput#hasImageInputStream()
|
|
42 */
|
|
43 @Override
|
|
44 public boolean hasImageInputStream() {
|
|
45 return true;
|
|
46 }
|
|
47
|
|
48 /*
|
|
49 * (non-Javadoc)
|
|
50 *
|
|
51 * @see digilib.io.ImageInput#getImageInputStream()
|
|
52 */
|
|
53 @Override
|
|
54 public ImageInputStream getImageInputStream() {
|
|
55 return iis;
|
|
56 }
|
|
57
|
|
58 }
|