01: /*
02: * $RCSfile: MlibMeanRIF.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:55:59 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.mlib;
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.ROI;
19: import com.sun.media.jai.opimage.RIFUtil;
20:
21: /**
22: * A <code>RIF</code> supporting the "Mean" operation in the
23: * rendered image mode using MediaLib.
24: *
25: * @see javax.media.jai.operator.MeanDescriptor
26: * @see MlibMeanOpImage
27: *
28: * @since EA3
29: *
30: */
31: public class MlibMeanRIF implements RenderedImageFactory {
32:
33: /** Constructor. */
34: public MlibMeanRIF() {
35: }
36:
37: /**
38: * Creates a new instance of <code>MlibMeanOpImage</code> in
39: * the rendered image mode.
40: *
41: * @param args The source image and the parameters.
42: * @param hints Rendering hints are ignored.
43: */
44: public RenderedImage create(ParameterBlock args,
45: RenderingHints hints) {
46: if (!MediaLibAccessor.isMediaLibCompatible(args)) {
47: return null;
48: }
49:
50: RenderedImage source = args.getRenderedSource(0);
51: ROI roi = (ROI) args.getObjectParameter(0);
52: int xPeriod = args.getIntParameter(1);
53: int yPeriod = args.getIntParameter(2);
54:
55: int xStart = source.getMinX(); // default values
56: int yStart = source.getMinY();
57:
58: int maxWidth = source.getWidth();
59: int maxHeight = source.getHeight();
60:
61: if (roi != null
62: && !roi.contains(xStart, yStart, maxWidth, maxHeight)) {
63: return null;
64: }
65:
66: // mediaLib supports only a sampling period of 1
67: if ((xPeriod != 1) || (yPeriod != 1)) {
68: return null;
69: }
70:
71: return new MlibMeanOpImage(source, roi, xStart, yStart,
72: xPeriod, yPeriod);
73: }
74: }
|