Class Compositor
java.lang.Object
uk.ac.starlink.ttools.plot2.paper.Compositor
- Direct Known Subclasses:
Compositor.BoostCompositor
Represents an algorithm for combining multiple RGBA values to produce
a single RGBA value. The
createBuffer(int)
method produces a buffer
containing a vector of pixels for which the compositing operation
can be performed on each element.
In general RGB values are not pre-multiplied by alpha as used by this class.
- Since:
- 12 Feb 2013
- Author:
- Mark Taylor
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Compositor with boosted saturation.static interface
Buffer of pixels on which compositing operations can be performed. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Compositor
Implementation which adds colours until the alpha is saturated and then makes no further updates to colour. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float
byteToFloat
(int i) Maps an integer in the range 0-255 to a float in the range 0-1.abstract Compositor.Buffer
createBuffer
(int count) Creates a buffer on which compositing operations can be performed.static int
floatToByte
(float f) Maps a float in the range 0-1 to an int in the range 0-255.abstract float
scaleAlpha
(float alpha) Adjusts an alpha value in accordance with this compositor's policy.static int
srcOverOpaque
(int sRgba, int dRgb) Returns the result of compositing a possibly transparent source pixel over an opaque destination pixel.
-
Field Details
-
SATURATION
Implementation which adds colours until the alpha is saturated and then makes no further updates to colour.
-
-
Constructor Details
-
Compositor
public Compositor()
-
-
Method Details
-
scaleAlpha
public abstract float scaleAlpha(float alpha) Adjusts an alpha value in accordance with this compositor's policy. It takes an alpha value in the range 0-1 and maps it into the range to be used for output from this compositor.- Parameters:
alpha
- input alpha in range 0-1- Returns:
- adjusted alpha, also in range 0-1
-
createBuffer
Creates a buffer on which compositing operations can be performed.- Parameters:
count
- number of pixel elements in buffer- Returns:
- new buffer
-
byteToFloat
public static float byteToFloat(int i) Maps an integer in the range 0-255 to a float in the range 0-1. Bits more significant than the first 8 are ignored.- Parameters:
i
- integer value- Returns:
- float in range 0-1
-
floatToByte
public static int floatToByte(float f) Maps a float in the range 0-1 to an int in the range 0-255.- Parameters:
f
- float in range 0-1- Returns:
- int in range 0-255
-
srcOverOpaque
public static int srcOverOpaque(int sRgba, int dRgb) Returns the result of compositing a possibly transparent source pixel over an opaque destination pixel.- Parameters:
sRgba
- RGBA for source pixeldRgb
- RGB for opaque destination pixel- Returns:
- RGBA for composition result
-