01: /*
02: * $RCSfile: MlibBandCombineRIF.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.RenderedImage;
16: import java.awt.image.renderable.ParameterBlock;
17: import java.awt.image.renderable.RenderedImageFactory;
18: import javax.media.jai.ImageLayout;
19: import java.util.Map;
20: import com.sun.media.jai.opimage.RIFUtil;
21:
22: /**
23: * A <code>RIF</code> supporting the "BandCombine" operation in the
24: * rendered image mode using MediaLib.
25: *
26: * @see javax.media.jai.operator.BandCombineDescriptor
27: * @see MlibBandCombineOpImage
28: *
29: */
30: public class MlibBandCombineRIF implements RenderedImageFactory {
31:
32: /** Constructor. */
33: public MlibBandCombineRIF() {
34: }
35:
36: /**
37: * Creates a new instance of <code>MlibBandCombineOpImage</code> in
38: * the rendered image mode.
39: *
40: * @param args The source image and the matrix.
41: * @param hints May contain rendering hints and destination image layout.
42: */
43: public RenderedImage create(ParameterBlock args,
44: RenderingHints hints) {
45: // Get ImageLayout and TileCache from RenderingHints.
46: ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
47:
48: if (!MediaLibAccessor.isMediaLibCompatible(args, layout)) {
49: return null;
50: }
51:
52: // Fall back to Java code if the matrix is not 3-by-4.
53: double[][] matrix = (double[][]) args.getObjectParameter(0);
54: if (matrix.length != 3) {
55: return null;
56: }
57: for (int i = 0; i < 3; i++) {
58: if (matrix[i].length != 4) {
59: return null;
60: }
61: }
62:
63: return new MlibBandCombineOpImage(args.getRenderedSource(0),
64: hints, layout, matrix);
65: }
66: }
|