开发者

Android Bitmap native API to create android.graphics.Bitmap instance

开发者 https://www.devze.com 2023-03-31 02:34 出处:网络
I\'m using native code and I have a buffer of pixels (i.e int* buffer). I want to create a android.util.Bitmap instance from the buffer with a specific width, height.

I'm using native code and I have a buffer of pixels (i.e int* buffer). I want to create a android.util.Bitmap instance from the buffer with a specific width, height.

Currently, I return the buffer to Java and using android.graphics.Bitmap.createBitmap() to create a Bitmap instance. But it seems to be not efficient and it开发者_Python百科 throws OutOfMemoryException in my phone (less resources), but work in tablet (more resources).

My question is: How can I create a Bitmap instance in the native way (i.e. create such instance in C and return as a Bitmap in Java using JNI interface)?


How large is the bitmap? if it throws OOM in Java, any attempt to pass it back from C would probably do the same - it will still need to consume Java memory. Consider a bitmap format that takes less space per pixel - say, RGB_565, or ARGB_4444.

0

精彩评论

暂无评论...
验证码 换一张
取 消