001: /*
002: * $RCSfile: InvertDescriptor.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:37 $
010: * $State: Exp $
011: */
012: package javax.media.jai.operator;
013:
014: import java.awt.RenderingHints;
015: import java.awt.image.RenderedImage;
016: import java.awt.image.renderable.RenderableImage;
017: import javax.media.jai.JAI;
018: import javax.media.jai.OperationDescriptorImpl;
019: import javax.media.jai.ParameterBlockJAI;
020: import javax.media.jai.RenderableOp;
021: import javax.media.jai.RenderedOp;
022: import javax.media.jai.registry.RenderableRegistryMode;
023: import javax.media.jai.registry.RenderedRegistryMode;
024:
025: /**
026: * An <code>OperationDescriptor</code> describing the "Invert" operation.
027: *
028: * <p> The "Invert" operation inverts the pixel values of an image.
029: * For source images with signed data types, the pixel values of the
030: * destination image are defined by the pseudocode:
031: *
032: * <pre>dst[x][y][b] = -src[x][y][b]</pre>
033: *
034: * <p> For unsigned data types, the destination values are defined by:
035: *
036: * <pre>dst[x][y][b] = MAX_VALUE - src[x][y][b]</pre>
037: *
038: * where <code>MAX_VALUE</code> is the maximum value supported by the
039: * system of the data type of the source pixel.
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>Invert</td></tr>
045: * <tr><td>LocalName</td> <td>Invert</td></tr>
046: * <tr><td>Vendor</td> <td>com.sun.media.jai</td></tr>
047: * <tr><td>Description</td> <td>Invert the pixel values of an image.</td></tr>
048: * <tr><td>DocURL</td> <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/InvertDescriptor.html</td></tr>
049: * <tr><td>Version</td> <td>1.0</td></tr>
050: * </table></p>
051: *
052: * <p> No parameters are needed for the "Invert" operation.
053: *
054: * @see javax.media.jai.OperationDescriptor
055: */
056: public class InvertDescriptor extends OperationDescriptorImpl {
057:
058: /**
059: * The resource strings that provide the general documentation
060: * and specify the parameter list for this operation.
061: */
062: private static final String[][] resources = {
063: { "GlobalName", "Invert" },
064: { "LocalName", "Invert" },
065: { "Vendor", "com.sun.media.jai" },
066: { "Description", JaiI18N.getString("InvertDescriptor0") },
067: {
068: "DocURL",
069: "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/InvertDescriptor.html" },
070: { "Version", JaiI18N.getString("DescriptorVersion") } };
071:
072: /** Constructor. */
073: public InvertDescriptor() {
074: super (resources, 1, null, null, null);
075: }
076:
077: /** Returns <code>true</code> since renderable operation is supported. */
078: public boolean isRenderableSupported() {
079: return true;
080: }
081:
082: /**
083: * Inverts the pixel values of an image.
084: *
085: * <p>Creates a <code>ParameterBlockJAI</code> from all
086: * supplied arguments except <code>hints</code> and invokes
087: * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
088: *
089: * @see JAI
090: * @see ParameterBlockJAI
091: * @see RenderedOp
092: *
093: * @param source0 <code>RenderedImage</code> source 0.
094: * @param hints The <code>RenderingHints</code> to use.
095: * May be <code>null</code>.
096: * @return The <code>RenderedOp</code> destination.
097: * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
098: */
099: public static RenderedOp create(RenderedImage source0,
100: RenderingHints hints) {
101: ParameterBlockJAI pb = new ParameterBlockJAI("Invert",
102: RenderedRegistryMode.MODE_NAME);
103:
104: pb.setSource("source0", source0);
105:
106: return JAI.create("Invert", pb, hints);
107: }
108:
109: /**
110: * Inverts the pixel values of an image.
111: *
112: * <p>Creates a <code>ParameterBlockJAI</code> from all
113: * supplied arguments except <code>hints</code> and invokes
114: * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
115: *
116: * @see JAI
117: * @see ParameterBlockJAI
118: * @see RenderableOp
119: *
120: * @param source0 <code>RenderableImage</code> source 0.
121: * @param hints The <code>RenderingHints</code> to use.
122: * May be <code>null</code>.
123: * @return The <code>RenderableOp</code> destination.
124: * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
125: */
126: public static RenderableOp createRenderable(
127: RenderableImage source0, RenderingHints hints) {
128: ParameterBlockJAI pb = new ParameterBlockJAI("Invert",
129: RenderableRegistryMode.MODE_NAME);
130:
131: pb.setSource("source0", source0);
132:
133: return JAI.createRenderable("Invert", pb, hints);
134: }
135: }
|