RenderScript Conversion Functions
Stay organized with collections
Save and categorize content based on your preferences.
Overview
The functions below convert from a numerical vector type to another, or from one color representation to another.
Summary
| Functions | |
|---|---|
| convert | Convert numerical vectors |
| rsPackColorTo8888 | Create a uchar4 RGBA from floats |
| rsUnpackColor8888 | Create a float4 RGBA from uchar4 |
| rsYuvToRGBA | Convert a YUV value to RGBA |
Functions
convert : Convert numerical vectors
Converts a vector from one numerical type to another. The conversion are done entry per entry.
E.g. calling a = convert_short3(b); is equivalent to doing
a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;.
Converting floating point values to integer types truncates.
Converting numbers too large to fit the destination type yields undefined results. For example, converting a float that contains 1.0e18 to a short is undefined. Use clamp() to avoid this.
rsPackColorTo8888 : Create a uchar4 RGBA from floats
Parameters
| r | Red component. |
|---|---|
| g | Green component. |
| b | Blue component. |
| a | Alpha component. |
| color | Vector of 3 or 4 floats containing the R, G, B, and A values. |
Packs three or four floating point RGBA values into a uchar4.
The input values are typically between 0.0f and 1.0f inclusive. For input values outside of this range, the resulting outputs will be clamped to be between 0 and 255. As this clamping may be done after the input is multiplied by 255.f and converted to an integer, input numbers greater than INT_MAX/255.f or less than INT_MIN/255.f result in undefined behavior.
If the alpha component is not specified, it is assumed to be 1.0, i.e. the result will have an alpha set to 255.
rsUnpackColor8888 : Create a float4 RGBA from uchar4
Unpacks a uchar4 color to float4. The resulting floats will be between 0.0 and 1.0 inclusive.
rsYuvToRGBA : Convert a YUV value to RGBA
Parameters
| y | Luminance component. |
|---|---|
| u | U chrominance component. |
| v | V chrominance component. |
Converts a color from a YUV representation to RGBA.
We currently don't provide a function to do the reverse conversion.