railo.runtime.img.filter
Class ConvolveFilter

java.lang.Object
  extended by railo.runtime.img.filter.AbstractBufferedImageOp
      extended by railo.runtime.img.filter.ConvolveFilter
All Implemented Interfaces:
BufferedImageOp, Cloneable, DynFiltering
Direct Known Subclasses:
AverageFilter, BlurFilter, BumpFilter, GaussianFilter, SharpenFilter

public abstract class ConvolveFilter
extends AbstractBufferedImageOp
implements DynFiltering


Field Summary
static int CLAMP_EDGES
          Clamp pixels off the edge to the nearest edge.
static int WRAP_EDGES
          Wrap pixels off the edge to the opposite edge.
static int ZERO_EDGES
          Treat pixels off the edge as zero.
 
Constructor Summary
ConvolveFilter()
          Construct a filter with a null kernel.
ConvolveFilter(float[] matrix)
          Construct a filter with the given 3x3 kernel.
ConvolveFilter(int rows, int cols, float[] matrix)
          Construct a filter with the given kernel.
ConvolveFilter(Kernel kernel)
          Construct a filter with the given 3x3 kernel.
 
Method Summary
static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve a block of pixels.
static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction)
          Convolve a block of pixels.
static void convolveH(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a kernel consisting of one row.
static void convolveHV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a 2D kernel.
static void convolveV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a kernel consisting of one column.
 BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM)
           
 BufferedImage filter(BufferedImage src, BufferedImage dst)
           
 BufferedImage filter(BufferedImage src, Struct parameters)
           
 Rectangle2D getBounds2D(BufferedImage src)
           
 int getEdgeAction()
          Get the action to perfomr for pixels off the image edges.
 Kernel getKernel()
          Get the convolution kernel.
 Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
           
 boolean getPremultiplyAlpha()
          Get whether to premultiply the alpha channel.
 RenderingHints getRenderingHints()
           
 boolean getUseAlpha()
          Get whether to convolve the alpha channel.
 void setEdgeAction(String edgeAction)
          Set the action to perfomr for pixels off the image edges.
 void setKernel(Kernel kernel)
          Set the convolution kernel.
 void setPremultiplyAlpha(boolean premultiplyAlpha)
          Set whether to premultiply the alpha channel.
 void setUseAlpha(boolean useAlpha)
          Set whether to convolve the alpha channel.
 String toString()
           
 
Methods inherited from class railo.runtime.img.filter.AbstractBufferedImageOp
clone, getRGB, setRGB
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO_EDGES

public static final int ZERO_EDGES
Treat pixels off the edge as zero.

See Also:
Constant Field Values

CLAMP_EDGES

public static final int CLAMP_EDGES
Clamp pixels off the edge to the nearest edge.

See Also:
Constant Field Values

WRAP_EDGES

public static final int WRAP_EDGES
Wrap pixels off the edge to the opposite edge.

See Also:
Constant Field Values
Constructor Detail

ConvolveFilter

public ConvolveFilter()
Construct a filter with a null kernel. This is only useful if you're going to change the kernel later on.


ConvolveFilter

public ConvolveFilter(float[] matrix)
Construct a filter with the given 3x3 kernel.

Parameters:
matrix - an array of 9 floats containing the kernel

ConvolveFilter

public ConvolveFilter(int rows,
                      int cols,
                      float[] matrix)
Construct a filter with the given kernel.

Parameters:
rows - the number of rows in the kernel
cols - the number of columns in the kernel
matrix - an array of rows*cols floats containing the kernel

ConvolveFilter

public ConvolveFilter(Kernel kernel)
Construct a filter with the given 3x3 kernel.

Parameters:
kernel - the convolution kernel
Method Detail

setKernel

public void setKernel(Kernel kernel)
Set the convolution kernel.

Parameters:
kernel - the kernel
See Also:
getKernel()

getKernel

public Kernel getKernel()
Get the convolution kernel.

Returns:
the kernel
See Also:
setKernel(java.awt.image.Kernel)

setEdgeAction

public void setEdgeAction(String edgeAction)
                   throws ExpressionException
