Class ImageFunction2D

  • All Implemented Interfaces:
    Function2D

    public class ImageFunction2D
    extends java.lang.Object
    implements Function2D
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean alpha  
      static int CLAMP  
      protected int edgeAction  
      protected int height  
      protected int[] pixels  
      protected int width  
      static int WRAP  
      static int ZERO  
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageFunction2D​(int[] pixels, int width, int height, int edgeAction, boolean alpha)  
      ImageFunction2D​(java.awt.Image image)  
      ImageFunction2D​(java.awt.image.BufferedImage image)  
      ImageFunction2D​(java.awt.image.BufferedImage image, boolean alpha)  
      ImageFunction2D​(java.awt.image.BufferedImage image, int edgeAction, boolean alpha)  
      ImageFunction2D​(java.awt.Image image, int edgeAction, boolean alpha)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float evaluate​(float x, float y)
      Evaluate the pixel and the x and y values according to the edge action.
      int getEdgeAction()
      Get the edgeAction.
      int getHeight()
      Get the height.
      int[] getPixels()
      Get the pixels.
      int[] getRGB​(java.awt.image.BufferedImage image, int x, int y, int width, int height, int[] pixels)
      A convenience method for getting ARGB pixels from an image.
      int getWidth()
      Get the width.
      void init​(int[] pixels, int width, int height, int edgeAction, boolean alpha)
      Initialize an image.
      void setEdgeAction​(int edgeAction)
      Set the edgeAction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pixels

        protected int[] pixels
      • width

        protected int width
      • height

        protected int height
      • edgeAction

        protected int edgeAction
      • alpha

        protected boolean alpha
    • Constructor Detail

      • ImageFunction2D

        public ImageFunction2D​(java.awt.image.BufferedImage image)
      • ImageFunction2D

        public ImageFunction2D​(java.awt.image.BufferedImage image,
                               boolean alpha)
      • ImageFunction2D

        public ImageFunction2D​(java.awt.image.BufferedImage image,
                               int edgeAction,
                               boolean alpha)
      • ImageFunction2D

        public ImageFunction2D​(int[] pixels,
                               int width,
                               int height,
                               int edgeAction,
                               boolean alpha)
      • ImageFunction2D

        public ImageFunction2D​(java.awt.Image image)
      • ImageFunction2D

        public ImageFunction2D​(java.awt.Image image,
                               int edgeAction,
                               boolean alpha)
    • Method Detail

      • getRGB

        public int[] getRGB​(java.awt.image.BufferedImage image,
                            int x,
                            int y,
                            int width,
                            int height,
                            int[] pixels)
        A convenience method for getting ARGB pixels from an image. This tries to avoid the performance penalty of BufferedImage.getRGB unmanaging the image.
        Parameters:
        image - The image
        x - The x value of the pixel in one of the corners
        y - The y value of the pixel in one of the corners
        width - The width of the pixels to get
        height - The height of the pixels to get
        pixels - The image
        Returns:
        The subimage
      • init

        public void init​(int[] pixels,
                         int width,
                         int height,
                         int edgeAction,
                         boolean alpha)
        Initialize an image.
        Parameters:
        pixels - The image
        width - The width of the pixels to get
        height - The height of the pixels to get
        edgeAction - The edgeAction, one of ZERO, CLAMP or WRAP.
        alpha - The alpha
      • evaluate

        public float evaluate​(float x,
                              float y)
        Evaluate the pixel and the x and y values according to the edge action.
        Specified by:
        evaluate in interface Function2D
        Parameters:
        x - The x value
        y - The y value
        Returns:
        The value
      • setEdgeAction

        public void setEdgeAction​(int edgeAction)
        Set the edgeAction.
        Parameters:
        edgeAction - one of ZERO, CLAMP or WRAP.
        See Also:
        getEdgeAction()
      • getEdgeAction

        public int getEdgeAction()
        Get the edgeAction.
        Returns:
        The edgeAction, one of ZERO, CLAMP or WRAP.
        See Also:
        setEdgeAction(int)
      • getWidth

        public int getWidth()
        Get the width.
        Returns:
        The width
      • getHeight

        public int getHeight()
        Get the height.
        Returns:
        the height
      • getPixels

        public int[] getPixels()
        Get the pixels.
        Returns:
        the pixels.