public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic
Element.DataType.UNSIGNED_8
,
it is converted to Element.DataType.FLOAT_32
and
normalized from (0-255) to (0-1). If the incoming vector size
is less than four, a Element.F32_4(android.renderscript.RenderScript)
is created by
filling the missing vector channels with zero. This value is
then multiplied by the 4x4 color matrix as performed by
rsMatrixMultiply(), adding a Element.F32_4(android.renderscript.RenderScript)
, and then
writing it to the output Allocation
.
If the ouptut type is unsigned, the value is normalized from
(0-1) to (0-255) and converted. If the output vector size is
less than four, the unused channels are discarded.
Supported elements types are Element.U8(android.renderscript.RenderScript)
, Element.U8_2(android.renderscript.RenderScript)
, Element.U8_3(android.renderscript.RenderScript)
, Element.U8_4(android.renderscript.RenderScript)
,
Element.F32(android.renderscript.RenderScript)
, Element.F32_2(android.renderscript.RenderScript)
, Element.F32_3(android.renderscript.RenderScript)
, and Element.F32_4(android.renderscript.RenderScript)
.Script.Builder, Script.FieldBase, Script.FieldID, Script.InvokeID, Script.KernelID, Script.LaunchOptions
Modifier and Type | Method and Description |
---|---|
static ScriptIntrinsicColorMatrix |
create(RenderScript rs)
Create an intrinsic for applying a color matrix to an
allocation.
|
static ScriptIntrinsicColorMatrix |
create(RenderScript rs,
Element e)
Deprecated.
Use the single argument version as Element is now
ignored.
|
void |
forEach(Allocation ain,
Allocation aout)
Invoke the kernel and apply the matrix to each cell of input
Allocation and copy to the output Allocation . |
void |
forEach(Allocation ain,
Allocation aout,
Script.LaunchOptions opt)
Invoke the kernel and apply the matrix to each cell of input
Allocation and copy to the output Allocation . |
Script.KernelID |
getKernelID()
Get a KernelID for this intrinsic kernel.
|
void |
setAdd(Float4 f)
Set the value to be added after the color matrix has been
applied.
|
void |
setAdd(float r,
float g,
float b,
float a)
Set the value to be added after the color matrix has been
applied.
|
void |
setColorMatrix(Matrix3f m)
Set the color matrix which will be applied to each cell of the image.
|
void |
setColorMatrix(Matrix4f m)
Set the color matrix which will be applied to each cell of
the image.
|
void |
setGreyscale()
Set a color matrix to convert from RGB to luminance.
|
void |
setRGBtoYUV()
Set the matrix to convert from RGB to YUV with a direct copy of the 4th
channel.
|
void |
setYUVtoRGB()
Set the matrix to convert from YUV to RGB with a direct copy of the 4th
channel.
|
bindAllocation, createFieldID, createInvokeID, createKernelID, forEach, forEach, forEach, forEach, getVarB, getVarD, getVarF, getVarI, getVarJ, getVarV, invoke, invoke, reduce, setTimeZone, setVar, setVar, setVar, setVar, setVar, setVar, setVar, setVar
@Deprecated public static ScriptIntrinsicColorMatrix create(RenderScript rs, Element e)
rs
- The RenderScript contexte
- Element type for inputs and outputs, As of API 19,
this parameter is ignored. The Element type check is
performed in the kernel launch.public static ScriptIntrinsicColorMatrix create(RenderScript rs)
rs
- The RenderScript contextpublic void setColorMatrix(Matrix4f m)
m
- The 4x4 matrix to set.public void setColorMatrix(Matrix3f m)
m
- The 3x3 matrix to set.public void setAdd(Float4 f)
f
- The float4 value to be added.public void setAdd(float r, float g, float b, float a)
r
- The red add value.g
- The green add value.b
- The blue add value.a
- The alpha add value.public void setGreyscale()
public void setYUVtoRGB()
public void setRGBtoYUV()
public void forEach(Allocation ain, Allocation aout)
Allocation
and copy to the output Allocation
.
If the vector size of the input is less than four, the
remaining components are treated as zero for the matrix
multiply.
If the output vector size is less than four, the unused
vector components are discarded.ain
- Input allocationaout
- Output allocationpublic void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt)
Allocation
and copy to the output Allocation
.
If the vector size of the input is less than four, the
remaining components are treated as zero for the matrix
multiply.
If the output vector size is less than four, the unused
vector components are discarded.ain
- Input allocationaout
- Output allocationopt
- LaunchOptions for clippingpublic Script.KernelID getKernelID()