Class FastPixelByte

  • All Implemented Interfaces:
    FastPixel

    public class FastPixelByte
    extends FastPixelImpl
    High performant access of RGB/YCrCb/HSV Data.

    RGB methods run faster by a magnitude (factor 10) compared to the original java getRGB method.

    Currently only ARGB and RGB image types are supported.

    Since:
    1.3.0 com.github.kilianB
    Author:
    Kilian
    • Constructor Detail

      • FastPixelByte

        public FastPixelByte​(BufferedImage bImage)
        Constructs a fast pixel object with the underlying buffered image.

        Note that calling this method may cause this DataBufferobject to be incompatible with performance optimizations used by some implementations (such as caching an associated image in video memory).

        Parameters:
        bImage - The buffered image to extract data from
        Since:
        1.3.0 com.github.kilianB
    • Method Detail

      • getRGB

        public int getRGB​(int index)
      • 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
        Overrides:
        getRGB in class FastPixelImpl
        Returns:
        a 2d integer array containing the argb values of the image
        Since:
        1.3.0 com.github.kilianB
      • getAlpha

        public int[][] getAlpha()
        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
        Overrides:
        getAlpha in class FastPixelImpl
        Returns:
        the alpha values or null if alpha is not supported
        Since:
        1.3.0 com.github.kilianB
      • setAlpha

        public void setAlpha​(int index,
                             int newAlpha)
        Description copied from interface: FastPixel
        Set the alpha value. This method is a NOP if alpha is not supported.
        Parameters:
        index - the offset of the underlying array
        newAlpha - the new alpha value in range [0-255]
      • setRed

        public void setRed​(int index,
                           int newRed)
        Description copied from interface: FastPixel
        Set the red value at the specified offset
        Parameters:
        index - the offset of the underlying array
        newRed - the new red value in range [0-255]
      • setGreen

        public void setGreen​(int index,
                             int newGreen)
        Description copied from interface: FastPixel
        Set the green value at the specified offset
        Parameters:
        index - the offset of the underlying array
        newGreen - the new green value in range [0-255]
      • setBlue

        public void setBlue​(int index,
                            int newBlue)
      • getOffset

        public int getOffset​(int x,
                             int y)
        Description copied from interface: FastPixel
        Map the x and y values to the underlying one dimensional data array
        Parameters:
        x - the x coordinate
        y - the y coordinate
        Returns:
        the corresponding 1d array index
      • 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
        Overrides:
        getLuma1D in class FastPixelImpl
        Returns:
        the luma component in range [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
        Overrides:
        getRed1D in class FastPixelImpl
        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
        Overrides:
        getGreen1D in class FastPixelImpl
        Returns:
        the green 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
        Overrides:
        getBlue1D in class FastPixelImpl
        Returns:
        the red values in range [0-255]