Class CheckeredScreenFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public final class CheckeredScreenFilter
    extends AbstractRowwiseFilter
    A filter that applies a checkerboard pattern to the source image by multiplying the alpha channel of alternating pixels by different values. pattern. This filter is intended for use with translucent images; if the destination image has no alpha channel, then the filter will have no effect.

    In-place filtering: This class supports in-place filtering (the source and destination images may be the same).

    Author:
    Chris Jennings
    • Constructor Detail

      • CheckeredScreenFilter

        public CheckeredScreenFilter()
        Creates a new filter with an even alpha multiplier of 0 and an odd multiplier of 1. This will cause even pixels to become completely transparent while odd pixels retain the same alpha value.
      • CheckeredScreenFilter

        public CheckeredScreenFilter​(float evenAlpha,
                                     float oddAlpha)
        Creates a new filter with a size of 1 and the specified even and odd alpha multipliers.
        Parameters:
        evenAlpha - the alpha value for even squares
        oddAlpha - the alpha value for odd squares
      • CheckeredScreenFilter

        public CheckeredScreenFilter​(int checkSize,
                                     float evenAlpha,
                                     float oddAlpha)
        Creates a new filter with the specified size of 1 and the specified even and odd alpha multipliers.
        Parameters:
        checkSize - the size of the squares in the check pattern, in pixels
        evenAlpha - the alpha value for even squares
        oddAlpha - the alpha value for odd squares
    • Method Detail

      • getEvenAlpha

        public float getEvenAlpha()
        Returns the alpha multiplier for even squares.
        Returns:
        the non-negative even multiplier
      • setEvenAlpha

        public void setEvenAlpha​(float evenAlpha)
        Sets the alpha multiplier for even squares. The existing alpha value in even squares will be multiplied by this amount. Typical values are between 0 and 1, but values above 1 are allowed.
        Parameters:
        evenAlpha - the even multiplier
      • getOddAlpha

        public float getOddAlpha()
        Returns the alpha multiplier for odd squares.
        Returns:
        the non-negative odd multiplier
      • setOddAlpha

        public void setOddAlpha​(float oddAlpha)
        Sets the alpha multiplier for odd squares. The existing alpha value in odd squares will be multiplied by this amount. Typical values are between 0 and 1, but values above 1 are allowed.
        Parameters:
        oddAlpha - the even multiplier
      • getCheckSize

        public int getCheckSize()
        Returns the size of the checkered squares, in pixels.
        Returns:
        the square size, a positive integer
      • setCheckSize

        public void setCheckSize​(int size)
        Sets the size of the checkered squares, in pixels.
        Parameters:
        size - the size of check pattern squares
      • createCompatibleDestImage

        public java.awt.image.BufferedImage createCompatibleDestImage​(java.awt.image.BufferedImage source,
                                                                      java.awt.image.ColorModel destinationColorModel)
        Description copied from class: AbstractImageFilter
        Specified by:
        createCompatibleDestImage in interface java.awt.image.BufferedImageOp
        Overrides:
        createCompatibleDestImage in class AbstractImageFilter
      • filterPixels

        public void filterPixels​(int y,
                                 int[] argb)
        Description copied from class: AbstractRowwiseFilter
        This method is called with a block of ARGB values to be filtered. Subclasses should override this method to implement the actual filtering algorithm, replacing each pixel in the supplied array with its filtered value.
        Specified by:
        filterPixels in class AbstractRowwiseFilter