-
大小: 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的答案
相关资源
- i2c_ioctl详解
- Linux网络编程超级详细笔记
- SlidingMenu的aar文件
- linux tftp rpm软件包
- libssl-dev库
- 基于video4linux2的双usb摄像头图像获取
- linux网络编程教学视频
- DTMF编码发音、捕获解码的DEMO
- Linux下聊天系统
- linux压力测试工具stress
- 国密SM4算法ECB CBC源码及demoLinux C版
- linux基础教程.pdf
- LINUX下传输文件源码
- NDK Socket通讯小程序
- 基于Linux的消息队列及多线程编程实现
- Linux操作系统实验教程源码.zip
- linux 0.11 bochs2.6.9配置文件
- socketcan提供的linux下的CAN网络工具包
- linux udev源代码
- libv4l-0.6.2-test.tar.gz
- makefile的详细说明文档
- 夜神模拟器tcpdump抓包教程
- 利用信号进行进程间通信
- Linux中的网络数据包捕获
- 基于QT+Linux的网络聊天室
- 银行家算法linux下实现
- linux下哲学家进餐问题实现
- UCloner-10.04.7.tar.gz
- linux libgcc_s.so.1 libgcc_s-4.4.5-20110214.
- uClinux-dist-20070130.tar.tar
评论
共有 条评论