Reputation: 12996
In my Android project, I want to access a drawable file using c/c++ from the android-ndk, like R.drawable.some_drawable.xml.
How can I achieve such functionality ?
Upvotes: 2
Views: 521
Reputation: 8862
AFAIK, using JNI you are limited to some primitive data types:
The mapping between Java data types and data types used in native code is pretty straightforward. The naming scheme remains the same: the native data type name is preceded by the character 'j', followed by all lowercase data type name equivalent to Java. JNI also includes another data type named jsize, which stores the length or an array or string.
void -> void : None
byte -> jbyte : 8-bit signed. Range is -27 to 27 - 1
int -> jint : 32-bit signed. Range is -231 to 231 - 1
float -> jfloat : 32 bits. Represent a real number as small as 1.4 x 10-45 and as big as 3.4 x 1038 (approx.), positive or negative
double -> jdouble : 64 bits. Represent a real number as small as 4.9 x 10-324 and as big as 1.7 x 10308 (approx.), positive or negative
char -> jchar : 16-bit unsigned. Range is 0 to 65535
long -> jlong : 64-bit signed. Range -263 to 263 - 1
short -> jshort : 16-bit signed. Range is -215 to 215 - 1
boolean -> jboolean : Unsigned 8 bits. true and false
Your solution would be saving your Drawable in cache folder and pass file address to your NDK code and read it in C/C++.
How can I write a Drawable resource to a File?
Upvotes: 1