Package dev.brachtendorf.graphics
Class FastPixelImpl
- java.lang.Object
-
- dev.brachtendorf.graphics.FastPixelImpl
-
- All Implemented Interfaces:
FastPixel
- Direct Known Subclasses:
FastPixelByte,FastPixelInt,FastPixelSlowDefault
public abstract class FastPixelImpl extends Object implements FastPixel
- Author:
- Kilian
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanalphaTrue if the underlying image has an alpha componentprotected intalphaReplacementThresholdprotected intheightHeight of the imageprotected intreplacementAprotected intreplacementBprotected intreplacementGprotected intreplacementRprotected intwidthWidth of the image
-
Constructor Summary
Constructors Constructor Description FastPixelImpl(int width, int height)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int[][]getAlpha()Get the alpha component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetAlpha(int offset)Get the alpha value of the specified pixelprotected abstract intgetAlphaInternal(int offset)int[][]getAverageGrayscale()Get the average grayscale of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetAverageGrayscale(int index)Get the average grayscale at the specified offsetint[][]getBlue()Get the blue component of the entire image mapped to a 2d array representing the x and y coordinates of the image.intgetBlue(int offset)Get the blue value of the specified offsetint[]getBlue1D()Get the blue component of the entire image mapped to a 1d arrayprotected abstract intgetBlueInternal(int offset)int[][]getGreen()Get the green component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetGreen(int offset)Get the green value of the specified offsetint[]getGreen1D()Get the green component of the entire image mapped to a 1d arrayprotected abstract intgetGreenInternal(int offset)int[][]getLuma()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.intgetLuma(int index)Return the Y(Luma) component of the YCbCr color model for the specified offset.int[]getLuma1D()Return the Y(Luma) component of the YCbCr color model fof the entire image mapped to a 1d arrayint[][]getRed()Get the red component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetRed(int offset)Get the red value at the specified offsetint[]getRed1D()Get the red component of the entire image mapped to a 1d arrayprotected abstract intgetRedInternal(int offset)int[][]getRGB()Returns the rgb values of the entire image in an 2 d array in the default RGB color model(TYPE_INT_ARGB).booleanhasAlpha()Check if an image supports alpha valuesbooleanisReplaceOpaqueColors()Check if the pixel loader replaces opaque colors with a non opaque version.voidsetAlpha(int[][] newAlpha)Set new alpha values for the entire picturevoidsetAverageGrayscale(int[][] newGrayValue)Set the gray values of the entire image.voidsetBlue(int[][] newBlue)Set new blue values for the entire picturevoidsetGreen(int[][] newGreen)Set new green values for the entire picturevoidsetRed(int[][] newRed)Set new red values for the entire picturevoidsetReplaceOpaqueColors(int alphaThreshold, int r, int g, int b, int a)Replace all pixels values in the image which have an alpha < than the specified threshold.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.brachtendorf.graphics.FastPixel
getAlpha, getAverageGrayscale, getBlue, getCb, getCb, getCr, getCr, getGreen, getHue, getHue, getLuma, getOffset, getRed, getRGB, getRGB, getSat, getSat, getVal, getVal, setAlpha, setAlpha, setAverageGrayscale, setAverageGrayscale, setBlue, setBlue, setGreen, setGreen, setRed, setRed, setReplaceOpaqueColors, setReplaceOpaqueColors
-
-
-
-
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
-
-
Method Detail
-
isReplaceOpaqueColors
public boolean isReplaceOpaqueColors()
Description copied from interface:FastPixelCheck if the pixel loader replaces opaque colors with a non opaque version. Opaque values are replaced only on get operations. To activate this option callFastPixel.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:
isReplaceOpaqueColorsin interfaceFastPixel- 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:FastPixelReplace 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:
setReplaceOpaqueColorsin interfaceFastPixel- 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 replacementr- 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:FastPixelGet the red component of the entire image mapped to a 1d array
-
getBlue1D
public int[] getBlue1D()
Description copied from interface:FastPixelGet the blue component of the entire image mapped to a 1d array
-
getGreen1D
public int[] getGreen1D()
Description copied from interface:FastPixelGet the green component of the entire image mapped to a 1d array- Specified by:
getGreen1Din interfaceFastPixel- Returns:
- the green values in range [0-255]
-
getLuma1D
public int[] getLuma1D()
Description copied from interface:FastPixelReturn the Y(Luma) component of the YCbCr color model fof the entire image mapped to a 1d array
-
getAverageGrayscale
public int getAverageGrayscale(int index)
Description copied from interface:FastPixelGet the average grayscale at the specified offsetAverage grayscale: (R+G+B)/3
This
- Specified by:
getAverageGrayscalein interfaceFastPixel- 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:FastPixelReturn the Y(Luma) component of the YCbCr color model for the specified offset.
-
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.
-
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.
-
getGreen
public int[][] getGreen()
Description copied from interface:FastPixelGet the green component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
-
getBlue
public int[][] getBlue()
Description copied from interface:FastPixelGet the blue component of the entire image mapped to a 2d array representing the x and y coordinates of the image.
-
getAlpha
public int[][] getAlpha()
Description copied from interface:FastPixelGet the alpha component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.
-
getLuma
public int[][] getLuma()
Description copied from interface:FastPixelReturn 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.
-
getAverageGrayscale
public int[][] getAverageGrayscale()
Description copied from interface:FastPixelGet 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:
getAverageGrayscalein interfaceFastPixel- Returns:
- the grayscale values in range [0 - 255]
-
setAlpha
public void setAlpha(int[][] newAlpha)
Set new alpha values for the entire picture
-
setRed
public void setRed(int[][] newRed)
Set new red values for the entire picture
-
setGreen
public void setGreen(int[][] newGreen)
Set new green values for the entire picture
-
setBlue
public void setBlue(int[][] newBlue)
Set new blue values for the entire picture
-
setAverageGrayscale
public void setAverageGrayscale(int[][] newGrayValue)
Description copied from interface:FastPixelSet 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:
setAverageGrayscalein interfaceFastPixel- Parameters:
newGrayValue- to set the pixels to range [0 - 255]
-
getRed
public final int getRed(int offset)
Description copied from interface:FastPixelGet the red value at the specified offset
-
getGreen
public final int getGreen(int offset)
Description copied from interface:FastPixelGet the green value of the specified offset
-
getBlue
public final int getBlue(int offset)
Description copied from interface:FastPixelGet the blue value of the specified offset
-
getAlpha
public final int getAlpha(int offset)
Description copied from interface:FastPixelGet the alpha value of the specified pixel
-
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)
-
-