RenderScript 转换函数

概览

以下函数将数值矢量类型转换为另一种类型,或将一种颜色表示法转换为另一种表示法。

摘要

函数
convert 转换数值矢量
rsPackColorTo8888 从 float 创建 uchar4 RGBA
rsUnpackColor8888 从 uchar4 创建 float4 RGBA
rsYuvToRGBA 将 YUV 值转换为 RGBA

函数

convert :转换数值矢量

char2 convert_char2(char2 v);
char2 convert_char2(double2 v); 添加于 API level 21
char2 convert_char2(float2 v);
char2 convert_char2(half2 v); 添加于 API level 24
char2 convert_char2(int2 v);
char2 convert_char2(long2 v); 添加于 API level 21
char2 convert_char2(short2 v);
char2 convert_char2(uchar2 v);
char2 convert_char2(uint2 v);
char2 convert_char2(ulong2 v); 添加于 API level 21
char2 convert_char2(ushort2 v);
char3 convert_char3(char3 v);
char3 convert_char3(double3 v); 添加于 API level 21
char3 convert_char3(float3 v);
char3 convert_char3(half3 v); 添加于 API level 24
char3 convert_char3(int3 v);
char3 convert_char3(long3 v); 添加于 API level 21
char3 convert_char3(short3 v);
char3 convert_char3(uchar3 v);
char3 convert_char3(uint3 v);
char3 convert_char3(ulong3 v); 添加于 API level 21
char3 convert_char3(ushort3 v);
char4 convert_char4(char4 v);
char4 convert_char4(double4 v); 添加于 API level 21
char4 convert_char4(float4 v);
char4 convert_char4(half4 v); 添加于 API level 24
char4 convert_char4(int4 v);
char4 convert_char4(long4 v); 添加于 API level 21
char4 convert_char4(short4 v);
char4 convert_char4(uchar4 v);
char4 convert_char4(uint4 v);
char4 convert_char4(ulong4 v); 添加于 API level 21
char4 convert_char4(ushort4 v);
double2 convert_double2(char2 v); 添加于 API level 21
double2 convert_double2(double2 v); 添加于 API level 21
double2 convert_double2(float2 v); 添加于 API level 21
double2 convert_double2(half2 v); 添加于 API level 24
double2 convert_double2(int2 v); 添加于 API level 21
double2 convert_double2(long2 v); 添加于 API level 21
double2 convert_double2(short2 v); 添加于 API level 21
double2 convert_double2(uchar2 v); 添加于 API level 21
double2 convert_double2(uint2 v); 添加于 API level 21
double2 convert_double2(ulong2 v); 添加于 API level 21
double2 convert_double2(ushort2 v); 添加于 API level 21
double3 convert_double3(char3 v); 添加于 API level 21
double3 convert_double3(double3 v); 添加于 API level 21
double3 convert_double3(float3 v); 添加于 API level 21
double3 convert_double3(half3 v); 添加于 API level 24
double3 convert_double3(int3 v); 添加于 API level 21
double3 convert_double3(long3 v); 添加于 API level 21
double3 convert_double3(short3 v); 添加于 API level 21
double3 convert_double3(uchar3 v); 添加于 API level 21
double3 convert_double3(uint3 v); 添加于 API level 21
double3 convert_double3(ulong3 v); 添加于 API level 21
double3 convert_double3(ushort3 v); 添加于 API level 21
double4 convert_double4(char4 v); 添加于 API level 21
double4 convert_double4(double4 v); 添加于 API level 21
double4 convert_double4(float4 v); 添加于 API level 21
double4 convert_double4(half4 v); 添加于 API level 24
double4 convert_double4(int4 v); 添加于 API level 21
double4 convert_double4(long4 v); 添加于 API level 21
double4 convert_double4(short4 v); 添加于 API level 21
double4 convert_double4(uchar4 v); 添加于 API level 21
double4 convert_double4(uint4 v); 添加于 API level 21
double4 convert_double4(ulong4 v); 添加于 API level 21
double4 convert_double4(ushort4 v); 添加于 API level 21
float2 convert_float2(char2 v);
float2 convert_float2(double2 v); 添加于 API level 21
float2 convert_float2(float2 v);
float2 convert_float2(half2 v); 添加于 API level 24
float2 convert_float2(int2 v);
float2 convert_float2(long2 v); 添加于 API level 21
float2 convert_float2(short2 v);
float2 convert_float2(uchar2 v);
float2 convert_float2(uint2 v);
float2 convert_float2(ulong2 v); 添加于 API level 21
float2 convert_float2(ushort2 v);
float3 convert_float3(char3 v);
float3 convert_float3(double3 v); 添加于 API level 21
float3 convert_float3(float3 v);
float3 convert_float3(half3 v); 添加于 API level 24
float3 convert_float3(int3 v);
float3 convert_float3(long3 v); 添加于 API level 21
float3 convert_float3(short3 v);
float3 convert_float3(uchar3 v);
float3 convert_float3(uint3 v);
float3 convert_float3(ulong3 v); 添加于 API level 21
float3 convert_float3(ushort3 v);
float4 convert_float4(char4 v);
float4 convert_float4(double4 v); 添加于 API level 21
float4 convert_float4(float4 v);
float4 convert_float4(half4 v); 添加于 API level 24
float4 convert_float4(int4 v);
float4 convert_float4(long4 v); 添加于 API level 21
float4 convert_float4(short4 v);
float4 convert_float4(uchar4 v);
float4 convert_float4(uint4 v);
float4 convert_float4(ulong4 v); 添加于 API level 21
float4 convert_float4(ushort4 v);
half2 convert_half2(char2 v); 添加于 API level 24
half2 convert_half2(double2 v); 添加于 API level 24
half2 convert_half2(float2 v); 添加于 API level 24
half2 convert_half2(half2 v); 添加于 API level 24
half2 convert_half2(int2 v); 添加于 API level 24
half2 convert_half2(long2 v); 添加于 API level 24
half2 convert_half2(short2 v); 添加于 API level 24
half2 convert_half2(uchar2 v); 添加于 API level 24
half2 convert_half2(uint2 v); 添加于 API level 24
half2 convert_half2(ulong2 v); 添加于 API level 24
half2 convert_half2(ushort2 v); 添加于 API level 24
half3 convert_half3(char3 v); 添加于 API level 24
half3 convert_half3(double3 v); 添加于 API level 24
half3 convert_half3(float3 v); 添加于 API level 24
half3 convert_half3(half3 v); 添加于 API level 24
half3 convert_half3(int3 v); 添加于 API level 24
half3 convert_half3(long3 v); 添加于 API level 24
half3 convert_half3(short3 v); 添加于 API level 24
half3 convert_half3(uchar3 v); 添加于 API level 24
half3 convert_half3(uint3 v); 添加于 API level 24
half3 convert_half3(ulong3 v); 添加于 API level 24
half3 convert_half3(ushort3 v); 添加于 API level 24
half4 convert_half4(char4 v); 添加于 API level 24
half4 convert_half4(double4 v); 添加于 API level 24
half4 convert_half4(float4 v); 添加于 API level 24
half4 convert_half4(half4 v); 添加于 API level 24
half4 convert_half4(int4 v); 添加于 API level 24
half4 convert_half4(long4 v); 添加于 API level 24
half4 convert_half4(short4 v); 添加于 API level 24
half4 convert_half4(uchar4 v); 添加于 API level 24
half4 convert_half4(uint4 v); 添加于 API level 24
half4 convert_half4(ulong4 v); 添加于 API level 24
half4 convert_half4(ushort4 v); 添加于 API level 24
int2 convert_int2(char2 v);
int2 convert_int2(double2 v); 添加于 API level 21
int2 convert_int2(float2 v);
int2 convert_int2(half2 v); 添加于 API level 24
int2 convert_int2(int2 v);
int2 convert_int2(long2 v); 添加于 API level 21
int2 convert_int2(short2 v);
int2 convert_int2(uchar2 v);
int2 convert_int2(uint2 v);
int2 convert_int2(ulong2 v); 添加于 API level 21
int2 convert_int2(ushort2 v);
int3 convert_int3(char3 v);
int3 convert_int3(double3 v); 添加于 API level 21
int3 convert_int3(float3 v);
int3 convert_int3(half3 v); 添加于 API level 24
int3 convert_int3(int3 v);
int3 convert_int3(long3 v); 添加于 API level 21
int3 convert_int3(short3 v);
int3 convert_int3(uchar3 v);
int3 convert_int3(uint3 v);
int3 convert_int3(ulong3 v); 添加于 API level 21
int3 convert_int3(ushort3 v);
int4 convert_int4(char4 v);
int4 convert_int4(double4 v); 添加于 API level 21
int4 convert_int4(float4 v);
int4 convert_int4(half4 v); 添加于 API level 24
int4 convert_int4(int4 v);
int4 convert_int4(long4 v); 添加于 API level 21
int4 convert_int4(short4 v);
int4 convert_int4(uchar4 v);
int4 convert_int4(uint4 v);
int4 convert_int4(ulong4 v); 添加于 API level 21
int4 convert_int4(ushort4 v);
long2 convert_long2(char2 v); 添加于 API level 21
long2 convert_long2(double2 v); 添加于 API level 21
long2 convert_long2(float2 v); 添加于 API level 21
long2 convert_long2(half2 v); 添加于 API level 24
long2 convert_long2(int2 v); 添加于 API level 21
long2 convert_long2(long2 v); 添加于 API level 21
long2 convert_long2(short2 v); 添加于 API level 21
long2 convert_long2(uchar2 v); 添加于 API level 21
long2 convert_long2(uint2 v); 添加于 API level 21
long2 convert_long2(ulong2 v); 添加于 API level 21
long2 convert_long2(ushort2 v); 添加于 API level 21
long3 convert_long3(char3 v); 添加于 API level 21
long3 convert_long3(double3 v); 添加于 API level 21
long3 convert_long3(float3 v); 添加于 API level 21
long3 convert_long3(half3 v); 添加于 API level 24
long3 convert_long3(int3 v); 添加于 API level 21
long3 convert_long3(long3 v); 添加于 API level 21
long3 convert_long3(short3 v); 添加于 API level 21
long3 convert_long3(uchar3 v); 添加于 API level 21
long3 convert_long3(uint3 v); 添加于 API level 21
long3 convert_long3(ulong3 v); 添加于 API level 21
long3 convert_long3(ushort3 v); 添加于 API level 21
long4 convert_long4(char4 v); 添加于 API level 21
long4 convert_long4(double4 v); 添加于 API level 21
long4 convert_long4(float4 v); 添加于 API level 21
long4 convert_long4(half4 v); 添加于 API level 24
long4 convert_long4(int4 v); 添加于 API level 21
long4 convert_long4(long4 v); 添加于 API level 21
long4 convert_long4(short4 v); 添加于 API level 21
long4 convert_long4(uchar4 v); 添加于 API level 21
long4 convert_long4(uint4 v); 添加于 API level 21
long4 convert_long4(ulong4 v); 添加于 API level 21
long4 convert_long4(ushort4 v); 添加于 API level 21
short2 convert_short2(char2 v);
short2 convert_short2(double2 v); 添加于 API level 21
short2 convert_short2(float2 v);
short2 convert_short2(half2 v); 添加于 API level 24
short2 convert_short2(int2 v);
short2 convert_short2(long2 v); 添加于 API level 21
short2 convert_short2(short2 v);
short2 convert_short2(uchar2 v);
short2 convert_short2(uint2 v);
short2 convert_short2(ulong2 v); 添加于 API level 21
short2 convert_short2(ushort2 v);
short3 convert_short3(char3 v);
short3 convert_short3(double3 v); 添加于 API level 21
short3 convert_short3(float3 v);
short3 convert_short3(half3 v); 添加于 API level 24
short3 convert_short3(int3 v);
short3 convert_short3(long3 v); 添加于 API level 21
short3 convert_short3(short3 v);
short3 convert_short3(uchar3 v);
short3 convert_short3(uint3 v);
short3 convert_short3(ulong3 v); 添加于 API level 21
short3 convert_short3(ushort3 v);
short4 convert_short4(char4 v);
short4 convert_short4(double4 v); 添加于 API level 21
short4 convert_short4(float4 v);
short4 convert_short4(half4 v); 添加于 API level 24
short4 convert_short4(int4 v);
short4 convert_short4(long4 v); 添加于 API level 21
short4 convert_short4(short4 v);
short4 convert_short4(uchar4 v);
short4 convert_short4(uint4 v);
short4 convert_short4(ulong4 v); 添加于 API level 21
short4 convert_short4(ushort4 v);
uchar2 convert_uchar2(char2 v);
uchar2 convert_uchar2(double2 v); 添加于 API level 21
uchar2 convert_uchar2(float2 v);
uchar2 convert_uchar2(half2 v); 添加于 API level 24
uchar2 convert_uchar2(int2 v);
uchar2 convert_uchar2(long2 v); 添加于 API level 21
uchar2 convert_uchar2(short2 v);
uchar2 convert_uchar2(uchar2 v);
uchar2 convert_uchar2(uint2 v);
uchar2 convert_uchar2(ulong2 v); 添加于 API level 21
uchar2 convert_uchar2(ushort2 v);
uchar3 convert_uchar3(char3 v);
uchar3 convert_uchar3(double3 v); 添加于 API level 21
uchar3 convert_uchar3(float3 v);
uchar3 convert_uchar3(half3 v); 添加于 API level 24
uchar3 convert_uchar3(int3 v);
uchar3 convert_uchar3(long3 v); 添加于 API level 21
uchar3 convert_uchar3(short3 v);
uchar3 convert_uchar3(uchar3 v);
uchar3 convert_uchar3(uint3 v);
uchar3 convert_uchar3(ulong3 v); 添加于 API level 21
uchar3 convert_uchar3(ushort3 v);
uchar4 convert_uchar4(char4 v);
uchar4 convert_uchar4(double4 v); 添加于 API level 21
uchar4 convert_uchar4(float4 v);
uchar4 convert_uchar4(half4 v); 添加于 API level 24
uchar4 convert_uchar4(int4 v);
uchar4 convert_uchar4(long4 v); 添加于 API level 21
uchar4 convert_uchar4(short4 v);
uchar4 convert_uchar4(uchar4 v);
uchar4 convert_uchar4(uint4 v);
uchar4 convert_uchar4(ulong4 v); 添加于 API level 21
uchar4 convert_uchar4(ushort4 v);
uint2 convert_uint2(char2 v);
uint2 convert_uint2(double2 v); 添加于 API level 21
uint2 convert_uint2(float2 v);
uint2 convert_uint2(half2 v); 添加于 API level 24
uint2 convert_uint2(int2 v);
uint2 convert_uint2(long2 v); 添加于 API level 21
uint2 convert_uint2(short2 v);
uint2 convert_uint2(uchar2 v);
uint2 convert_uint2(uint2 v);
uint2 convert_uint2(ulong2 v); 添加于 API level 21
uint2 convert_uint2(ushort2 v);
uint3 convert_uint3(char3 v);
uint3 convert_uint3(double3 v); 添加于 API level 21
uint3 convert_uint3(float3 v);
uint3 convert_uint3(half3 v); 添加于 API level 24
uint3 convert_uint3(int3 v);
uint3 convert_uint3(long3 v); 添加于 API level 21
uint3 convert_uint3(short3 v);
uint3 convert_uint3(uchar3 v);
uint3 convert_uint3(uint3 v);
uint3 convert_uint3(ulong3 v); 添加于 API level 21
uint3 convert_uint3(ushort3 v);
uint4 convert_uint4(char4 v);
uint4 convert_uint4(double4 v); 添加于 API level 21
uint4 convert_uint4(float4 v);
uint4 convert_uint4(half4 v); 添加于 API level 24
uint4 convert_uint4(int4 v);
uint4 convert_uint4(long4 v); 添加于 API level 21
uint4 convert_uint4(short4 v);
uint4 convert_uint4(uchar4 v);
uint4 convert_uint4(uint4 v);
uint4 convert_uint4(ulong4 v); 添加于 API level 21
uint4 convert_uint4(ushort4 v);
ulong2 convert_ulong2(char2 v); 添加于 API level 21
ulong2 convert_ulong2(double2 v); 添加于 API level 21
ulong2 convert_ulong2(float2 v); 添加于 API level 21
ulong2 convert_ulong2(half2 v); 添加于 API level 24
ulong2 convert_ulong2(int2 v); 添加于 API level 21
ulong2 convert_ulong2(long2 v); 添加于 API level 21
ulong2 convert_ulong2(short2 v); 添加于 API level 21
ulong2 convert_ulong2(uchar2 v); 添加于 API level 21
ulong2 convert_ulong2(uint2 v); 添加于 API level 21
ulong2 convert_ulong2(ulong2 v); 添加于 API level 21
ulong2 convert_ulong2(ushort2 v); 添加于 API level 21
ulong3 convert_ulong3(char3 v); 添加于 API level 21
ulong3 convert_ulong3(double3 v); 添加于 API level 21
ulong3 convert_ulong3(float3 v); 添加于 API level 21
ulong3 convert_ulong3(half3 v); 添加于 API level 24
ulong3 convert_ulong3(int3 v); 添加于 API level 21
ulong3 convert_ulong3(long3 v); 添加于 API level 21
ulong3 convert_ulong3(short3 v); 添加于 API level 21
ulong3 convert_ulong3(uchar3 v); 添加于 API level 21
ulong3 convert_ulong3(uint3 v); 添加于 API level 21
ulong3 convert_ulong3(ulong3 v); 添加于 API level 21
ulong3 convert_ulong3(ushort3 v); 添加于 API level 21
ulong4 convert_ulong4(char4 v); 添加于 API level 21
ulong4 convert_ulong4(double4 v); 添加于 API level 21
ulong4 convert_ulong4(float4 v); 添加于 API level 21
ulong4 convert_ulong4(half4 v); 添加于 API level 24
ulong4 convert_ulong4(int4 v); 添加于 API level 21
ulong4 convert_ulong4(long4 v); 添加于 API level 21
ulong4 convert_ulong4(short4 v); 添加于 API level 21
ulong4 convert_ulong4(uchar4 v); 添加于 API level 21
ulong4 convert_ulong4(uint4 v); 添加于 API level 21
ulong4 convert_ulong4(ulong4 v); 添加于 API level 21
ulong4 convert_ulong4(ushort4 v); 添加于 API level 21
ushort2 convert_ushort2(char2 v);
ushort2 convert_ushort2(double2 v); 添加于 API level 21
ushort2 convert_ushort2(float2 v);
ushort2 convert_ushort2(half2 v); 添加于 API level 24
ushort2 convert_ushort2(int2 v);
ushort2 convert_ushort2(long2 v); 添加于 API level 21
ushort2 convert_ushort2(short2 v);
ushort2 convert_ushort2(uchar2 v);
ushort2 convert_ushort2(uint2 v);
ushort2 convert_ushort2(ulong2 v); 添加于 API level 21
ushort2 convert_ushort2(ushort2 v);
ushort3 convert_ushort3(char3 v);
ushort3 convert_ushort3(double3 v); 添加于 API level 21
ushort3 convert_ushort3(float3 v);
ushort3 convert_ushort3(half3 v); 添加于 API level 24
ushort3 convert_ushort3(int3 v);
ushort3 convert_ushort3(long3 v); 添加于 API level 21
ushort3 convert_ushort3(short3 v);
ushort3 convert_ushort3(uchar3 v);
ushort3 convert_ushort3(uint3 v);
ushort3 convert_ushort3(ulong3 v); 添加于 API level 21
ushort3 convert_ushort3(ushort3 v);
ushort4 convert_ushort4(char4 v);
ushort4 convert_ushort4(double4 v); 添加于 API level 21
ushort4 convert_ushort4(float4 v);
ushort4 convert_ushort4(half4 v); 添加于 API level 24
ushort4 convert_ushort4(int4 v);
ushort4 convert_ushort4(long4 v); 添加于 API level 21
ushort4 convert_ushort4(short4 v);
ushort4 convert_ushort4(uchar4 v);
ushort4 convert_ushort4(uint4 v);
ushort4 convert_ushort4(ulong4 v); 添加于 API level 21
ushort4 convert_ushort4(ushort4 v);

