01: /*
02: * $RCSfile: ErrorDiffusionRIF.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:25 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.opimage;
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 javax.media.jai.KernelJAI;
21: import javax.media.jai.LookupTableJAI;
22:
23: /**
24: * A <code>RIF</code> supporting the "ErrorDiffusion" operation in the rendered
25: * image layer.
26: *
27: * @since EA2
28: * @see javax.media.jai.operator.ErrorDiffusionDescriptor
29: */
30: public class ErrorDiffusionRIF implements RenderedImageFactory {
31:
32: /** Constructor. */
33: public ErrorDiffusionRIF() {
34: }
35:
36: /**
37: * Creates a new instance of an error diffusion operator according to the
38: * color map and error filter kernel.
39: *
40: * @param paramBlock The color map and error filter kernel objects.
41: */
42: public RenderedImage create(ParameterBlock paramBlock,
43: RenderingHints renderHints) {
44: // Get ImageLayout from renderHints if any.
45: ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
46:
47: RenderedImage source = paramBlock.getRenderedSource(0);
48: LookupTableJAI lookupTable = (LookupTableJAI) paramBlock
49: .getObjectParameter(0);
50: KernelJAI kernel = (KernelJAI) paramBlock.getObjectParameter(1);
51:
52: return new ErrorDiffusionOpImage(source, renderHints, layout,
53: lookupTable, kernel);
54: }
55: }
|