Set the action to perfomr for pixels off the image edges. valid values are: - clamp (default): Clamp pixels off the edge to the nearest edge. - wrap: Wrap pixels off the edge to the opposite edge. - zero: Treat pixels off the edge as zero

Parameters:
edgeAction - the action
Throws:
ExpressionException

getEdgeAction

public int getEdgeAction()
Get the action to perfomr for pixels off the image edges.

Returns:
the action
See Also:
setEdgeAction(java.lang.String)

setUseAlpha

public void setUseAlpha(boolean useAlpha)
Set whether to convolve the alpha channel.

Parameters:
useAlpha - true to convolve the alpha
See Also:
getUseAlpha()

getUseAlpha

public boolean getUseAlpha()
Get whether to convolve the alpha channel.

Returns:
true to convolve the alpha
See Also:
setUseAlpha(boolean)

setPremultiplyAlpha

public void setPremultiplyAlpha(boolean premultiplyAlpha)
Set whether to premultiply the alpha channel.

Parameters:
premultiplyAlpha - true to premultiply the alpha
See Also:
getPremultiplyAlpha()

getPremultiplyAlpha

public boolean getPremultiplyAlpha()
Get whether to premultiply the alpha channel.

Returns:
true to premultiply the alpha
See Also:
setPremultiplyAlpha(boolean)

filter

public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)
Specified by:
filter in interface BufferedImageOp

createCompatibleDestImage

public BufferedImage createCompatibleDestImage(BufferedImage src,
                                               ColorModel dstCM)
Specified by:
createCompatibleDestImage in interface BufferedImageOp
Overrides:
createCompatibleDestImage in class AbstractBufferedImageOp

getBounds2D

public Rectangle2D getBounds2D(BufferedImage src)
Specified by:
getBounds2D in interface BufferedImageOp
Overrides:
getBounds2D in class AbstractBufferedImageOp

getPoint2D

public Point2D getPoint2D(Point2D srcPt,
                          Point2D dstPt)
Specified by:
getPoint2D in interface BufferedImageOp
Overrides:
getPoint2D in class AbstractBufferedImageOp

getRenderingHints

public RenderingHints getRenderingHints()
Specified by:
getRenderingHints in interface BufferedImageOp
Overrides:
getRenderingHints in class AbstractBufferedImageOp

convolve

public static void convolve(Kernel kernel,
                            int[] inPixels,
                            int[] outPixels,
                            int width,
                            int height,
                            int edgeAction)
Convolve a block of pixels.

Parameters:
kernel - the kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width
height - the height
edgeAction - what to do at the edges

convolve

public static void convolve(Kernel kernel,
                            int[] inPixels,
                            int[] outPixels,
                            int width,
                            int height,
                            boolean alpha,
                            int edgeAction)
Convolve a block of pixels.

Parameters:
kernel - the kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width
height - the height
alpha - include alpha channel
edgeAction - what to do at the edges

convolveHV

public static void convolveHV(Kernel kernel,
                              int[] inPixels,
                              int[] outPixels,
                              int width,
                              int height,
                              boolean alpha,
                              int edgeAction)
Convolve with a 2D kernel.

Parameters:
kernel - the kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width
height - the height
alpha - include alpha channel
edgeAction - what to do at the edges

convolveH

public static void convolveH(Kernel kernel,
                             int[] inPixels,
                             int[] outPixels,
                             int width,
                             int height,
                             boolean alpha,
                             int edgeAction)
Convolve with a kernel consisting of one row.

Parameters:
kernel - the kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width
height - the height
alpha - include alpha channel
edgeAction - what to do at the edges

convolveV

public static void convolveV(Kernel kernel,
                             int[] inPixels,
                             int[] outPixels,
                             int width,
                             int height,
                             boolean alpha,
                             int edgeAction)
Convolve with a kernel consisting of one column.

Parameters:
kernel - the kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width
height - the height
alpha - include alpha channel
edgeAction - what to do at the edges

toString

public String toString()
Overrides:
toString in class Object

filter

public BufferedImage filter(BufferedImage src,
                            Struct parameters)
                     throws PageException
Specified by:
filter in interface DynFiltering
Throws:
PageException


Copyright © 2012 Railo