01: /*
02: * $RCSfile: MlibExtremaRIF.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:56 $
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 "Extrema" operation in the
23: * rendered image mode using MediaLib.
24: *
25: * @see javax.media.jai.operator.ExtremaDescriptor
26: * @see MlibExtremaOpImage
27: *
28: * @since EA4
29: *
30: */
31: public class MlibExtremaRIF implements RenderedImageFactory {
32:
33: /** Constructor. */
34: public MlibExtremaRIF() {
35: }
36:
37: /**
38: * Creates a new instance of <code>MlibExtremaOpImage</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: boolean saveLocations = ((Boolean) args.getObjectParameter(3))
55: .booleanValue();
56: int maxRuns = args.getIntParameter(4);
57:
58: int xStart = source.getMinX(); // default values
59: int yStart = source.getMinY();
60:
61: int maxWidth = source.getWidth();
62: int maxHeight = source.getHeight();
63:
64: if (roi != null
65: && !roi.contains(xStart, yStart, maxWidth, maxHeight)) {
66: return null;
67: }
68:
69: return new MlibExtremaOpImage(source, roi, xStart, yStart,
70: xPeriod, yPeriod, saveLocations, maxRuns);
71: }
72: }
|