4730
- 收藏
- 点赞
- 分享
- 举报
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
-
2016-08-11 20:01:35
-
2013-02-20 13:30:49
-
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
-
2019-01-18 14:11:17
-
2020-03-03 17:51:42
-
2020-04-13 16:05:15
-
2021-06-16 13:43:20
-
2021-01-03 19:22:38
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5SS928的emmc有32GB,bootargs设置使用16GB,但是为啥能用的只有rootfs的大小
-
33SS928怎样烧写ubuntu系统
-
10ToolPlatform下载rootfs提示网络失败
-
10谁有GK7205V500的SDK
-
5Hi3516CV610 烧录不进去
-
10Hi3559AV100 芯片硬解码h265编码格式的视频时出现视频播放错误,解码错误信息 s32PackErr:码流有错
-
5海思SS928 / SD3403的sample_venc.c摄像头编码Demo中,采集到的摄像头的YUV数据在哪个相关的函数中?
-
5海鸥派openEuler无法启动网卡,连接WIFI存在问题
-
66有没有ISP相关的巨佬帮忙看看SS928对接IMX347的图像问题
-
50求助hi3559与FPGA通过SLVS-EC接口对接问题
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认