01: /*
02: * $RCSfile: WarpRIF.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:47 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
13:
14: import java.awt.RenderingHints;
15: import java.awt.image.RenderedImage;
16: import java.awt.image.renderable.ParameterBlock;
17: import java.awt.image.renderable.RenderedImageFactory;
18: import javax.media.jai.BorderExtender;
19: import javax.media.jai.ImageLayout;
20: import javax.media.jai.Interpolation;
21: import javax.media.jai.InterpolationNearest;
22: import javax.media.jai.InterpolationBilinear;
23: import javax.media.jai.InterpolationBicubic;
24: import javax.media.jai.InterpolationBicubic2;
25: import javax.media.jai.InterpolationTable;
26: import java.util.Map;
27: import javax.media.jai.Warp;
28:
29: /**
30: * A <code>RIF</code> supporting the "Warp" operation in the rendered
31: * image layer.
32: *
33: * @since EA2
34: * @see javax.media.jai.operator.WarpDescriptor
35: * @see GeneralWarpOpImage
36: *
37: */
38: public class WarpRIF implements RenderedImageFactory {
39:
40: /** Constructor. */
41: public WarpRIF() {
42: }
43:
44: /**
45: * Creates a new instance of warp operator according to the warp object
46: * and interpolation method.
47: *
48: * @param paramBlock The warp and interpolation objects.
49: */
50: public RenderedImage create(ParameterBlock paramBlock,
51: RenderingHints renderHints) {
52: // Get ImageLayout from renderHints if any.
53: ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
54:
55: // Get BorderExtender from renderHints if any.
56: BorderExtender extender = RIFUtil
57: .getBorderExtenderHint(renderHints);
58:
59: RenderedImage source = paramBlock.getRenderedSource(0);
60: Warp warp = (Warp) paramBlock.getObjectParameter(0);
61: Interpolation interp = (Interpolation) paramBlock
62: .getObjectParameter(1);
63:
64: double[] backgroundValues = (double[]) paramBlock
65: .getObjectParameter(2);
66:
67: if (interp instanceof InterpolationNearest) {
68: return new WarpNearestOpImage(source, renderHints, layout,
69: warp, interp, backgroundValues);
70: } else if (interp instanceof InterpolationBilinear) {
71: return new WarpBilinearOpImage(source, extender,
72: renderHints, layout, warp, interp, backgroundValues);
73: } else {
74: return new WarpGeneralOpImage(source, extender,
75: renderHints, layout, warp, interp, backgroundValues);
76: }
77: }
78: }
|