QNX screen API简单学习

使用QNX screen API填充屏幕显示

main.c

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include "display.h"

struct display_context_t ctx = {
    .id_string                 = "demo",
    .display_index             = 0,
    .pipeline                  = 6,
    .zorder                    = 5,
    .property_buffer_size[0]   = 4032,
    .property_buffer_size[1]   = 756,
    .index_screen_buf          = 0,
    .property_source_pos[0]    = 0,
    .property_source_pos[1]    = 0,
    .property_source_size[0]   = 4032,
    .property_source_size[1]   = 756,
    .property_win_pos[0]       = 0,
    .property_win_pos[1]       = 0,
    .screen_property_size[0]   = 4032,
    .screen_property_size[1]   = 756,
    .screen_property_format        = SCREEN_FORMAT_RGBA8888,
    .picture_buffer_count        = 2,
};

int main(int argc, char *argv[])
{
    display_init(&ctx);

    while(1)
    {
        int rect[4] = { 0, 0, 1, 1 };
        rect[0] = rect[1] = 0;
        rect[2] = 0;//width;
        rect[3] = 0;//height;

        uint32_t *p = (void *)ctx.picture_buffer[ctx.index_screen_buf];
        for(int i = 0; i < 4032; i++)
        {
            for(int j = 0; j < 756; j++)
            {
                p[i * 756 + j] = 0x00FF0000;
            }
        }

        if( screen_post_window(ctx.screen_win, ctx.screen_buf[ctx.index_screen_buf], 1, rect, 0) != 0)
        {
            SLOG_ERR( "screen_post_window() failed, errno = %d.", errno );
        }
        else
        {
        }
    }
    return 0;
}

display.h

#if ! defined(__DISPLAY_H__)
#define __DISPLAY_H__

#include <sys/strm.h>
#include <sys/stat.h>
#include <stdio.h>
#include <limits.h>
#include <pthread.h>
#include <sys/mman.h>
#include <screen/screen.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

//#define V_DEC_PICTURE_BUFF_COUNT 2
#define SLOG_ERR(fmt,...) do{printf(fmt,##__VA_ARGS__);printf("\n");}while(0);
#define SLOG_INFO SLOG_ERR
#define SLOG_DEBUG2 SLOG_ERR

struct display_context_t
{
    char *id_string; /* /dev/screen/<pid>/id_string */
    int display_index; /* display index defined i
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值