001: /*
002: * $RCSfile: BMPDescriptor.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:57:29 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import com.sun.media.jai.codec.SeekableStream;
015: import java.awt.RenderingHints;
016: import java.awt.image.RenderedImage;
017: import javax.media.jai.JAI;
018: import javax.media.jai.OperationDescriptorImpl;
019: import javax.media.jai.ParameterBlockJAI;
020: import javax.media.jai.RenderedOp;
021: import javax.media.jai.registry.RenderedRegistryMode;
022:
023: /**
024: * An <code>OperationDescriptor</code> describing the "BMP" operation.
025: *
026: * <p> The "BMP" operation reads a standard BMP input stream.
027: * The "BMP" operation currently reads Version2, Version3 and
028: * some of the Version 4 images, as defined in the Microsoft
029: * Windows BMP file format.
030: *
031: * <p> Version 4 of the BMP format allows for the specification of alpha
032: * values, gamma values and CIE colorspaces. These are not
033: * currently handled, but the relevant properties are emitted, if
034: * they are available from the BMP image file.
035: *
036: * <p><b> The classes in the <code>com.sun.media.jai.codec</code>
037: * package are not a committed part of the JAI API. Future releases
038: * of JAI will make use of new classes in their place. This
039: * class will change accordingly.</b>
040: *
041: * <p><table border=1>
042: * <caption>Resource List</caption>
043: * <tr><th>Name</th> <th>Value</th></tr>
044: * <tr><td>GlobalName</td> <td>BMP</td></tr>
045: * <tr><td>LocalName</td> <td>BMP</td></tr>
046: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
047: * <tr><td>Description</td> <td>Reads an image from a BMP stream.</td></tr>
048: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BMPDescriptor.html</td></tr>
049: * <tr><td>Version</td> <td>1.0</td></tr>
050: * <tr><td>arg0Desc</td> <td>The SeekableStream to read from.</td></tr>
051: * </table></p>
052: *
053: * <p><table border=1>
054: * <caption>Parameter List</caption>
055: * <tr><th>Name</th> <th>Class Type</th>
056: * <th>Default Value</th></tr>
057: * <tr><td>stream</td> <td>com.sun.media.jai.codec.SeekableStream</td>
058: * <td>NO_PARAMETER_DEFAULT</td>
059: * </table></p>
060: *
061: * @see com.sun.media.jai.codec.SeekableStream
062: * @see javax.media.jai.OperationDescriptor */
063: public class BMPDescriptor extends OperationDescriptorImpl {
064:
065: /**
066: * The resource strings that provide the general documentation and
067: * specify the parameter list for the "BMP" operation.
068: */
069: private static final String[][] resources = {
070: { "GlobalName", "BMP" },
071: { "LocalName", "BMP" },
072: { "Vendor", "com.sun.media.jai" },
073: { "Description", JaiI18N.getString("BMPDescriptor0") },
074: {
075: "DocURL",
076: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BMPDescriptor.html" },
077: { "Version", JaiI18N.getString("DescriptorVersion") },
078: { "arg0Desc", JaiI18N.getString("BMPDescriptor1") }, };
079:
080: /** The parameter names for the "BMP" operation. */
081: private static final String[] paramNames = { "stream" };
082:
083: /** The parameter class types for the "BMP" operation. */
084: private static final Class[] paramClasses = { com.sun.media.jai.codec.SeekableStream.class };
085:
086: /** The parameter default values for the "BMP" operation. */
087: private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
088:
089: /** Constructor. */
090: public BMPDescriptor() {
091: super (resources, 0, paramClasses, paramNames, paramDefaults);
092: }
093:
094: /**
095: * Reads an image from a BMP stream.
096: *
097: * <p>Creates a <code>ParameterBlockJAI</code> from all
098: * supplied arguments except <code>hints</code> and invokes
099: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
100: *
101: * @see JAI
102: * @see ParameterBlockJAI
103: * @see RenderedOp
104: *
105: * @param stream The SeekableStream to read from.
106: * @param hints The <code>RenderingHints</code> to use.
107: * May be <code>null</code>.
108: * @return The <code>RenderedOp</code> destination.
109: * @throws IllegalArgumentException if <code>stream</code> is <code>null</code>.
110: */
111: public static RenderedOp create(SeekableStream stream,
112: RenderingHints hints) {
113: ParameterBlockJAI pb = new ParameterBlockJAI("BMP",
114: RenderedRegistryMode.MODE_NAME);
115:
116: pb.setParameter("stream", stream);
117:
118: return JAI.create("BMP", pb, hints);
119: }
120: }
|