Reputation: 417
I want to create one bitmap and display it on screen by using ndk code, can anybody tel me how to do that. Sample code is good to understand.
Upvotes: 1
Views: 1197
Reputation: 257
Starting from Gingerbread, NativeWindow is your choice to display a bitmap on screen from ndk.
android-ndk-r7b/platforms/android-9/arch-arm/usr/include/android/native_window.h
Looking for the two functions below, int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds); int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
It looks very much like java Canvas at android SDK level, right?
To use nativeWnd, you have to pass down a jobject of java SurfaceHolder to ndk, then acquire on the surface to make a nativeWnd.
Then, use ANativeWindow_setBuffersGeometry to setup frame size and color format
Then, ANativeWindow_lock to lock the surface
Then, do your picture bitblt
At last, ANativeWindow_unlockAndPost - your bitmap is on screen
You can also search the Internet to find sample code using native window.
Upvotes: 1