Package dev.brachtendorf.graphics
Class FastPixelSlowDefault
- java.lang.Object
-
- dev.brachtendorf.graphics.FastPixelImpl
-
- dev.brachtendorf.graphics.FastPixelSlowDefault
-
- All Implemented Interfaces:
FastPixel
public class FastPixelSlowDefault extends FastPixelImpl
A fallback instance of fast pixel using a cached getRGB instance instead of the underlying buffer due to the fact that no other implementation currently is available. This allows to support all image formats but individual implementations should be replaced by faster alternatives in the future.- Since:
- 1.5.2 com.github.kilianB
- Author:
- Kilian
-
-
Field Summary
-
Fields inherited from class dev.brachtendorf.graphics.FastPixelImpl
alpha, alphaReplacementThreshold, height, replacementA, replacementB, replacementG, replacementR, width
-
-
Constructor Summary
Constructors Constructor Description FastPixelSlowDefault(BufferedImage bImage)Constructs a fast pixel object with the underlying buffered image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAlphaInternal(int index)intgetBlueInternal(int index)intgetGreenInternal(int index)intgetOffset(int x, int y)Map the x and y values to the underlying one dimensional data arrayintgetRedInternal(int index)int[][]getRGB()Returns the rgb values of the entire image in an 2 d array in the default RGB color model(TYPE_INT_ARGB).intgetRGB(int index)voidsetAlpha(int[][] newAlpha)Set new alpha values for the entire picturevoidsetAlpha(int index, int newAlpha)Set the alpha value.voidsetAverageGrayscale(int[][] newGrayValue)Set the gray values of the entire image.voidsetBlue(int[][] newBlue)Set new blue values for the entire picturevoidsetBlue(int index, int newBlue)voidsetGreen(int[][] newGreen)Set new green values for the entire picturevoidsetGreen(int index, int newGreen)Set the green value at the specified offsetvoidsetRed(int[][] newRed)Set new red values for the entire picturevoidsetRed(int index, int newRed)Set the red value at the specified offset-
Methods inherited from class dev.brachtendorf.graphics.FastPixelImpl
getAlpha, getAlpha, getAverageGrayscale, getAverageGrayscale, getBlue, getBlue, getBlue1D, getGreen, getGreen, getGreen1D, getLuma, getLuma, getLuma1D, getRed, getRed, getRed1D, hasAlpha, isReplaceOpaqueColors, setReplaceOpaqueColors
-
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, getRed, getRGB, getSat, getSat, getVal, getVal, setAlpha, setAverageGrayscale, setAverageGrayscale, setBlue, setGreen, setRed, setReplaceOpaqueColors, setReplaceOpaqueColors
-
-
-
-
Constructor Detail
-
FastPixelSlowDefault
public FastPixelSlowDefault(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()
Description copied from class:FastPixelImplReturns 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:
getRGBin interfaceFastPixel- Overrides:
getRGBin classFastPixelImpl- Returns:
- a 2d integer array containing the argb values of the image
-
getAlphaInternal
public int getAlphaInternal(int index)
- Specified by:
getAlphaInternalin classFastPixelImpl
-
setAlpha
public void setAlpha(int index, int newAlpha)Description copied from interface:FastPixelSet the alpha value. This method is a NOP if alpha is not supported.- Parameters:
index- the offset of the underlying arraynewAlpha- the new alpha value in range [0-255]
-
setAlpha
public void setAlpha(int[][] newAlpha)
Description copied from class:FastPixelImplSet new alpha values for the entire picture- Specified by:
setAlphain interfaceFastPixel- Overrides:
setAlphain classFastPixelImpl- Parameters:
newAlpha- red values in range [0-255]
-
getRedInternal
public int getRedInternal(int index)
- Specified by:
getRedInternalin classFastPixelImpl
-
setRed
public void setRed(int index, int newRed)Description copied from interface:FastPixelSet the red value at the specified offset- Parameters:
index- the offset of the underlying arraynewRed- the new red value in range [0-255]
-
setRed
public void setRed(int[][] newRed)
Description copied from class:FastPixelImplSet new red values for the entire picture- Specified by:
setRedin interfaceFastPixel- Overrides:
setRedin classFastPixelImpl- Parameters:
newRed- red values in range [0-255]
-
getGreenInternal
public int getGreenInternal(int index)
- Specified by:
getGreenInternalin classFastPixelImpl
-
setGreen
public void setGreen(int index, int newGreen)Description copied from interface:FastPixelSet the green value at the specified offset- Parameters:
index- the offset of the underlying arraynewGreen- the new green value in range [0-255]
-
setGreen
public void setGreen(int[][] newGreen)
Description copied from class:FastPixelImplSet new green values for the entire picture- Specified by:
setGreenin interfaceFastPixel- Overrides:
setGreenin classFastPixelImpl- Parameters:
newGreen- red values in range [0-255]
-
getBlueInternal
public int getBlueInternal(int index)
- Specified by:
getBlueInternalin classFastPixelImpl
-
setBlue
public void setBlue(int index, int newBlue)
-
setBlue
public void setBlue(int[][] newBlue)
Description copied from class:FastPixelImplSet new blue values for the entire picture- Specified by:
setBluein interfaceFastPixel- Overrides:
setBluein classFastPixelImpl- Parameters:
newBlue- red values in range [0-255]
-
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- Overrides:
setAverageGrayscalein classFastPixelImpl- Parameters:
newGrayValue- to set the pixels to range [0 - 255]
-
getOffset
public int getOffset(int x, int y)Description copied from interface:FastPixelMap the x and y values to the underlying one dimensional data array- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the corresponding 1d array index
-
-