Class ContourPlot.Pixel
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.Pixel
-
- All Implemented Interfaces:
ContourPlot.PixelBase
- Enclosing class:
- ContourPlot
public class ContourPlot.Pixel extends java.lang.Object implements ContourPlot.PixelBase
Pixel class for retrieving a value from anContourPlot.Img
. A Pixel object stores a position and can be used to get and set values of an Img. It is NOT the value and changing its position will not change the image, instead it will reference a different value of the image as the pixel object is a pointer to a value in the Img's data array.The Pixel class also provides a set of static methods for color decomposition and recombination from color channels like
argb(int, int, int, int)
ora(int)
,r(int)
,g(int)
,b(int)
.- Since:
- 1.0
- Author:
- hageldave
-
-
Field Summary
Fields Modifier and Type Field Description private ContourPlot.Img
img
Img this pixel belongs toprivate int
index
index of the value this pixel references
-
Constructor Summary
Constructors Constructor Description Pixel(ContourPlot.Img img, int index)
Creates a new Pixel object referencing the value of specified Img at specified index.Pixel(ContourPlot.Img img, int x, int y)
Creates a new Pixel object referencing the value of specified Img at specified position.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
a()
int
a(int color)
double
a_asDouble()
Returns the alpha value of this pixel at its current position.double
a_normalized(int color)
int
argb(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value.int
argb_bounded(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value.int
argb_fast(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value.int
argb_fromNormalized(double a, double r, double g, double b)
Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value.int
b()
int
b(int color)
double
b_asDouble()
Returns the blue value of this pixel at its current position.double
b_normalized(int color)
int
g()
int
g(int color)
double
g_asDouble()
Returns the green value of this pixel at its current position.double
g_normalized(int color)
int
getGrey(int redWeight, int greenWeight, int blueWeight)
Calculates the grey value of this pixel using specified weights.int
getGrey(int color, int redWeight, int greenWeight, int blueWeight)
Calculates a grey value from an RGB or ARGB value using specified weights for each R,G and B channel.int
getIndex()
Returns this pixel's index.int
getLuminance()
int
getLuminance(int color)
ContourPlot.Img
getSource()
Returns the underlying image of this pixel (the image referenced by this pixel)int
getValue()
Gets the value of the Img at the position currently referenced by this Pixel.int
getX()
int
getY()
int
r()
int
r(int color)
double
r_asDouble()
Returns the red value of this pixel at its current position.double
r_normalized(int color)
int
rgb(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque).int
rgb_bounded(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque).int
rgb_fast(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque).int
rgb_fromNormalized(double r, double g, double b)
Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value with alpha=255 (opaque).ContourPlot.Pixel
setA(int a)
Sets alpha channel value of this Pixel.ContourPlot.PixelBase
setA_fromDouble(double a)
Sets the alpha value of this pixel at its current position with 0.0 as fully transparent and 1.0 as fully opaque.void
setARGB(int a, int r, int g, int b)
Sets an ARGB value at the position currently referenced by this Pixel.ContourPlot.Pixel
setARGB_fromDouble(double a, double r, double g, double b)
Sets an ARGB value at the position currently referenced by this Pixel.ContourPlot.Pixel
setB(int b)
Sets blue channel value of this Pixel.ContourPlot.PixelBase
setB_fromDouble(double b)
Sets the blue value of this pixel at its current position with 0.0 as no blue contribution and 1.0 as full blue contribution.ContourPlot.Pixel
setG(int g)
Sets green channel value of this Pixel.ContourPlot.PixelBase
setG_fromDouble(double g)
Sets the green value of this pixel at its current position with 0.0 as no green contribution and 1.0 as full green contribution.ContourPlot.Pixel
setIndex(int index)
Sets the index of the Img value this Pixel references.ContourPlot.Pixel
setPosition(int x, int y)
Sets the position of the Img value this Pixel references.ContourPlot.Pixel
setR(int r)
Sets red channel value of this Pixel.ContourPlot.PixelBase
setR_fromDouble(double r)
Sets the red value of this pixel at its current position with 0.0 as no red contribution and 1.0 as full red contribution.void
setRGB(int r, int g, int b)
Sets an opaque RGB value at the position currently referenced by this Pixel.ContourPlot.Pixel
setRGB_fromDouble(double r, double g, double b)
Sets an opaque RGB value at the position currently referenced by this Pixel.ContourPlot.Pixel
setRGB_fromDouble_preserveAlpha(double r, double g, double b)
Sets an RGB value at the position currently referenced by this Pixel.void
setRGB_preserveAlpha(int r, int g, int b)
Sets an RGB value at the position currently referenced by this Pixel.ContourPlot.Pixel
setValue(int pixelValue)
Sets the value of the Img at the position currently referenced by this Pixel.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.PixelBase
asString, getXnormalized, getYnormalized
-
-
-
-
Field Detail
-
img
private final ContourPlot.Img img
Img this pixel belongs to- Since:
- 1.0
-
index
private int index
index of the value this pixel references- Since:
- 1.0
-
-
Constructor Detail
-
Pixel
public Pixel(ContourPlot.Img img, int index)
Creates a new Pixel object referencing the value of specified Img at specified index.No bounds checks are performed for index.
- Parameters:
img
- the Img this pixel corresponds toindex
- of the value in the images data array- Since:
- 1.0
- See Also:
Pixel(Img, int, int)
,ContourPlot.Img.getPixel()
,ContourPlot.Img.getPixel(int, int)
-
Pixel
public Pixel(ContourPlot.Img img, int x, int y)
Creates a new Pixel object referencing the value of specified Img at specified position.No bounds checks are performed for x and y
- Parameters:
img
- the Img this pixel corresponds tox
- coordinatey
- coordinate- Since:
- 1.0
- See Also:
Pixel(Img, int)
,ContourPlot.Img.getPixel()
,ContourPlot.Img.getPixel(int, int)
-
-
Method Detail
-
getSource
public ContourPlot.Img getSource()
Description copied from interface:ContourPlot.PixelBase
Returns the underlying image of this pixel (the image referenced by this pixel)- Specified by:
getSource
in interfaceContourPlot.PixelBase
- Returns:
- the Img this Pixel belongs to.
- Since:
- 1.0
- See Also:
ContourPlot.ImgBase
-
setIndex
public ContourPlot.Pixel setIndex(int index)
Sets the index of the Img value this Pixel references. No bounds checks are performed.- Specified by:
setIndex
in interfaceContourPlot.PixelBase
- Parameters:
index
- corresponding to the position of the image's data array.- Returns:
- this pixel for chaining
- Since:
- 1.0
- See Also:
setPosition(int, int)
,getIndex()
-
setPosition
public ContourPlot.Pixel setPosition(int x, int y)
Sets the position of the Img value this Pixel references. No bounds checks are performed.- Specified by:
setPosition
in interfaceContourPlot.PixelBase
- Parameters:
x
- coordinatey
- coordinate- Returns:
- this pixel for chaining
- Since:
- 1.0
- See Also:
setIndex(int)
,getX()
,getY()
-
getIndex
public int getIndex()
Description copied from interface:ContourPlot.PixelBase
Returns this pixel's index. The index relates to the pixels's position in the following way:
index = y * width + x y = index / width x = index % width
- Specified by:
getIndex
in interfaceContourPlot.PixelBase
- Returns:
- the index of the Img value this Pixel references.
- Since:
- 1.0
- See Also:
ContourPlot.PixelBase.setIndex(int)
,ContourPlot.PixelBase.getX()
,ContourPlot.PixelBase.getY()
-
getX
public int getX()
- Specified by:
getX
in interfaceContourPlot.PixelBase
- Returns:
- the x coordinate of the position in the Img this Pixel references.
- Since:
- 1.0
- See Also:
getY()
,getIndex()
,setPosition(int, int)
-
getY
public int getY()
- Specified by:
getY
in interfaceContourPlot.PixelBase
- Returns:
- the y coordinate of the position in the Img this Pixel references.
- Since:
- 1.0
- See Also:
getX()
,getIndex()
,setPosition(int, int)
-
setValue
public ContourPlot.Pixel setValue(int pixelValue)
Sets the value of the Img at the position currently referenced by this Pixel.If the position of this pixel is not in bounds of the Img the value for a different position may be set or an ArrayIndexOutOfBoundsException may be thrown.
- Parameters:
pixelValue
- to be set e.g. 0xff0000ff for blue.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
setARGB(int, int, int, int)
,setRGB(int, int, int)
,getValue()
,ContourPlot.Img.setValue(int, int, int)
-
getValue
public int getValue()
Gets the value of the Img at the position currently referenced by this Pixel.If the position of this pixel is not in bounds of the Img the value for a different position may be returned or an ArrayIndexOutOfBoundsException may be thrown.
- Returns:
- the value of the Img currently referenced by this Pixel.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
a()
,r()
,g()
,b()
,setValue(int)
,ContourPlot.Img.getValue(int, int)
-
a
public int a()
- Returns:
- the alpha component of the value currently referenced by this Pixel. It is assumed that the value is an ARGB value with 8bits per color channel, so this will return a value in [0..255].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
r()
,g()
,b()
,setRGB(int, int, int)
,setARGB(int, int, int, int)
,getValue()
-
r
public int r()
- Returns:
- the red component of the value currently referenced by this Pixel. It is assumed that the value is an ARGB value with 8bits per color channel, so this will return a value in [0..255].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
a()
,g()
,b()
,setRGB(int, int, int)
,setARGB(int, int, int, int)
,getValue()
-
g
public int g()
- Returns:
- the green component of the value currently referenced by this Pixel. It is assumed that the value is an ARGB value with 8bits per color channel, so this will return a value in [0..255].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
a()
,r()
,b()
,setRGB(int, int, int)
,setARGB(int, int, int, int)
,getValue()
-
b
public int b()
- Returns:
- the blue component of the value currently referenced by this Pixel. It is assumed that the value is an ARGB value with 8bits per color channel, so this will return a value in [0..255].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
a()
,r()
,g()
,setRGB(int, int, int)
,setARGB(int, int, int, int)
,getValue()
-
a_asDouble
public double a_asDouble()
Description copied from interface:ContourPlot.PixelBase
Returns the alpha value of this pixel at its current position. If the underlying image does not support alpha, 1.0 is returned.- Specified by:
a_asDouble
in interfaceContourPlot.PixelBase
- Returns:
- the normalized alpha component of the value currently referenced by this Pixel. This will return a value in [0.0 .. 1.0].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
a()
,r_asDouble()
,g_asDouble()
,b_asDouble()
-
r_asDouble
public double r_asDouble()
Description copied from interface:ContourPlot.PixelBase
Returns the red value of this pixel at its current position.- Specified by:
r_asDouble
in interfaceContourPlot.PixelBase
- Returns:
- the normalized red component of the value currently referenced by this Pixel. This will return a value in [0.0 .. 1.0].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
r()
,a_asDouble()
,g_asDouble()
,b_asDouble()
-
g_asDouble
public double g_asDouble()
Description copied from interface:ContourPlot.PixelBase
Returns the green value of this pixel at its current position.- Specified by:
g_asDouble
in interfaceContourPlot.PixelBase
- Returns:
- the normalized green component of the value currently referenced by this Pixel. This will return a value in [0.0 .. 1.0].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
g()
,a_asDouble()
,r_asDouble()
,b_asDouble()
-
b_asDouble
public double b_asDouble()
Description copied from interface:ContourPlot.PixelBase
Returns the blue value of this pixel at its current position.- Specified by:
b_asDouble
in interfaceContourPlot.PixelBase
- Returns:
- the normalized blue component of the value currently referenced by this Pixel. This will return a value in [0.0 .. 1.0].
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
b()
,a_asDouble()
,r_asDouble()
,g_asDouble()
-
setARGB
public void setARGB(int a, int r, int g, int b)
Sets an ARGB value at the position currently referenced by this Pixel. Each channel value is assumed to be 8bit and otherwise truncated.- Parameters:
a
- alphar
- redg
- greenb
- blue- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
setRGB(int, int, int)
,setRGB_preserveAlpha(int, int, int)
,argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,setValue(int)
-
setRGB
public void setRGB(int r, int g, int b)
Sets an opaque RGB value at the position currently referenced by this Pixel. Each channel value is assumed to be 8bit and otherwise truncated.- Parameters:
r
- redg
- greenb
- blue- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.0
- See Also:
setARGB(int, int, int, int)
,setRGB_preserveAlpha(int, int, int)
,argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,setValue(int)
-
setRGB_preserveAlpha
public void setRGB_preserveAlpha(int r, int g, int b)
Sets an RGB value at the position currently referenced by this Pixel. The present alpha value will not be altered by this operation. Each channel value is assumed to be 8bit and otherwise truncated.- Parameters:
r
- redg
- greenb
- blue- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setRGB_fromDouble_preserveAlpha(double, double, double)
-
setARGB_fromDouble
public ContourPlot.Pixel setARGB_fromDouble(double a, double r, double g, double b)
Sets an ARGB value at the position currently referenced by this Pixel.
Each channel value is assumed to be within [0.0 .. 1.0]. Channel values outside these bounds will be clamped to them.- Specified by:
setARGB_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
a
- normalized alphar
- normalized redg
- normalized greenb
- normalized blue- Returns:
- this pixel for chaining.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setRGB_fromDouble(double, double, double)
,setRGB_fromDouble_preserveAlpha(double, double, double)
,setARGB(int, int, int, int)
,a_asDouble()
,r_asDouble()
,g_asDouble()
,b_asDouble()
-
setRGB_fromDouble
public ContourPlot.Pixel setRGB_fromDouble(double r, double g, double b)
Sets an opaque RGB value at the position currently referenced by this Pixel.
Each channel value is assumed to be within [0.0 .. 1.0]. Channel values outside these bounds will be clamped to them.- Specified by:
setRGB_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
r
- normalized redg
- normalized greenb
- normalized blue- Returns:
- this pixel for chaining.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setARGB_fromDouble(double, double, double, double)
,setRGB_fromDouble_preserveAlpha(double, double, double)
,setRGB(int, int, int)
,a_asDouble()
,r_asDouble()
,g_asDouble()
,b_asDouble()
-
setRGB_fromDouble_preserveAlpha
public ContourPlot.Pixel setRGB_fromDouble_preserveAlpha(double r, double g, double b)
Sets an RGB value at the position currently referenced by this Pixel. The present alpha value will not be altered by this operation.
Each channel value is assumed to be within [0.0 .. 1.0]. Channel values outside these bounds will be clamped to them.- Specified by:
setRGB_fromDouble_preserveAlpha
in interfaceContourPlot.PixelBase
- Parameters:
r
- normalized redg
- normalized greenb
- normalized blue- Returns:
- this pixel for chaining.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setRGB_preserveAlpha(int, int, int)
-
setA
public ContourPlot.Pixel setA(int a)
Sets alpha channel value of this Pixel. Value will be truncated to 8bits (e.g. 0x12ff will truncate to 0xff).- Parameters:
a
- alpha value in range [0..255]- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setARGB(int a, int r, int g, int b)
-
setR
public ContourPlot.Pixel setR(int r)
Sets red channel value of this Pixel. Value will be truncated to 8bits (e.g. 0x12ff will truncate to 0xff).- Parameters:
r
- red value in range [0..255]- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setARGB(int a, int r, int g, int b)
,setRGB(int r, int g, int b)
-
setG
public ContourPlot.Pixel setG(int g)
Sets green channel value of this Pixel. Value will be truncated to 8bits (e.g. 0x12ff will truncate to 0xff).- Parameters:
g
- green value in range [0..255]- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setARGB(int a, int r, int g, int b)
,setRGB(int r, int g, int b)
-
setB
public ContourPlot.Pixel setB(int b)
Sets blue channel value of this Pixel. Value will be truncated to 8bits (e.g. 0x12ff will truncate to 0xff).- Parameters:
b
- blue value in range [0..255]- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
setARGB(int a, int r, int g, int b)
,setRGB(int r, int g, int b)
-
setA_fromDouble
public ContourPlot.PixelBase setA_fromDouble(double a)
Description copied from interface:ContourPlot.PixelBase
Sets the alpha value of this pixel at its current position with 0.0 as fully transparent and 1.0 as fully opaque. If the underlying image does not support alpha, this call imediately returns without modifying the image.- Specified by:
setA_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
a
- the alpha value. May exceed [0,1] range depending on implementation.- Returns:
- this pixel for chaining.
- See Also:
ContourPlot.PixelBase.a_asDouble()
,ContourPlot.PixelBase.setR_fromDouble(double)
,ContourPlot.PixelBase.setG_fromDouble(double)
,ContourPlot.PixelBase.setB_fromDouble(double)
,ContourPlot.PixelBase.setARGB_fromDouble(double, double, double, double)
-
setR_fromDouble
public ContourPlot.PixelBase setR_fromDouble(double r)
Description copied from interface:ContourPlot.PixelBase
Sets the red value of this pixel at its current position with 0.0 as no red contribution and 1.0 as full red contribution.- Specified by:
setR_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
r
- the red value. May exceed [0,1] range depending on implementation.- Returns:
- this pixel for chaining.
- See Also:
ContourPlot.PixelBase.r_asDouble()
,ContourPlot.PixelBase.setA_fromDouble(double)
,ContourPlot.PixelBase.setG_fromDouble(double)
,ContourPlot.PixelBase.setB_fromDouble(double)
,ContourPlot.PixelBase.setARGB_fromDouble(double, double, double, double)
-
setG_fromDouble
public ContourPlot.PixelBase setG_fromDouble(double g)
Description copied from interface:ContourPlot.PixelBase
Sets the green value of this pixel at its current position with 0.0 as no green contribution and 1.0 as full green contribution.- Specified by:
setG_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
g
- the green value. May exceed [0,1] range depending on implementation.- Returns:
- this pixel for chaining.
- See Also:
ContourPlot.PixelBase.g_asDouble()
,ContourPlot.PixelBase.setA_fromDouble(double)
,ContourPlot.PixelBase.setR_fromDouble(double)
,ContourPlot.PixelBase.setB_fromDouble(double)
,ContourPlot.PixelBase.setARGB_fromDouble(double, double, double, double)
-
setB_fromDouble
public ContourPlot.PixelBase setB_fromDouble(double b)
Description copied from interface:ContourPlot.PixelBase
Sets the blue value of this pixel at its current position with 0.0 as no blue contribution and 1.0 as full blue contribution.- Specified by:
setB_fromDouble
in interfaceContourPlot.PixelBase
- Parameters:
b
- the blue value. May exceed [0,1] range depending on implementation.- Returns:
- this pixel for chaining.
- See Also:
ContourPlot.PixelBase.b_asDouble()
,ContourPlot.PixelBase.setA_fromDouble(double)
,ContourPlot.PixelBase.setR_fromDouble(double)
,ContourPlot.PixelBase.setG_fromDouble(double)
,ContourPlot.PixelBase.setARGB_fromDouble(double, double, double, double)
-
getLuminance
public int getLuminance()
- Returns:
- 8bit luminance value of this pixel.
Using weights r=0.2126 g=0.7152 b=0.0722 - Throws:
java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
getGrey(int, int, int)
,getLuminance(int)
-
getGrey
public int getGrey(int redWeight, int greenWeight, int blueWeight)
Calculates the grey value of this pixel using specified weights.- Parameters:
redWeight
- weight for red channelgreenWeight
- weight for green channelblueWeight
- weight for blue channel- Returns:
- grey value of pixel for specified weights
- Throws:
java.lang.ArithmeticException
- divide by zero if the weights sum up to 0.java.lang.ArrayIndexOutOfBoundsException
- if this Pixel's index is not in range of the Img's data array.- Since:
- 1.2
- See Also:
getLuminance()
,getGrey(int, int, int, int)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLuminance
public final int getLuminance(int color)
- Parameters:
color
- RGB(24bit) or ARGB(32bit) value- Returns:
- 8bit luminance value of given RGB value.
Using weights r=0.2126 g=0.7152 b=0.0722 - Since:
- 1.0
- See Also:
getGrey(int, int, int, int)
-
getGrey
public final int getGrey(int color, int redWeight, int greenWeight, int blueWeight)
Calculates a grey value from an RGB or ARGB value using specified weights for each R,G and B channel.Weights are integer values so normalized weights need to be converted beforehand. E.g. normalized weights (0.33, 0.62, 0.05) would be have to be converted to integer weights (33, 62, 5).
When using weights with same signs, the value is within [0..255]. When weights have mixed signs the resulting value is unbounded.
- Parameters:
color
- RGB(24bit) or ARGB(32bit) valueredWeight
- weight for red channelgreenWeight
- weight for green channelblueWeight
- weight for blue channel- Returns:
- weighted grey value (8bit) of RGB color value for non-negative weights.
- Throws:
java.lang.ArithmeticException
- divide by zero if the weights sum up to 0.- Since:
- 1.0
- See Also:
getLuminance(int)
-
rgb_bounded
public final int rgb_bounded(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque). Components are clamped to [0,255].- Parameters:
r
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,rgb(int, int, int)
,rgb_fast(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
rgb
public final int rgb(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque). Components larger than 8bit get truncated to 8bit.- Parameters:
r
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,rgb_bounded(int, int, int)
,rgb_fast(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
rgb_fast
public final int rgb_fast(int r, int g, int b)
Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque). Components larger than 8bit are NOT truncated and will result in a broken, malformed value.- Parameters:
r
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,rgb_bounded(int, int, int)
,rgb(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
rgb_fromNormalized
public final int rgb_fromNormalized(double r, double g, double b)
Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value with alpha=255 (opaque). Component values less than 0 or greater than 1 clamped to fit the range.- Parameters:
r
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.2
- See Also:
argb_fromNormalized(double, double, double, double)
,rgb(int, int, int)
,a_normalized(int)
,r_normalized(int)
,g_normalized(int)
,b_normalized(int)
-
argb_bounded
public final int argb_bounded(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value. Components are clamped to [0,255].- Parameters:
a
- alphar
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb(int, int, int, int)
,argb_fast(int, int, int, int)
,rgb_bounded(int, int, int)
,rgb(int, int, int)
,rgb_fast(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
argb
public final int argb(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value. Components larger than 8bit get truncated to 8bit.- Parameters:
a
- alphar
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb_bounded(int, int, int, int)
,argb_fast(int, int, int, int)
,rgb_bounded(int, int, int)
,rgb(int, int, int)
,rgb_fast(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
argb_fast
public final int argb_fast(int a, int r, int g, int b)
Packs 8bit ARGB color components into a single 32bit integer value. Components larger than 8bit are NOT truncated and will result in a broken, malformed value.- Parameters:
a
- alphar
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
argb(int, int, int, int)
,argb_bounded(int, int, int, int)
,rgb_bounded(int, int, int)
,rgb(int, int, int)
,rgb_fast(int, int, int)
,a(int)
,r(int)
,g(int)
,b(int)
-
argb_fromNormalized
public final int argb_fromNormalized(double a, double r, double g, double b)
Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value. Component values less than 0 or greater than 1 are clamped to fit the range.- Parameters:
a
- alphar
- redg
- greenb
- blue- Returns:
- packed ARGB value
- Since:
- 1.2
- See Also:
rgb_fromNormalized(double, double, double)
,argb(int, int, int, int)
,a_normalized(int)
,r_normalized(int)
,g_normalized(int)
,b_normalized(int)
-
b
public final int b(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- blue component(8bit) of specified color.
- Since:
- 1.0
- See Also:
a(int)
,r(int)
,g(int)
,argb(int, int, int, int)
,rgb(int, int, int)
-
g
public final int g(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- green component(8bit) of specified color.
- Since:
- 1.0
- See Also:
a(int)
,r(int)
,b(int)
,argb(int, int, int, int)
,rgb(int, int, int)
-
r
public final int r(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- red component(8bit) of specified color.
- Since:
- 1.0
- See Also:
a(int)
,g(int)
,b(int)
,argb(int, int, int, int)
,rgb(int, int, int)
-
a
public final int a(int color)
- Parameters:
color
- ARGB(32bit) value- Returns:
- alpha component(8bit) of specified color.
- Since:
- 1.0
- See Also:
r(int)
,g(int)
,b(int)
,argb(int, int, int, int)
,rgb(int, int, int)
-
b_normalized
public final double b_normalized(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized blue component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
b()
,r_normalized(int)
,g_normalized(int)
,a_normalized(int)
-
g_normalized
public final double g_normalized(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized green component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
g()
,r_normalized(int)
,b_normalized(int)
,a_normalized(int)
-
r_normalized
public final double r_normalized(int color)
- Parameters:
color
- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized red component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
r()
,b_normalized(int)
,g_normalized(int)
,a_normalized(int)
-
a_normalized
public final double a_normalized(int color)
- Parameters:
color
- ARGB(32bit) value- Returns:
- normalized alpha component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
a()
,r_normalized(int)
,g_normalized(int)
,a_normalized(int)
-
-