Dear all,
I need a help in Drawing Images in ANativeWindow in NDK.
I am trying to draw a 320 * 240 image in ANativeWindow in NDK using below code.
ANativeWindow_setBuffersGeometry(player.nativeWindow, 320, 240, WINDOW_FORMAT_RGB_565) ; // Called only once
The above code is called only once in the init function.
The Window is passed from application as a surface. The Surface is OpenGLSurface in Application
In a thread, below code is used to draw on Native Window
ANativeWindow_acquire(nativeWindow);
if(ANativeWindow_lock(nativeWindow,&outBuffer,NULL) < 0)
{
LOGE("Native Window Lock Failed....");
return -1;
}
memcpy(outBuffer.bits,frame->data,320*240*2);
if(ANativeWindow_unlockAndPost(is->nativeWindow) < 0)
{
LOGE("Native Window unlock and post failed");
}
return;
But the image that is being drawn on the device is not full.It looks like a zoomed Image.It is drawing only a part of the image.
Whereas when I dump the frame that is being copied to Native Window Outbuffer, the image is perfect as 320*240 image
The App is Run in Landscape Mode. The Display size is 800 * 480. The Open GL Surface Dimension is 320 * 240.
Please let me know, whether I am missing something or Its a bug in ANativeWindow.
Thanks & Regards
Vijayasarathy.M