01: /*
02: * $RCSfile: SingleTileRenderedImage.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:55:38 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.codecimpl;
13:
14: import java.awt.image.Raster;
15: import java.awt.image.ColorModel;
16: import java.awt.image.SampleModel;
17:
18: /**
19: * A simple class that provides RenderedImage functionality
20: * given a Raster and a ColorModel.
21: */
22: public class SingleTileRenderedImage extends SimpleRenderedImage {
23:
24: Raster ras;
25:
26: /**
27: * Constructs a SingleTileRenderedImage based on a Raster
28: * and a ColorModel.
29: *
30: * @param ras A Raster that will define tile (0, 0) of the image.
31: * @param cm A ColorModel that will serve as the image's
32: * ColorModel.
33: */
34: public SingleTileRenderedImage(Raster ras, ColorModel colorModel) {
35: this .ras = ras;
36:
37: this .tileGridXOffset = this .minX = ras.getMinX();
38: this .tileGridYOffset = this .minY = ras.getMinY();
39: this .tileWidth = this .width = ras.getWidth();
40: this .tileHeight = this .height = ras.getHeight();
41: this .sampleModel = ras.getSampleModel();
42: this .colorModel = colorModel;
43: }
44:
45: /**
46: * Returns the image's Raster as tile (0, 0).
47: */
48: public Raster getTile(int tileX, int tileY) {
49: if (tileX != 0 || tileY != 0) {
50: throw new IllegalArgumentException(JaiI18N
51: .getString("SingleTileRenderedImage0"));
52: }
53: return ras;
54: }
55: }
|