资源简介
最近一个项目用到将TVP5150抓的RGB565 数据上传,
但电脑无法显示RGB565图像,所以参考网络上的代码
稍微进行了调整,可以使用!
使用方法:
将RGB565文件放到工程或者DEBUG目录下,文件名为test无扩展名
文件分辨率大小为 720x530
如果需要其它分辨率 可直接去代码中修改 宽度和高度即可。
由于项目时间关系,没有做参数直接传入就能用的功能。
同时提供一个
BMP转rgb565 的工具:
使用方法,调入图片后,可以调整图像的上下左右等。
然后点Save as 后弹出 转换的输出格式。
然后选择你想要的rgb565即可。
但注意一点,转出来的Data 的第一行要删除掉(这行看起来是个数据头)
剩下的全是图像数据。

代码片段和文件信息
// rgb565.cpp : Defines the entry point for the console application.
//
#include “stdafx.h“
//主函数
#include
#include
#include
#include “rgb2bmp.h“
#include
/****************************
RGB加上头部信息转换成BMP
参数說明:
rgb_buffer :RGB数据文件中的信息
nData :RGB数据的长度
nWidth :图像宽度的像素数
nHeight :图像高度的像素数
fp1 :所存放的文件
*****************************/
int RGB2BMP(unsigned 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.startPosition=54;
fwrite(bfType1sizeof(bfType)fp1);
fwrite(&m_BMPHeader.imageSize1sizeof(m_BMPHeader.imageSize)fp1);
fwrite(&m_BMPHeader.blank1sizeof(m_BMPHeader.blank)fp1);
fwrite(&m_BMPHeader.startPosition1sizeof(m_BMPHeader.startPosition)fp1);
InfoHead m_BMPInfoHeader;
m_BMPInfoHeader.Length=40;
m_BMPInfoHeader.width=nWidth;
m_BMPInfoHeader.height=nHeight;
m_BMPInfoHeader.colorPlane=1;
m_BMPInfoHeader.bitColor=24;
m_BMPInfoHeader.zipFormat=0;
m_BMPInfoHeader.realSize=3*nWidth*nHeight;
m_BMPInfoHeader.xPels=0;
m_BMPInfoHeader.yPels=0;
m_BMPInfoHeader.colorUse=0;
m_BMPInfoHeader.colorImportant=0;
fwrite(&m_BMPInfoHeader.Length1sizeof(m_BMPInfoHeader.Length)fp1);
fwrite(&m_BMPInfoHeader.width1sizeof(m_BMPInfoHeader.width)fp1);
fwrite(&m_BMPInfoHeader.height1sizeof(m_BMPInfoHeader.height)fp1);
fwrite(&m_BMPInfoHeader.colorPlane1sizeof(m_BMPInfoHeader.colorPlane)fp1);
fwrite(&m_BMPInfoHeader.bitColor1sizeof(m_BMPInfoHeader.bitColor)fp1);
fwrite(&m_BMPInfoHeader.zipFormat1sizeof(m_BMPInfoHeader.zipFormat)fp1);
fwrite(&m_BMPInfoHeader.realSize1sizeof(m_BMPInfoHeader.realSize)fp1);
fwrite(&m_BMPInfoHeader.xPels1sizeof(m_BMPInfoHeader.xPels)fp1);
fwrite(&m_BMPInfoHeader.yPels1sizeof(m_BMPInfoHeader.yPels)fp1);
fwrite(&m_BMPInfoHeader.colorUse1sizeof(m_BMPInfoHeader.colorUse)fp1);
fwrite(&m_BMPInfoHeader.colorImportant1sizeof(m_BMPInfoHeader.colorImportant)fp1);
fwrite(rgb_buffer3*nWidth*nHeight1fp1);
return 0;
}
int main(int argc char* argv[])
{ FILE* p;
/*************** input data ***********
filename :RGB数据文件名称
nWidth :所生成文件的水平像素
nHeight :所生成文件的垂直像素
newFile :最终生成文件的名称
***********************************************/
char* filename = “test“;
int nWidth = 720;
int nHeight = 530;
char* newFile = “test.bmp“;
int num;
p = fopen(filename“rb“);
if (p == NULL)
{
printf(“!!!file %s open failed.n“ filename);
return 0;
}
printf(“file %s open success\n“filename);
/*********** read Image
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 113664 2011-06-29 15:28 RGB-BMP互转\bmp转rgb565\BmpCvt.exe
文件 254001 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\Debug\rgb565.exe
文件 369084 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\Debug\rgb565.ilk
文件 16672 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\Debug\rgb565.obj
文件 203728 2015-09-29 17:04 RGB-BMP互转\RGB565转BMP\Debug\rgb565.pch
文件 590848 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\Debug\rgb565.pdb
文件 1814 2015-09-29 17:04 RGB-BMP互转\RGB565转BMP\Debug\StdAfx.obj
文件 763200 2015-09-29 16:48 RGB-BMP互转\RGB565转BMP\Debug\test
文件 74752 2015-09-30 09:15 RGB-BMP互转\RGB565转BMP\Debug\vc60.idb
文件 110592 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\Debug\vc60.pdb
文件 1208 2015-09-29 13:53 RGB-BMP互转\RGB565转BMP\ReadMe.txt
文件 3092 2015-09-29 14:05 RGB-BMP互转\RGB565转BMP\rgb2bmp.h
文件 4213 2015-09-29 17:46 RGB-BMP互转\RGB565转BMP\rgb565.cpp
文件 4536 2015-09-29 13:53 RGB-BMP互转\RGB565转BMP\rgb565.dsp
文件 535 2015-09-29 13:53 RGB-BMP互转\RGB565转BMP\rgb565.dsw
文件 50176 2015-09-30 09:16 RGB-BMP互转\RGB565转BMP\rgb565.ncb
文件 53760 2015-09-30 09:16 RGB-BMP互转\RGB565转BMP\rgb565.opt
文件 246 2015-09-29 17:47 RGB-BMP互转\RGB565转BMP\rgb565.plg
文件 293 2015-09-29 13:53 RGB-BMP互转\RGB565转BMP\StdAfx.cpp
文件 769 2015-09-29 13:53 RGB-BMP互转\RGB565转BMP\StdAfx.h
文件 763200 2015-09-29 16:48 RGB-BMP互转\RGB565转BMP\test
文件 581 2015-09-30 09:54 RGB-BMP互转\说明.txt
目录 0 2015-09-30 09:51 RGB-BMP互转\RGB565转BMP\Debug
目录 0 2015-09-30 09:52 RGB-BMP互转\bmp转rgb565
目录 0 2015-09-30 09:51 RGB-BMP互转\RGB565转BMP
目录 0 2015-09-30 09:54 RGB-BMP互转
----------- --------- ---------- ----- ----
3380964 26
- 上一篇:异形窗口与gif动画带透明背景的实现
- 下一篇:Unity 3D小游戏
相关资源
- 易语言播放器组件无缝转换(Demo2.e)
- IEEE754 浮点转换工具
- 栈的实现及应用,六种基本算法
- 音乐代码转换软件 单片机编程时用
- Img2Lcd(将图片转换为数组的工具)
- IP地址转换整形工具
- UNICODE GBK双向码表二进制文件
- 基于c8051f020的AD转换程序及LCD显示程序
- K码和经纬度转换excel表格
- 模拟段页式虚拟存储管理中地址转换
- EXE 转换 BAT工具
- 文件名批量大小写转换工具
- 莱卡 全站仪数据格式转换程序,有源
- 常用编码(UnicodeUTF-8GBK)转换工具
- 可以把delphi的dcu文件转换为pas文件的
- Cad坐标转换工具,可进行批量转换
- 将yuv各种格式的图片转换为jpg格式的
- 汉字内码转换工具,区位码转换
- 汇编语言程序设计代码转换程序
- 全自动多功能编码转换工具(URLASCI
- 汇编编程实现二进制和十六进制之间
- 将数字转为中文金额的大写方式(C
- 基于51单片机的模数转换与数模转换
- bmp2c
- 进制转换小程序
- EXCEL文件转换成固定的格式的文本格式
- 地固系惯性系坐标转换程序
- txt测井曲线转换las2.0(新编)
- 球面坐标与平面坐标的转换
- 公历(阳历)和农历(阴历)相互转
评论
共有 条评论