Class FastPixelImpl

    • Field Detail

      • width

        protected final int width
        Width of the image
      • height

        protected final int height
        Height of the image
      • alpha

        protected boolean alpha
        True if the underlying image has an alpha component
      • alphaReplacementThreshold

        protected int alphaReplacementThreshold
      • replacementR

        protected int replacementR
      • replacementG

        protected int replacementG
      • replacementB

        protected int replacementB
      • replacementA

        protected int replacementA
    • Constructor Detail

      • FastPixelImpl

        public FastPixelImpl​(int width,
                             int height)
    • Method Detail

      • isReplaceOpaqueColors

        public boolean isReplaceOpaqueColors()
        Description copied from interface: FastPixel
        Check if the pixel loader replaces opaque colors with a non opaque version. Opaque values are replaced only on get operations. To activate this option call FastPixel.setReplaceOpaqueColors(int, int, int, int, int) and set a color which will be returned in case that the pixel has an alpha value smaller than the specified threshold
        Specified by:
        isReplaceOpaqueColors in interface FastPixel
        Returns:
        true if opaque colors are replaced by a user defined color
      • setReplaceOpaqueColors

        public void setReplaceOpaqueColors​(int alphaThreshold,
                                           int r,
                                           int g,
                                           int b,
                                           int a)
        Description copied from interface: FastPixel
        Replace all pixels values in the image which have an alpha < than the specified threshold. The pixel value is replaced for all get operations, including luminosity calculation. Set operations are not touched by this setting.
        Specified by:
        setReplaceOpaqueColors in interface FastPixel
        Parameters:
        alphaThreshold - replace each pixel which has an alpha value smaller or equal to the threshold in the range of [0-255]. A value of will disabled color replacement
        r - the red value which will be returned in case of an opaque pixel [0-255]
        g - the green value which will be returned in case of an opaque pixel [0-255]
        b - the blue value which will be returned in case of an opaque pixel [0-255]
        a - the alpha value which will be returned in case of an opaque pixel [0-255]
      • getRed1D

        public int[] getRed1D()
        Description copied from interface: FastPixel
        Get the red component of the entire image mapped to a 1d array
        Specified by:
        getRed1D in interface FastPixel
        Returns:
        the red values in range [0-255]
      • getBlue1D

        public int[] getBlue1D()
        Description copied from interface: FastPixel
        Get the blue component of the entire image mapped to a 1d array
        Specified by:
        getBlue1D in interface FastPixel
        Returns:
        the red values in range [0-255]
      • getGreen1D

        public int[] getGreen1D()
        Description copied from interface: FastPixel
        Get the green component of the entire image mapped to a 1d array
        Specified by:
        getGreen1D in interface FastPixel
        Returns:
        the green values in range [0-255]
      • getLuma1D

        public int[] getLuma1D()
        Description copied from interface: FastPixel
        Return the Y(Luma) component of the YCbCr color model fof the entire image mapped to a 1d array
        Specified by:
        getLuma1D in interface FastPixel
        Returns:
        the luma component in range [0-255]
      • getAverageGrayscale

        public int getAverageGrayscale​(int index)
        Description copied from interface: FastPixel
        Get the average grayscale at the specified offset

        Average grayscale: (R+G+B)/3

        This

        Specified by:
        getAverageGrayscale in interface FastPixel
        Parameters:
        index - offset of der underlying array
        Returns:
        the grayscale values in range [0-255]
      • getLuma

        public int getLuma​(int index)
        Description copied from interface: FastPixel
        Return the Y(Luma) component of the YCbCr color model for the specified offset.
        Specified by:
        getLuma in interface FastPixel
        Parameters:
        index - of the underlying array
        Returns:
        the luma component in range [0-255]
      • getRGB

        public int[][] getRGB()
        Returns the rgb values of the entire image in an 2 d array in the default RGB color model(TYPE_INT_ARGB). There are only 8-bits of precision for each color component in the returned data when using this method. An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds.
        Specified by:
        getRGB in interface FastPixel
        Returns:
        a 2d integer array containing the argb values of the image
        Since:
        1.3.0 com.github.kilianB
      • getRed

        public int[][] getRed()
        Get the red component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
        Specified by:
        getRed in interface FastPixel
        Returns:
        the red values
        Since:
        1.3.0 com.github.kilianB
      • getGreen

        public int[][] getGreen()
        Description copied from interface: FastPixel
        Get the green component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
        Specified by:
        getGreen in interface FastPixel
        Returns:
        the green values in range [0-255]
      • getBlue

        public int[][] getBlue()
        Description copied from interface: FastPixel
        Get the blue component of the entire image mapped to a 2d array representing the x and y coordinates of the image.
        Specified by:
        getBlue in interface FastPixel
        Returns:
        the blue values in range [0-255]
      • getAlpha

        public int[][] getAlpha()
        Description copied from interface: FastPixel
        Get the alpha component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
        Specified by:
        getAlpha in interface FastPixel
        Returns:
        the alpha values or null if alpha is not supported
      • getLuma

        public int[][] getLuma()
        Description copied from interface: FastPixel
        Return the Y(Luma) component of the YCbCr color model for the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
        Specified by:
        getLuma in interface FastPixel
        Returns:
        the luma component in range [0-255]
      • getAverageGrayscale

        public int[][] getAverageGrayscale()
        Description copied from interface: FastPixel
        Get the average grayscale of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.

        Average grayscale: (R+G+B)/3

        Average grayscale: (R+G+B)/3

        Specified by:
        getAverageGrayscale in interface FastPixel
        Returns:
        the grayscale values in range [0 - 255]
      • setAlpha

        public void setAlpha​(int[][] newAlpha)
        Set new alpha values for the entire picture
        Specified by:
        setAlpha in interface FastPixel
        Parameters:
        newAlpha - red values in range [0-255]
        Since:
        1.4.5 com.github.kilianB
      • setRed

        public void setRed​(int[][] newRed)
        Set new red values for the entire picture
        Specified by:
        setRed in interface FastPixel
        Parameters:
        newRed - red values in range [0-255]
        Since:
        1.4.5 com.github.kilianB
      • setGreen

        public void setGreen​(int[][] newGreen)
        Set new green values for the entire picture
        Specified by:
        setGreen in interface FastPixel
        Parameters:
        newGreen - red values in range [0-255]
        Since:
        1.4.5 com.github.kilianB
      • setBlue

        public void setBlue​(int[][] newBlue)
        Set new blue values for the entire picture
        Specified by:
        setBlue in interface FastPixel
        Parameters:
        newBlue - red values in range [0-255]
        Since:
        1.4.5 com.github.kilianB
      • setAverageGrayscale

        public void setAverageGrayscale​(int[][] newGrayValue)
        Description copied from interface: FastPixel
        Set the gray values of the entire image.

        Average grayscale: (R+G+B)/3

        It is up to the inheriting class to decide how the gray value is reflected at the value level. If the image is still in rgb or argb mode the value of each individual channel will be set to the gray value

        Specified by:
        setAverageGrayscale in interface FastPixel
        Parameters:
        newGrayValue - to set the pixels to range [0 - 255]
      • getRed

        public final int getRed​(int offset)
        Description copied from interface: FastPixel
        Get the red value at the specified offset
        Specified by:
        getRed in interface FastPixel
        Parameters:
        offset - offset of ther underlying array
        Returns:
        the red value in range [0-255]
      • getGreen

        public final int getGreen​(int offset)
        Description copied from interface: FastPixel
        Get the green value of the specified offset
        Specified by:
        getGreen in interface FastPixel
        Parameters:
        offset - the offset of the underlying array
        Returns:
        the green value in range [0-255]
      • getBlue

        public final int getBlue​(int offset)
        Description copied from interface: FastPixel
        Get the blue value of the specified offset
        Specified by:
        getBlue in interface FastPixel
        Parameters:
        offset - the offset of the underlying array
        Returns:
        the green value in range [0-255]
      • getAlpha

        public final int getAlpha​(int offset)
        Description copied from interface: FastPixel
        Get the alpha value of the specified pixel
        Specified by:
        getAlpha in interface FastPixel
        Parameters:
        offset - the offset in the underlying array
        Returns:
        the alpha value in range [0-255] or -1 if alpha is not supported
      • getRedInternal

        protected abstract int getRedInternal​(int offset)
      • getGreenInternal

        protected abstract int getGreenInternal​(int offset)
      • getBlueInternal

        protected abstract int getBlueInternal​(int offset)
      • getAlphaInternal

        protected abstract int getAlphaInternal​(int offset)
      • hasAlpha

        public boolean hasAlpha()
        Description copied from interface: FastPixel
        Check if an image supports alpha values
        Specified by:
        hasAlpha in interface FastPixel
        Returns:
        true if the image has an alpha channel. false otherwise