#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
usingnamespaceandroid;
staticinlineSkBitmap::Config convertPixelFormat(PixelFormat format) {
/* note: if PIXEL_FORMAT_RGBX_8888 means that all alpha bytes are 0xFF, then
we can map to SkBitmap::kARGB_8888_Config, and optionally call
bitmap.setIsOpaque(true) on the resulting SkBitmap (as an accelerator)
*/
switch(format) {
casePIXEL_FORMAT_RGBX_8888:returnSkBitmap::kARGB_8888_Config;
casePIXEL_FORMAT_RGBA_8888:returnSkBitmap::kARGB_8888_Config;
casePIXEL_FORMAT_RGB_565:returnSkBitmap::kRGB_565_Config;
default:returnSkBitmap::kNo_Config;
}
}
intmain(intargc,char** argv)
{
// set up

本文展示了如何在Android上通过C++创建Surface并显示RGB数据。首先,通过SurfaceComposerClient创建Surface,并设置其大小和位置。接着,获取Surface缓冲区并填充RGB内容,然后解锁并发布Surface。最后,还演示了从文件加载RGB数据、使用Skia库绘制图形以及显示JPEG图片到Surface的方法。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



