-
大小: 467KB文件类型: .gz金币: 1下载: 0 次发布日期: 2021-05-25
- 语言: 其他
- 标签: linux android framebuffer gsnap
资源简介
linux从framebuffer获取image源码
代码片段和文件信息
/*
* File: gsnap.c
* Author: Li XianJing
* Brief: snap the linux mobile device screen.
*
* Copyright (c) 2009-2011 Li XianJing
*
*/
/*
* History:
* ================================================================
* 2009-08-20 Li XianJing created
* 2011-02-28 Li XianJing suppport RGB888 framebuffer.
* 2011-04-09 Li XianJing merge figofuture‘s png output.
* ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
struct _FBInfo;
typedef struct _FBInfo FBInfo;
typedef int (*UnpackPixel)(FBInfo* fb unsigned char* pixel
unsigned char* r unsigned char* g unsigned char* b);
struct _FBInfo
{
int fd;
UnpackPixel unpack;
unsigned char *bits;
struct fb_fix_screeninfo fi;
struct fb_var_screeninfo vi;
};
#define fb_width(fb) ((fb)->vi.xres)
#define fb_height(fb) ((fb)->vi.yres)
#define fb_bpp(fb) ((fb)->vi.bits_per_pixel>>3)
#define fb_size(fb) ((fb)->vi.xres * (fb)->vi.yres * fb_bpp(fb))
#define fb_line_length(fb) ((fb)->fi.line_length)
static int fb_unpack_rgb565(FBInfo* fb unsigned char* pixel
unsigned char* r unsigned char* g unsigned char* b)
{
unsigned short color = *(unsigned short*)pixel;
*r = ((color >> 11) & 0xff) << 3;
*g = ((color >> 5) & 0xff) << 2;
*b = (color & 0xff )<< 3;
return 0;
}
static int fb_unpack_rgb24(FBInfo* fb unsigned char* pixel
unsigned char* r unsigned char* g unsigned char* b)
{
*r = pixel[fb->vi.red.offset>>3];
*g = pixel[fb->vi.green.offset>>3];
*b = pixel[fb->vi.blue.offset>>3];
return 0;
}
static int fb_unpack_argb32(FBInfo* fb unsigned char* pixel
unsigned char* r unsigned char* g unsigned char* b)
{
*r = pixel[fb->vi.red.offset>>3];
*g = pixel[fb->vi.green.offset>>3];
*b = pixel[fb->vi.blue.offset>>3];
return 0;
}
static int fb_unpack_none(FBInfo* fb unsigned char* pixel
unsigned char* r unsigned char* g unsigned char* b)
{
*r = *g = *b = 0;
return 0;
}
static void set_pixel_unpacker(FBInfo* fb)
{
if(fb_bpp(fb) == 2)
{
fb->unpack = fb_unpack_rgb565;
}
else if(fb_bpp(fb) == 3)
{
fb->unpack = fb_unpack_rgb24;
}
else if(fb_bpp(fb) == 4)
{
fb->unpack = fb_unpack_argb32;
}
else
{
fb->unpack = fb_unpack_none;
printf(“%s: not supported format.\n“ __func__);
}
return;
}
static int fb_open(FBInfo* fb const char* fbfilename)
{
fb->fd = open(fbfilename O_RDWR);
if (fb->fd < 0)
{
fprintf(stderr “can‘t open %s\n“ fbfilename);
return -1;
}
if (ioctl(fb->fd FBIOGET_FSCREENINFO &fb->fi) < 0)
goto fail;
if (ioctl(fb->fd FBIOGET_VSCREENINFO &fb->vi) < 0)
goto fail;
fb->bits = mmap(0 fb_size(fb) PROT_READ | PR
- 上一篇:ROS+VLAN25条ADSL 多线拔号
- 下一篇:ssd7的答案
相关资源
- AsyncTask文件控制暂停和继续,在状态
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
评论
共有 条评论