最近一个项目用到将TVP5150抓的RGB565 数据上传,
但电脑无法显示RGB565图像,所以参考网络上的代码
稍微进行了调整,可以使用!
使用方法:
将RGB565文件放到工程或者DEBUG目录下,文件名为test无扩展名
文件分辨率大小为 720x530
如果需要其它分辨率 可直接去代码中修改 宽度和高度即可。
由于项目时间关系,没有做参数直接传入就能用的功能。
同时提供一个
BMP转rgb565 的工具:
使用方法,调入图片后,可以调整图像的上下左右等。
然后点Save as 后弹出 转换的输出格式。
然后选择你想要的rgb565即可。
但注意一点,转出来的Data 的第一行要删除掉(这行看起来是个数据头)
剩下的全是图像数据。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 113664 2011-06-29 15:28 RGB-BMP互转mp转rgb565BmpCvt.exe
文件 254001 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.exe
文件 369084 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.ilk
文件 16672 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.obj
文件 203728 2015-09-29 17:04 RGB-BMP互转RGB565转BMPDebug
gb565.pch
文件 590848 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.pdb
文件 1814 2015-09-29 17:04 RGB-BMP互转RGB565转BMPDebugStdAfx.obj
文件 763200 2015-09-29 16:48 RGB-BMP互转RGB565转BMPDebug est
文件 74752 2015-09-30 09:15 RGB-BMP互转RGB565转BMPDebugvc60.idb
文件 110592 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebugvc60.pdb
文件 1208 2015-09-29 13:53 RGB-BMP互转RGB565转BMPReadMe.txt
文件 3092 2015-09-29 14:05 RGB-BMP互转RGB565转BMP
gb2bmp.h
文件 4213 2015-09-29 17:46 RGB-BMP互转RGB565转BMP
gb565.cpp
文件 4536 2015-09-29 13:53 RGB-BMP互转RGB565转BMP
gb565.dsp
文件 535 2015-09-29 13:53 RGB-BMP互转RGB565转BMP
gb565.dsw
文件 50176 2015-09-30 09:16 RGB-BMP互转RGB565转BMP
gb565.ncb
文件 53760 2015-09-30 09:16 RGB-BMP互转RGB565转BMP
gb565.opt
文件 246 2015-09-29 17:47 RGB-BMP互转RGB565转BMP
gb565.plg
文件 293 2015-09-29 13:53 RGB-BMP互转RGB565转BMPStdAfx.cpp
文件 769 2015-09-29 13:53 RGB-BMP互转RGB565转BMPStdAfx.h
文件 763200 2015-09-29 16:48 RGB-BMP互转RGB565转BMP est
文件 581 2015-09-30 09:54 RGB-BMP互转说明.txt
目录 0 2015-09-30 09:51 RGB-BMP互转RGB565转BMPDebug
目录 0 2015-09-30 09:52 RGB-BMP互转mp转rgb565
目录 0 2015-09-30 09:51 RGB-BMP互转RGB565转BMP
目录 0 2015-09-30 09:54 RGB-BMP互转
----------- --------- ---------- ----- ----
3380964 26
// 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
“filename);
/*********** read Image
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 113664 2011-06-29 15:28 RGB-BMP互转mp转rgb565BmpCvt.exe
文件 254001 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.exe
文件 369084 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.ilk
文件 16672 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.obj
文件 203728 2015-09-29 17:04 RGB-BMP互转RGB565转BMPDebug
gb565.pch
文件 590848 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebug
gb565.pdb
文件 1814 2015-09-29 17:04 RGB-BMP互转RGB565转BMPDebugStdAfx.obj
文件 763200 2015-09-29 16:48 RGB-BMP互转RGB565转BMPDebug est
文件 74752 2015-09-30 09:15 RGB-BMP互转RGB565转BMPDebugvc60.idb
文件 110592 2015-09-29 17:46 RGB-BMP互转RGB565转BMPDebugvc60.pdb
文件 1208 2015-09-29 13:53 RGB-BMP互转RGB565转BMPReadMe.txt
文件 3092 2015-09-29 14:05 RGB-BMP互转RGB565转BMP
gb2bmp.h
文件 4213 2015-09-29 17:46 RGB-BMP互转RGB565转BMP
gb565.cpp
文件 4536 2015-09-29 13:53 RGB-BMP互转RGB565转BMP
gb565.dsp
文件 535 2015-09-29 13:53 RGB-BMP互转RGB565转BMP
gb565.dsw
文件 50176 2015-09-30 09:16 RGB-BMP互转RGB565转BMP
gb565.ncb
文件 53760 2015-09-30 09:16 RGB-BMP互转RGB565转BMP
gb565.opt
文件 246 2015-09-29 17:47 RGB-BMP互转RGB565转BMP
gb565.plg
文件 293 2015-09-29 13:53 RGB-BMP互转RGB565转BMPStdAfx.cpp
文件 769 2015-09-29 13:53 RGB-BMP互转RGB565转BMPStdAfx.h
文件 763200 2015-09-29 16:48 RGB-BMP互转RGB565转BMP est
文件 581 2015-09-30 09:54 RGB-BMP互转说明.txt
目录 0 2015-09-30 09:51 RGB-BMP互转RGB565转BMPDebug
目录 0 2015-09-30 09:52 RGB-BMP互转mp转rgb565
目录 0 2015-09-30 09:51 RGB-BMP互转RGB565转BMP
目录 0 2015-09-30 09:54 RGB-BMP互转
----------- --------- ---------- ----- ----
3380964 26
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)