01: /*
02: * $RCSfile: MlibAndConstRIF.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:50 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.mlib;
13:
14: import java.awt.RenderingHints;
15: import java.awt.image.DataBuffer;
16: import java.awt.image.RenderedImage;
17: import java.awt.image.SampleModel;
18: import java.awt.image.renderable.ParameterBlock;
19: import java.awt.image.renderable.RenderedImageFactory;
20: import javax.media.jai.ImageLayout;
21: import java.util.Map;
22: import com.sun.media.jai.opimage.RIFUtil;
23:
24: /**
25: * A <code>RIF</code> supporting the "AndConst" operation in the
26: * rendered image mode using MediaLib.
27: *
28: * @see javax.media.jai.operator.AndConstDescriptor
29: * @see MlibAndConstOpImage
30: *
31: */
32: public class MlibAndConstRIF implements RenderedImageFactory {
33:
34: /** Constructor. */
35: public MlibAndConstRIF() {
36: }
37:
38: /**
39: * Creates a new instance of <code>MlibAndConstOpImage</code> in
40: * the rendered image mode.
41: *
42: * @param args The source image and the constants.
43: * @param hints May contain rendering hints and destination image layout.
44: */
45: public RenderedImage create(ParameterBlock args,
46: RenderingHints hints) {
47: ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
48:
49: if (!MediaLibAccessor.isMediaLibCompatible(args, layout)
50: || !MediaLibAccessor.hasSameNumBands(args, layout)) {
51: return null;
52: }
53:
54: /* Check whether dest has data type of float or double. */
55: if (layout != null) {
56: SampleModel sm = layout.getSampleModel(null);
57:
58: if (sm != null) {
59: int dtype = sm.getDataType();
60: if (dtype == DataBuffer.TYPE_FLOAT
61: || dtype == DataBuffer.TYPE_DOUBLE) {
62: return null;
63: }
64: }
65: }
66:
67: return new MlibAndConstOpImage(args.getRenderedSource(0),
68: hints, layout, (int[]) args.getObjectParameter(0));
69: }
70: }
|