Package com.jhlabs.image
Class PixelUtils
- java.lang.Object
-
- com.jhlabs.image.PixelUtils
-
public class PixelUtils extends java.lang.ObjectSome more useful math functions for image processing. These are becoming obsolete as we move to Java2D. Use MiscComposite instead.
-
-
Field Summary
Fields Modifier and Type Field Description static intADDstatic intALPHAstatic intALPHA_TO_GRAYstatic intAVERAGEstatic intCLEARstatic intCOLORstatic intDIFFERENCEstatic intDISSOLVEstatic intDST_INstatic intEXCHANGEstatic intHUEstatic intMAXstatic intMINstatic intMULTIPLYstatic intNORMALstatic intOVERLAYstatic intREPLACEstatic intSATURATIONstatic intSCREENstatic intSUBTRACTstatic intVALUE
-
Constructor Summary
Constructors Constructor Description PixelUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbrightness(int rgb)Return the brightness.static intclamp(int c)Clamp a value to the range 0..255.static intcombinePixels(int rgb1, int rgb2, int op)Return rgb1 painted onto rgb2.static intcombinePixels(int rgb1, int rgb2, int op, int extraAlpha)Return rgb1 painted onto rgb2.static intcombinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask)Return rgb1 painted onto rgb2.static intinterpolate(int v1, int v2, float f)Interpolate between two values.static booleannearColors(int rgb1, int rgb2, int tolerance)Return true of the colors are near each other.
-
-
-
Field Detail
-
REPLACE
public static final int REPLACE
- See Also:
- Constant Field Values
-
NORMAL
public static final int NORMAL
- See Also:
- Constant Field Values
-
MIN
public static final int MIN
- See Also:
- Constant Field Values
-
MAX
public static final int MAX
- See Also:
- Constant Field Values
-
ADD
public static final int ADD
- See Also:
- Constant Field Values
-
SUBTRACT
public static final int SUBTRACT
- See Also:
- Constant Field Values
-
DIFFERENCE
public static final int DIFFERENCE
- See Also:
- Constant Field Values
-
MULTIPLY
public static final int MULTIPLY
- See Also:
- Constant Field Values
-
HUE
public static final int HUE
- See Also:
- Constant Field Values
-
SATURATION
public static final int SATURATION
- See Also:
- Constant Field Values
-
VALUE
public static final int VALUE
- See Also:
- Constant Field Values
-
COLOR
public static final int COLOR
- See Also:
- Constant Field Values
-
SCREEN
public static final int SCREEN
- See Also:
- Constant Field Values
-
AVERAGE
public static final int AVERAGE
- See Also:
- Constant Field Values
-
OVERLAY
public static final int OVERLAY
- See Also:
- Constant Field Values
-
CLEAR
public static final int CLEAR
- See Also:
- Constant Field Values
-
EXCHANGE
public static final int EXCHANGE
- See Also:
- Constant Field Values
-
DISSOLVE
public static final int DISSOLVE
- See Also:
- Constant Field Values
-
DST_IN
public static final int DST_IN
- See Also:
- Constant Field Values
-
ALPHA
public static final int ALPHA
- See Also:
- Constant Field Values
-
ALPHA_TO_GRAY
public static final int ALPHA_TO_GRAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
clamp
public static int clamp(int c)
Clamp a value to the range 0..255.- Parameters:
c- The value to be clamped- Returns:
- the clamped value.
-
interpolate
public static int interpolate(int v1, int v2, float f)Interpolate between two values.- Parameters:
v1- The first valuev2- The second valuef- The amount of interpolation, typically between 0 and 1.- Returns:
- the interpolated value, clamped to 0..255.
-
brightness
public static int brightness(int rgb)
Return the brightness.- Parameters:
rgb- RFB encoded.- Returns:
- The average of the R, G and B.
-
nearColors
public static boolean nearColors(int rgb1, int rgb2, int tolerance)Return true of the colors are near each other.- Parameters:
rgb1- The first colorrgb2- The second colortolerance- The maximum difference for r, g, and b between the two values.- Returns:
- True if the colors are near each other.
-
combinePixels
public static int combinePixels(int rgb1, int rgb2, int op)Return rgb1 painted onto rgb2.- Parameters:
rgb1- The first pixel.rgb2- The second pixel.op- The operation as defined by this class.- Returns:
- the combined pixel.
-
combinePixels
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask)Return rgb1 painted onto rgb2.- Parameters:
rgb1- The first pixel.rgb2- The second pixel.op- The operation as defined by this class.extraAlpha- The extra alpha.channelMask- The channel mask.- Returns:
- the combined pixel.
-
combinePixels
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha)Return rgb1 painted onto rgb2.- Parameters:
rgb1- The first pixel.rgb2- The second pixel.op- The operation as defined by this class.extraAlpha- The extra alpha.- Returns:
- the combined pixel.
-
-