001: /*
002: * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: *
028: * $Id: Images.java,v 1.6 2005/01/10 23:25:42 cvs Exp $
029: */
030:
031: package com.caucho.graphics;
032:
033: import java.awt.*;
034: import java.awt.image.ColorModel;
035: import java.awt.image.ImageConsumer;
036: import java.util.Hashtable;
037:
038: public class Images implements ImageConsumer {
039: private static Toolkit toolkit;
040: private int width;
041: private int height;
042:
043: public static Images getImage(String filename) {
044: try {
045: if (toolkit == null)
046: toolkit = Toolkit.getDefaultToolkit();
047:
048: Image img = toolkit.getImage(filename);
049:
050: if (img == null)
051: return null;
052:
053: Images image = new Images();
054:
055: img.getSource().startProduction(image);
056:
057: synchronized (image) {
058: image.wait(100);
059: }
060:
061: if (image.width > 0 && image.height > 0)
062: return image;
063: else
064: return null;
065: } catch (Throwable e) {
066: return null;
067: }
068: }
069:
070: public int getWidth() {
071: return width;
072: }
073:
074: public int getHeight() {
075: return height;
076: }
077:
078: public void imageComplete(int status) {
079: synchronized (this ) {
080: this .notifyAll();
081: }
082: }
083:
084: public void setColorModel(ColorModel model) {
085: }
086:
087: public void setDimensions(int width, int height) {
088: this .width = width;
089: this .height = height;
090: }
091:
092: public void setHints(int hintflags) {
093: }
094:
095: public void setPixels(int x, int y, int w, int h, ColorModel mode,
096: byte[] pixels, int off, int scansize) {
097: }
098:
099: public void setPixels(int x, int y, int w, int h, ColorModel mode,
100: int[] pixels, int off, int scansize) {
101: }
102:
103: public void setProperties(Hashtable<?, ?> props) {
104: }
105: }
|