admin管理员组文章数量:1401673
Is there a way to get supported device specific formats when using ANativeWindow_setBuffersGeometry? My current approach to test each option seems awkward. I can use ANativeWindow_getFormat (window) to get the default format, but some devices support multiple and I would like to choose the one with simplest processing to convert a source image to a displayable format. If there is a Java-side option based on Surface/SurfaceTexture (that can be used in NDK side), that would work but I couldn't find one.
int checkGeometry (ANativeWindow *window, int width, int height, int format)
{
int err_code = ANativeWindow_setBuffersGeometry(window,
width, height, format);
if (err_code != 0)
{
LOGD ("setBuffersGeometry failed!");
return err_code;
}
LOGD ("setBuffersGeometry: OK");
//--------
ANativeWindow_Buffer outBuffer;
err_code = ANativeWindow_lock(window, &outBuffer, NULL);
if (err_code != 0) {
LOGD ("Failed to allocate buffer!");
return err_code;
}
ANativeWindow_unlockAndPost(window);
//If failed to set properties, exit with error
if ( outBuffer.width != width ) {return -EINVAL;}
if ( outBuffer.height != height) {return -EINVAL;}
if ( outBuffer.format != format) {return -EINVAL;}
return err_code;
}
本文标签: imageGet list of supported formats for ANativeWindowsetBuffersGeometryStack Overflow
版权声明:本文标题:image - Get list of supported formats for ANativeWindow_setBuffersGeometry? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744283093a2598750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论