4714
- 收藏
- 点赞
- 分享
- 举报
linux framebuffer 显示图片问题
我的程序这样写的 为什么读不出来图片??
#include
#include
#include
#include
#include
#include "inc/hifb.h"
#define IMAGE_WIDTH 1096
#define IMAGE_HEIGHT 346
#define IMAGE_SIZE (1096 * 346 * 2)
#define IMAGE_NUM 14
//#define IMAGE_PATH "/0705-yinxr/%d.bmp"
#define IMAGE_PATH "/0705-yinxr/blui_update.png"
static struct fb_bitfield g_r16 = {10, 5, 0};
static struct fb_bitfield g_g16 = {5, 5, 0};
static struct fb_bitfield g_b16 = {0, 5, 0};
static struct fb_bitfield g_a16 = {15, 1, 0};
/*bit area for argb 8888*/
static struct fb_bitfield g_r32 = {16, 8, 0};
static struct fb_bitfield g_g32 = {8, 8, 0};
static struct fb_bitfield g_b32 = {0, 8, 0};
static struct fb_bitfield g_a32 = {24, 8, 0};
int main()
{
int fd;
int i = 0;
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
unsigned char *pShowScreen;
unsigned char *pHideScreen;
HIFB_POINT_S stPoint = {100, 0};
HIFB_ALPHA_S stAlpha;
FILE *fp;
char image_name[128];
/*1. open Framebuffer device overlay 0*/
fd = open("/dev/fb0", O_RDWR);
if(fd < 0)
{
printf("open fb0 failed!\n");
return -1;
}
/*2. set the screen original position*/
//stPoint.s32XPos = 0;
//stPoint.s32YPos = 0;
if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
printf("set screen original show position failed!\n");
return -1;
}
#if 0
stAlpha.bAlphaEnable = HI_TRUE;
stAlpha.bAlphaChannel = HI_TRUE;
stAlpha.u8Alpha0 = 0xff;
stAlpha.u8Alpha1 = 0xff;
stAlpha.u8GlobalAlpha = 0xff;
#endif
if (ioctl(fd, FBIOPUT_ALPHA_HIFB, &stAlpha) < 0)
{
printf("Set alpha failed!\n");
close(fd);
return HI_NULL;
}
/*3. get the variable screen info*/
if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0)
{
printf("Get variable screen info failed!\n");
close(fd);
return -1;
}
/*4. modify the variable screen info
the screen size: IMAGE_WIDTH*IMAGE_HEIGHT
the virtual screen size: IMAGE_WIDTH*(IMAGE_HEIGHT*2)
the pixel format: ARGB1555
*/
#if 1
var.xres = 1920;
var.yres = 1080;
var.xres_virtual = 1920;
var.yres_virtual = 1080 * 2;
var.transp= g_a16;
var.red = g_r16;
var.green = g_g16;
var.blue = g_b16;
var.bits_per_pixel = 16;
#endif
/*5. set the variable screeninfo*/
if (ioctl(fd, FBIOPUT_VSCREENINFO, &var) < 0)
{
printf("Put variable screen info failed!\n");
close(fd);
return -1;
}
/*6. get the fix screen info*/
if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0)
{
printf("Get fix screen info failed!\n");
close(fd);
return -1;
}
/*7. map the physical video memory for user use*/
pShowScreen = mmap(NULL, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
pHideScreen = pShowScreen + IMAGE_SIZE;
memset(pShowScreen, 0, IMAGE_SIZE);
/*8. load the bitmaps from file to hide screen and set pan display the
hide screen*/
//for(i = 0; i < IMAGE_NUM; i++)
{
sprintf(image_name, IMAGE_PATH);
fp = fopen(image_name, "rb");
if(NULL == fp)
{
printf("Load %s failed!\n", image_name);
close(fd);
return -1;
}
fread(pHideScreen, 1, IMAGE_SIZE, fp);
fclose(fp);
#if 0
if(i % 2)
{
var.yoffset = 0;
pHideScreen = pShowScreen + IMAGE_SIZE;
}
else
{
var.yoffset = IMAGE_HEIGHT;
pHideScreen = pShowScreen;
}
#endif
if (ioctl(fd, FBIOPAN_DISPLAY, &var) < 0)
{
printf("FBIOPAN_DISPLAY failed!\n");
close(fd);
return -1;
}
}
printf("Enter to quit!\n");
getchar();
/*9. close the Framebuffer device*/
close(fd);
return 0;
}
#include
#include
#include
#include
#include
#include "inc/hifb.h"
#define IMAGE_WIDTH 1096
#define IMAGE_HEIGHT 346
#define IMAGE_SIZE (1096 * 346 * 2)
#define IMAGE_NUM 14
//#define IMAGE_PATH "/0705-yinxr/%d.bmp"
#define IMAGE_PATH "/0705-yinxr/blui_update.png"
static struct fb_bitfield g_r16 = {10, 5, 0};
static struct fb_bitfield g_g16 = {5, 5, 0};
static struct fb_bitfield g_b16 = {0, 5, 0};
static struct fb_bitfield g_a16 = {15, 1, 0};
/*bit area for argb 8888*/
static struct fb_bitfield g_r32 = {16, 8, 0};
static struct fb_bitfield g_g32 = {8, 8, 0};
static struct fb_bitfield g_b32 = {0, 8, 0};
static struct fb_bitfield g_a32 = {24, 8, 0};
int main()
{
int fd;
int i = 0;
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
unsigned char *pShowScreen;
unsigned char *pHideScreen;
HIFB_POINT_S stPoint = {100, 0};
HIFB_ALPHA_S stAlpha;
FILE *fp;
char image_name[128];
/*1. open Framebuffer device overlay 0*/
fd = open("/dev/fb0", O_RDWR);
if(fd < 0)
{
printf("open fb0 failed!\n");
return -1;
}
/*2. set the screen original position*/
//stPoint.s32XPos = 0;
//stPoint.s32YPos = 0;
if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
printf("set screen original show position failed!\n");
return -1;
}
#if 0
stAlpha.bAlphaEnable = HI_TRUE;
stAlpha.bAlphaChannel = HI_TRUE;
stAlpha.u8Alpha0 = 0xff;
stAlpha.u8Alpha1 = 0xff;
stAlpha.u8GlobalAlpha = 0xff;
#endif
if (ioctl(fd, FBIOPUT_ALPHA_HIFB, &stAlpha) < 0)
{
printf("Set alpha failed!\n");
close(fd);
return HI_NULL;
}
/*3. get the variable screen info*/
if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0)
{
printf("Get variable screen info failed!\n");
close(fd);
return -1;
}
/*4. modify the variable screen info
the screen size: IMAGE_WIDTH*IMAGE_HEIGHT
the virtual screen size: IMAGE_WIDTH*(IMAGE_HEIGHT*2)
the pixel format: ARGB1555
*/
#if 1
var.xres = 1920;
var.yres = 1080;
var.xres_virtual = 1920;
var.yres_virtual = 1080 * 2;
var.transp= g_a16;
var.red = g_r16;
var.green = g_g16;
var.blue = g_b16;
var.bits_per_pixel = 16;
#endif
/*5. set the variable screeninfo*/
if (ioctl(fd, FBIOPUT_VSCREENINFO, &var) < 0)
{
printf("Put variable screen info failed!\n");
close(fd);
return -1;
}
/*6. get the fix screen info*/
if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0)
{
printf("Get fix screen info failed!\n");
close(fd);
return -1;
}
/*7. map the physical video memory for user use*/
pShowScreen = mmap(NULL, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
pHideScreen = pShowScreen + IMAGE_SIZE;
memset(pShowScreen, 0, IMAGE_SIZE);
/*8. load the bitmaps from file to hide screen and set pan display the
hide screen*/
//for(i = 0; i < IMAGE_NUM; i++)
{
sprintf(image_name, IMAGE_PATH);
fp = fopen(image_name, "rb");
if(NULL == fp)
{
printf("Load %s failed!\n", image_name);
close(fd);
return -1;
}
fread(pHideScreen, 1, IMAGE_SIZE, fp);
fclose(fp);
#if 0
if(i % 2)
{
var.yoffset = 0;
pHideScreen = pShowScreen + IMAGE_SIZE;
}
else
{
var.yoffset = IMAGE_HEIGHT;
pHideScreen = pShowScreen;
}
#endif
if (ioctl(fd, FBIOPAN_DISPLAY, &var) < 0)
{
printf("FBIOPAN_DISPLAY failed!\n");
close(fd);
return -1;
}
}
printf("Enter to quit!\n");
getchar();
/*9. close the Framebuffer device*/
close(fd);
return 0;
}
我来回答
回答3个
时间排序
认可量排序
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2021-06-21 16:42:51
-
2016-04-13 20:34:52
-
2016-09-01 11:42:18
-
2013-02-20 13:30:49
-
2016-08-11 20:01:35
-
2018-05-18 17:00:41
-
2018-07-27 13:59:09
-
2021-01-21 18:02:39
-
2015-09-17 17:22:21
-
2015-06-19 14:20:36
-
2016-09-28 10:11:50
-
2021-01-03 19:23:27
-
2013-11-28 22:19:21
-
2018-11-02 09:43:28
-
2020-04-13 16:05:15
-
2021-06-16 13:43:20
-
2019-01-18 14:11:17
-
2020-03-03 17:51:42
-
2016-11-11 15:51:23
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认