/* Copyright (C) 2005-2011 Fabio Riccardi */ package com.lightcrafts.jai.operator; import com.lightcrafts.mediax.jai.*; import com.lightcrafts.mediax.jai.registry.RenderedRegistryMode; import com.lightcrafts.mediax.jai.registry.RenderableRegistryMode; import java.awt.image.RenderedImage; import java.awt.image.renderable.RenderableImage; import java.awt.*; /** * Created by IntelliJ IDEA. * User: fabio * Date: Apr 1, 2005 * Time: 10:09:12 AM * To change this template use File | Settings | File Templates. */ public class BlendDescriptor extends OperationDescriptorImpl { /** * The resource strings that provide the general documentation * and specify the parameter list for this operation. */ private static final String[][] resources = { {"GlobalName", "Blend"}, {"LocalName", "Blend"}, {"Vendor", "lightcrafts.com"}, {"Description", "Blend Two Images and a Mask"}, {"DocURL", "none"}, {"Version", "1.0"} }; private static Class[] paramClasses = { String.class, Double.class, ROIShape.class, RenderedImage.class }; private static String[] paramNames = { "blendingMode", "opacity", "mask", "colorSelection" }; private static Object[] paramDefaults = { "Overlay", 1.0, null, null }; /** Constructor. */ public BlendDescriptor() { super(resources, 2, paramClasses, paramNames, paramDefaults); } /** Returns true since renderable operation is supported. */ public boolean isRenderableSupported() { return true; } /** * Adds two images. * *

Creates a ParameterBlockJAI from all * supplied arguments except hints and invokes * {@link com.lightcrafts.mediax.jai.JAI#create(String,java.awt.image.renderable.ParameterBlock,java.awt.RenderingHints)}. * * @see com.lightcrafts.mediax.jai.JAI * @see com.lightcrafts.mediax.jai.ParameterBlockJAI * @see com.lightcrafts.mediax.jai.RenderedOp * * @param source0 RenderedImage source 0. * @param source1 RenderedImage source 1. * @param hints The RenderingHints to use. * May be null. * @return The RenderedOp destination. * @throws IllegalArgumentException if source0 is null. * @throws IllegalArgumentException if source1 is null. */ public static RenderedOp create(RenderedImage source0, RenderedImage source1, RenderedImage colorSelection, RenderingHints hints) { ParameterBlockJAI pb = new ParameterBlockJAI("Blend", RenderedRegistryMode.MODE_NAME); pb.setSource("source0", source0); pb.setSource("source1", source1); pb.setParameter("blendingMode", paramDefaults[0]); pb.setParameter("opacity", paramDefaults[1]); pb.setParameter("mask", paramDefaults[2]); pb.setParameter("colorSelection", colorSelection); return JAI.create("Blend", pb, hints); } public static RenderedOp create(RenderedImage source0, RenderedImage source1, RenderedImage colorSelection, String blendingMode, Double opacity, ROI mask, RenderingHints hints) { ParameterBlockJAI pb = new ParameterBlockJAI("Blend", RenderedRegistryMode.MODE_NAME); pb.setSource("source0", source0); pb.setSource("source1", source1); pb.setSource("colorSelection", colorSelection); pb.setParameter("blendingMode", blendingMode); pb.setParameter("opacity", opacity); pb.setParameter("mask", mask); return JAI.create("Blend", pb, hints); } /** * Adds two images. * *

Creates a ParameterBlockJAI from all * supplied arguments except hints and invokes * {@link JAI#createRenderable(String,java.awt.image.renderable.ParameterBlock,RenderingHints)}. * * @see JAI * @see ParameterBlockJAI * @see com.lightcrafts.mediax.jai.RenderableOp * * @param source0 RenderableImage source 0. * @param source1 RenderableImage source 1. * @param hints The RenderingHints to use. * May be null. * @return The RenderableOp destination. * @throws IllegalArgumentException if source0 is null. * @throws IllegalArgumentException if source1 is null. */ public static RenderableOp createRenderable(RenderableImage source0, RenderableImage source1, RenderingHints hints) { ParameterBlockJAI pb = new ParameterBlockJAI("Blend", RenderableRegistryMode.MODE_NAME); pb.setSource("source0", source0); pb.setSource("source1", source1); pb.setParameter("blendingMode", paramDefaults[0]); pb.setParameter("opacity", paramDefaults[1]); pb.setParameter("mask", paramDefaults[2]); return JAI.createRenderable("Blend", pb, hints); } }