01: /*
02: * $RCSfile: PatternRIF.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:40 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
13:
14: import java.awt.RenderingHints;
15: import java.awt.image.ColorModel;
16: import java.awt.image.Raster;
17: import java.awt.image.RenderedImage;
18: import java.awt.image.renderable.RenderedImageFactory;
19: import java.awt.image.renderable.ParameterBlock;
20: import javax.media.jai.ImageLayout;
21: import java.util.Map;
22:
23: /**
24: * A <code>RIF</code> supporting the "Pattern" operation in the
25: * rendered image layer.
26: *
27: * @see javax.media.jai.operator.PatternDescriptor
28: * @see PatternOpImage
29: *
30: */
31: public class PatternRIF implements RenderedImageFactory {
32:
33: /** Constructor. */
34: public PatternRIF() {
35: }
36:
37: /**
38: * Creates a new instance of PatternOpImage in the rendered layer.
39: * This method satisfies the implementation of RIF.
40: */
41: public RenderedImage create(ParameterBlock paramBlock,
42: RenderingHints renderHints) {
43: // Get ImageLayout from renderHints if any.
44: ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
45:
46: int minX = 0;
47: int minY = 0;
48:
49: if (layout != null) {
50: if (layout.isValid(ImageLayout.MIN_X_MASK)) {
51: minX = layout.getMinX(null);
52: }
53: if (layout.isValid(ImageLayout.MIN_Y_MASK)) {
54: minY = layout.getMinY(null);
55: }
56: }
57:
58: RenderedImage source = (RenderedImage) paramBlock.getSource(0);
59: Raster pattern = source.getData();
60: ColorModel colorModel = source.getColorModel();
61:
62: // Get image width and height from the parameter block
63: int width = paramBlock.getIntParameter(0);
64: int height = paramBlock.getIntParameter(1);
65:
66: return new PatternOpImage(pattern, colorModel, minX, minY,
67: width, height);
68: }
69: }
|