01: /*
02: * $RCSfile: AWTImageRIF.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:56:11 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
13:
14: import java.awt.Image;
15: import java.awt.RenderingHints;
16: import java.awt.image.RenderedImage;
17: import java.awt.image.renderable.ParameterBlock;
18: import java.awt.image.renderable.RenderedImageFactory;
19: import javax.media.jai.ImageLayout;
20: import java.util.Map;
21:
22: /**
23: * A <code>RIF</code> supporting the "AWTImage" operation in the rendered
24: * layer. It's used by </code>OperationRegistry</code> to create an
25: * <code>AWTImageOpImage</code>.
26: *
27: * @see javax.media.jai.operator.AWTImageDescriptor
28: * @see AWTImageOpImage
29: *
30: */
31: public class AWTImageRIF implements RenderedImageFactory {
32:
33: /** Constructor. */
34: public AWTImageRIF() {
35: }
36:
37: /**
38: * Creates a new instance of <code>AWTImageOpImage</code>
39: * in the rendered layer.
40: * This method satisfies the implementation of RIF.
41: *
42: * @param paramBlock The AWT image.
43: */
44: public RenderedImage create(ParameterBlock paramBlock,
45: RenderingHints renderHints) {
46: // Get ImageLayout from renderHints if any.
47: ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
48:
49: // Extract the source AWT Image and cast it.
50: Image awtImage = (Image) paramBlock.getObjectParameter(0);
51:
52: // If it's already a RenderedImage (as for a BufferedImage) just cast.
53: if (awtImage instanceof RenderedImage) {
54: return (RenderedImage) awtImage;
55: }
56:
57: // Create a RenderedImage from the data.
58: return new AWTImageOpImage(renderHints, layout, awtImage);
59: }
60: }
|