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.
精彩评论