blob: c650c7235f9a0e67d8256b9f368ef40550b498ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
*/
package org.apache.fop.image.analyser;
// Java
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
// FOP
import org.apache.fop.image.FopImageException;
/**
* Factory for ImageReader objects.
* @author Pankaj Narula
* @version 1.0
*/
public class ImageReaderFactory {
static protected Vector formats = null;
/**
* ImageReader maker.
* @param in image input stream
* @return ImageReader object
* @exception FopImageException an error occured during creation or
* image type is not supported
*/
static public ImageReader Make(String uri, InputStream in)
throws FopImageException {
// need to use a config file and remove static methods
formats = new Vector();
formats.addElement(new JPEGReader());
formats.addElement(new BMPReader());
formats.addElement(new GIFReader());
formats.addElement(new PNGReader());
formats.addElement(new TIFFReader());
formats.addElement(new SVGReader());
//
ImageReader reader;
BufferedInputStream bis = new BufferedInputStream(in);
Enumeration itr = formats.elements();
try {
while (itr.hasMoreElements()) {
reader = (ImageReader) itr.nextElement();
if (reader.verifySignature(uri, bis)) {
return reader;
}
}
} catch (IOException ex) {
throw new FopImageException(ex.getMessage());
}
return null;
}
}
|