01: /*
02: * @(#)FileImageSource.java 1.23 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package sun.awt.image;
29:
30: import java.io.InputStream;
31: import java.io.BufferedInputStream;
32: import java.io.IOException;
33: import sun.io.FileIOFactory;
34:
35: public class FileImageSource extends InputStreamImageSource {
36: String imagefile;
37:
38: public FileImageSource(String filename) {
39: SecurityManager security = System.getSecurityManager();
40: if (security != null) {
41: security.checkRead(filename);
42: }
43: imagefile = filename;
44: }
45:
46: final boolean checkSecurity(Object context, boolean quiet) {
47: // File based images only ever need to be checked statically
48: // when the image is retrieved from the cache.
49: return true;
50: }
51:
52: protected ImageDecoder getDecoder() {
53: InputStream is;
54: try {
55: is = new BufferedInputStream(FileIOFactory
56: .getInputStream(imagefile));
57: } catch (IOException e) {
58: return null;
59: }
60: return getDecoder(is);
61: }
62: }
|