1
我想在JNI
中使用此代碼,而不必返回Java
。將createBitmap從Java轉換爲JNI
我已經將位圖操作轉換爲JNI(感謝其他stackoverflow海報),但這看起來更復雜,因爲我不明白如何調用構造函數。
Bitmap bmp;
bmp = ((BitmapDrawable)imgview.getDrawable()).getBitmap();
if (bmp == null || !bmp.isMutable())
Bitmap bmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
// bitmap manipulations goes here
jclass java_bitmap_class = (env)->GetObjectClass(java_bitmap);
class SkBitmap;
SkBitmap *sk_bitmap = (SkBitmap*)(env)->CallIntMethod(
java_bitmap, (env)->GetMethodID(java_bitmap_class, "ni", "()I"));
// there is more c++ code to manipulate bmp, but it is not relevant to a question
imgview.setImageBitmap(bmp);