01: /*
02: * $RCSfile: TransposeCRIF.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:46 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
13:
14: import java.awt.RenderingHints;
15: import java.awt.image.DataBuffer;
16: import java.awt.image.MultiPixelPackedSampleModel;
17: import java.awt.image.SampleModel;
18: import java.awt.image.RenderedImage;
19: import java.awt.image.renderable.RenderableImage;
20: import java.awt.image.renderable.RenderContext;
21: import java.awt.image.renderable.ParameterBlock;
22: import java.awt.image.renderable.RenderedImageFactory;
23: import javax.media.jai.CRIFImpl;
24: import javax.media.jai.EnumeratedParameter;
25: import javax.media.jai.ImageLayout;
26: import javax.media.jai.JAI;
27: import javax.media.jai.PlanarImage;
28: import javax.media.jai.RenderedOp;
29: import java.util.Map;
30:
31: /**
32: * @see TransposeOpImage
33: * @see TransposeBinaryOpImage
34: */
35: public class TransposeCRIF extends CRIFImpl {
36:
37: /** Constructor. */
38: public TransposeCRIF() {
39: super ("transpose");
40: }
41:
42: /**
43: * Creates a Tranpose operation.
44: */
45: public RenderedImage create(ParameterBlock paramBlock,
46: RenderingHints renderHints) {
47: // Get ImageLayout from renderHints if any.
48: ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
49:
50: RenderedImage source = paramBlock.getRenderedSource(0);
51:
52: EnumeratedParameter type = (EnumeratedParameter) paramBlock
53: .getObjectParameter(0);
54:
55: SampleModel sm = source.getSampleModel();
56: if ((sm instanceof MultiPixelPackedSampleModel)
57: && (sm.getSampleSize(0) == 1)
58: && (sm.getDataType() == DataBuffer.TYPE_BYTE
59: || sm.getDataType() == DataBuffer.TYPE_USHORT || sm
60: .getDataType() == DataBuffer.TYPE_INT)) {
61: return new TransposeBinaryOpImage(source, renderHints,
62: layout, type.getValue());
63: } else {
64: return new TransposeOpImage(source, renderHints, layout,
65: type.getValue());
66: }
67: }
68: }
|