How to initialize constant of type rs_matrix4x4
using RenderScript?
Something like that
const rs_matrix4x4 xyz2rgb_m = {
3.2406, -1.5372, -0.4986, 0.0000,
-0.9689, 1.8758, 0.0415, 0.0000,
0.0557, -0.2040, 1.0570, 0.0000,
0.0000, 0.0000, 0.0000, 1.0000};
doesn't work. Compiler returns an error message:
Error:(11, 20) error: Reflection of initializer to variable 'xyz2rgb_m' (of type 'rs_matrix4x4') is unsupported currently.
Is element-by-element initialization the only way?
There is a set of functions named rsMatrixLoad
for rs_matrix4x4
initialization. They can load matrix elements from an array or a matrix.
One can use this function for initialization by array values:
void rsMatrixLoad(rs_matrix2x2* destination, const float* array);
For example:
void init() {
float rgb2xyz_m_data[] = {
0.4124, 0.3576, 0.1805, 0.0000,
0.2126, 0.7152, 0.0722, 0.0000,
0.0193, 0.1192, 0.9505, 0.0000,
0.0000, 0.0000, 0.0000, 1.0000};
rsMatrixLoad(&rgb2xyz_m, rgb2xyz_m_data);
}
There is also a set of methods for loading special matrices (e.g. projection one).