kanzi将画面保存成本地图片的可行方案

背景:除了利用平台的截屏功能外,kanzi自带的截屏功能并不好用,而且Texture的离屏渲染,也无法获取本地的纹理数据,似乎直接发给了GPU。

需求:kanzi画面离屏渲染,将纹理数据保存到本地图片。

一、创建kanzi插件

创建插件工程参考 使用kanzi开发仪表HMI插件

插件属性

	static kanzi::PropertyType<kanzi::string> NameProperty; //图片名字
    static kanzi::PropertyType<bool> ReSaveProperty;  //是否保存图片
    static kanzi::PropertyType<int> CaptureImgWidth;  //图片宽度
    static kanzi::PropertyType<int> CaptureImgHeight;  //图片高度

1.1 引入glad,设置framebuffer

gladLoadGL();

 glGenFramebuffers(1, &m_fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);

    kzLogDebug(("m_fbo={}", m_fbo));

    const int width = getProperty(CaptureImgWidth);
    const int height = getProperty(CaptureImgHeight);

    imageData = (unsigned char*)malloc(width * height * 4); // 4 bytes per pixel
    flippedData = (unsigned char*)malloc(width * height * 4); // 新的图像数据数组

    glGenTextures(1, &m_textureColorBuffer);
    glBindTexture(GL_TEXTURE_2D, m_texture
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值