-
大小: 4KB文件类型: .c金币: 1下载: 0 次发布日期: 2021-06-24
- 语言: 其他
- 标签: linux framebuffer terminal C语言
资源简介
在terminal里写framebuffer显示一张32位/24位/16位jpg图片
代码片段和文件信息
/*
* ===========================================================================
*
* Filename: test.c
*
* Description:
*
* Version: 1.0
* Created: 03/26/2012 01:55:10 PM
* Revision: none
* Compiler: gcc
*
* Author: Johann (smith) hcywcx@gmail.com
* Company:
*
* ===========================================================================
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FB_DEV “/dev/fb0“
void RGB888toRGB32(unsigned int width unsigned char *inbuffer unsigned char * outbuffer);
unsigned short RGB888toRGB565(unsigned char redunsigned char green unsigned char blue);
int fb_pixel(void *fbmem int width int height int x int y unsigned short color);
void RGB888toRGB32(unsigned int width unsigned char *inbuffer unsigned char *outbuffer)
{
unsigned int i;
for (i=0; i < width; i++)
{
/* RED */
outbuffer[(i<<2)+0] = inbuffer[i * 3 + 2];
/* GREEN */
outbuffer[(i<<2)+1] = inbuffer[i * 3 + 1];
/* BLUE */
outbuffer[(i<<2)+2] = inbuffer[i * 3];
/* ALPHA */
outbuffer[(i<<2)+3] = ‘\0‘;
}
}
unsigned short RGB888toRGB565(unsigned char red unsigned char green unsigned char blue)
{
unsigned short B = (blue >> 3) & 0x001F;
unsigned short G = ((green >> 2) << 5) & 0x07E0;
unsigned short R = ((red >> 3) << 11) & 0xF800;
return (unsigned short) (R | G | B);
}
int fb_pixel(void *fbmem int width int height int x int y unsigned short color)
{
if ((x > width) || (y > height)) return (-1);
unsigned short *dst = ((unsigned short *) fbmem + y * width + x);
*dst = color;
return (0);
}
int main(int argc char *argv[])
{
FILE *jpgfile;
int fbdev;
char *fb_device;
unsigned char *fbmem;
unsigned short color;
unsigned char *buffer *outbuffer;
unsigned int s
相关资源
- DM9008 linux 驱动
- linux c select简单
- Lua中调用C函数
- Linux mpu6050驱动程序
- linux 配置文件读写C
- linux0.11内核源码
- linux进程监控和守护进程的程序
- rocky凝思操作系统ISO镜像刻录到U盘里
- linux按键测试,获取按键状态
- Linux基本命令操作实验报告
- 学习用4.0版Linux下Zynq的axitimer中断驱动
- ros的urdf机器人模型功能包
- ROS创建工作空间代码我写的博客配套
- 2020大数据面试题总汇
- Linux实验1_常用命令应用.doc
- 树莓派用I2C读取mpu9250代码
- pgilinux-2019-1910-x86-64.txt
- 56706-Linux驱动程序开发第2版源码
- Linux下基于UDP的socket编程,适用多客户
- linux调用kettle所用到的自动化脚本 k
- linux计算器代码
- max9286+96705 4路AHDcamera方案
- 三期视频网上买的,带课件,安装包
- 基于Linux的网络聊天室.rar
- linux 命令.docx
- linux 下QT讯飞语音合成demo
- linux下查看端口是否被占用以及查看所
- socket编程常用API汇总
- arcsde10.2百度云连接linux版本
- 嵌入式uClinux应用程序的NFS开发
评论
共有 条评论