将矢量从一种数值类型转换为另一种类型。转换是逐项完成的。

例如,调用 a = convert_short3(b); 等同于执行 a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;

将浮点值转换为整数类型会截断。

将过大的数字转换为目标类型会导致未定义结果。例如,将包含 1.0e18 的 float 转换为 short 是未定义的。使用 clamp() 可避免此问题。

rsPackColorTo8888 :从 float 创建 uchar4 RGBA

uchar4 rsPackColorTo8888(float r, float g, float b);
uchar4 rsPackColorTo8888(float r, float g, float b, float a);
uchar4 rsPackColorTo8888(float3 color);
uchar4 rsPackColorTo8888(float4 color);
参数
r红色分量。
g绿色分量。
b蓝色分量。
aAlpha 分量。
color包含 R、G、B 和 A 值的 3 或 4 个浮点数的向量。

将三个或四个浮点 RGBA 值打包成一个 uchar4。

输入值通常在 0.0f 到 1.0f(含)之间。对于超出此范围的输入值,结果输出将被钳位到 0 到 255 之间。由于此钳位操作可能是在输入值乘以 255.f 并转换为整数之后进行的,因此大于 INT_MAX/255.f 或小于 INT_MIN/255.f 的输入值会导致未定义的行为。

如果未指定 Alpha 分量,则默认为 1.0,即结果的 Alpha 将设置为 255。

rsUnpackColor8888 :从 uchar4 创建一个 float4 RGBA

float4 rsUnpackColor8888(uchar4 c);

将 uchar4 颜色解包为 float4。结果浮点数将在 0.0 到 1.0(含)之间。

rsYuvToRGBA :将 YUV 值转换为 RGBA

float4 rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
uchar4 rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
参数
y亮度分量。
uU 色度分量。
vV 色度分量。

将颜色从 YUV 表示转换为 RGBA。

我们目前不提供执行反向转换的函数。