资源简介
文件中包含未转化的RGB565格式文件 tu0 tu1等(750KB)文件 同学们可以自己转换,也有转化好的文件(1126KB) 可执行文件a.out 原代码是rgb2bmp.c 和rgb2bmp.h 无BUG ,RGB565格式文件是从 某火的429开发板从液晶屏上截取的图像,该图像是从摄像头中拍下来的。
代码片段和文件信息
#include
#include
#include
#include“rgb2bmp.h“
int RGB2BMP(char *int int FILE *);
int main(int argcchar *argv[]){
double num_tmp = 0;
FILE *p;
/*************** input data ***********
filename :RGB数据文件名称
nWidth :所生成文件的水平像素
nHeight :所生成文件的垂直像素
newFile :最终生成文件的名称
**********************************************/
size_t read_size;
size_t write_size;
printf(“argv[1]= %s\n“argv[1]);
printf(“argv[2]= %s\n“argv[2]);
char * filename = “rgb565_800_480_woman“;
int nWidth = 800;
int nHeight = 480;
char *newFile = “rgb565_800_480_woman_0x7f.bmp“;
if(argc!=3){
printf(“Usage:./a.out \n“);
return -1;
}
filename = argv[1];
newFile = argv[2];
p = fopen(filename“rb“);
if( p == NULL){
printf(“open file %s error \n“filename);
return 0;
}
printf(“open file %s success\n“filename);
/*************** read Image Data **********/
long nData = nWidth *nHeight;
unsigned short * rgb_buffer = malloc(nData * sizeof(short));
//read_size = fread(rgb_buffer2nDatap);
//printf(“rgb_buffer[384000] = %d\n“*(rgb_buffer+383980));
read_size = fread(rgb_buffer2384000p);
//printf(“rgb_buffer[384000] = %d\n“*(rgb_buffer+383980));
printf(“fread 读取到的字节数是 %ld\n“read_size);
unsigned long total = nWidth*nHeight*3;
unsigned char *pVisit = malloc(total*sizeof(char));
unsigned char *tmp = pVisit;
long i = 0;
unsigned char RGB;
unsigned short *free1= rgb_buffer;
unsigned char *free2= pVisit;
while(i R = *rgb_buffer&0x1f;
G = (*rgb_buffer>>5)&0x3f;
B = (*rgb_buffer>>11)&0x1f;
/*
B<<3;
G<<2;
R<<3;
*/
num_tmp = R;
num_tmp/= 31;
R = num_tmp * 255;
num_tmp = G;
num_tmp/= 63;
G = num_tmp * 255;
num_tmp = B;
num_tmp/= 31;
B = num_tmp * 255;
*pVisit = R;pVisit++;
*pVisit = G;pVisit++;
*pVisit = B;pVisit++;
rgb_buffer++;
i++;
}
//free(free1);
printf(“read file over. nData = %ld\n“nData);
fclose(p);
p = NULL;
/*************************************/
/**************** write file *********/
FILE *result = fopen(newFile“wb“);
if(result == NULL){
printf(“open new file failed“);
return -1;
}
RGB2BMP(tmpnWidthnHeightresult);
printf(“total = %ld\n“total);
/*
write_size = fwrite(((char *)pVisit)1total/3result);
printf(“write_size = %ld \n“write_size);
write_size = fwrite(((char *)pVisit)+total/31total/3result);
printf(“write_size = %ld \n“write_size);
write_size = fwrite(((char *)pVisit)+total/3*21total/3result);
*/
write_size = fwrite(free211152000result);
printf(“write_size = %ld \n“write_size);
/*
write_size = fwrite(pVisit+7520001500000result);
printf(“write_size = %ld \n“write_size);
*/
fclose(result);
result = NULL;
free(free2);
return 0;
}
int RGB2BMP(char *rgb_bufferint nWidthint nHeightFILE *fp1){
BmpHead m_BMPHeader;
char bfType[2] = {‘B‘‘M‘};
m_BMPHeader.imageSize = 3*nWidth*nHeight + 54;
m_BMPHeader.blank=0;
m_BMPHeader.startP
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-03 08:47 RGB2\
文件 16384 2018-07-03 08:12 RGB2\.rgb2bmp.c.swp
文件 13152 2018-06-05 17:25 RGB2\a.out
文件 4602 2018-06-28 16:29 RGB2\rgb2bmp.c
文件 2851 2018-05-14 14:11 RGB2\rgb2bmp.h
文件 1152054 2018-06-05 17:34 RGB2\test.bmp
文件 314 2018-06-05 17:24 RGB2\tt.c
文件 768000 2015-01-01 00:00 RGB2\tu0
文件 768000 2015-01-01 00:00 RGB2\tu1
文件 768000 2015-01-01 00:00 RGB2\tu2
文件 1152054 2018-06-13 15:32 RGB2\zzz.bmp
文件 768000 2018-06-13 15:31 RGB2\zzz.txt
相关资源
- stm32F429中文数据手册279362
- stm32f4+w5500+tcpclient/server源码
- LORA完成.rar
- 水墨屏资料
- protues元器件名称
- 6968389Linux内核剖析(书籍注释代码)
- STM32之ADC+DMA传输定时器触发
- 基于SM32F103C8T6的环境传感器
- STM32F103C8T6+DHT11+SGP30+CH340+ADC
- STM32F103C8T6+DHT11+OLED
- rtl8723bs wifi linux驱动
- Linux安装SNMP服务所需要rpm包
- STM32实现LCD中显示当前ADC转换值
- Linux课设实现ftp服务器和客户端
- 基于STM32的DHT11的温湿度采集GSM报警系
- STM32 MODBUS_RTU从站程序,KEIL编写
- 搭建OMAPL138的Linux开发环境 LINUX交叉编
- stm32接收短信并开启继电器
- stm32智能小车/数组控制小车路径/避障
- NRF24L01收发程序STM32F407
- 嵌入式 L inux C 语言应用程序设计.pd
- 蓝桥杯嵌入式五届到八届完成全部源
- stm32f103zet6+摄像头颜色识别
- 基于stm32的红外代码程序
- linux音频设备编程
- LD3320语音模块资料51单片机代码,ST
- STM32F777 eMMC 驱动
- STM32F单片机与SIM900A的硬件条件下读一
- STM32 MPU6050 载人平衡车资料
- STM32F429DISCOVERY外接SD卡使用SDIO4BIT方式
评论
共有 条评论