资源简介
Bmp2raw is a tool to convert 24bit BMP file to raw data.
It may be useful before generating C arrays for showing a picture in
a embeded system.
The color order in the output file is (B,G,R),(B,G,R), ...
代码片段和文件信息
/*
bmp2raw
author: Wayne.M.Zhang
email: wayne.m.zhang@gmail.com
date added: 10-18-2011
date modified: 10-18-2011
version: 1.01
license: BSD (revised/modified)
description: bmp2raw is a tool to convert 24bit BMP file to raw data.
It may be useful before generating C arrays for showing a picture in
a embeded system.
The color order in the output file is (BGR)(BGR) ...
*/
#include
#include “EasyBMP.h“
using namespace std;
int main(int argc char* argv[])
{
RGBApixel* pixel;
BMP input;
FILE* output;
unsigned int w;
unsigned int h;
unsigned char r;
unsigned char g;
unsigned char b;
if(argc != 3)
{
cout << “usage: bmp2raw “
<< endl << endl;
return 1;
}
if(! input.ReadFromFile(argv[1]) )
{
cout << “open file “ << argv[1] << “fail“ << endl;
return 1;
}
if(24 != input.TellBitDepth())
{
cout << argv[1] << “is not a 24bit bmp file !“ << endl;
return 1;
}
output = fopen(argv[2] “w+“);
if(output == NULL)
{
cout << “create file“ << argv[2] << “fail“ << endl;
return 1;
}
w = input.TellWidth();
h = input.TellHeight();
for(int j=0; j < h; j++)
{
for( int i=0; i < w; i++)
{
pixel = input(ij);
r =pixel->Red;
g =pixel->Green;
b =pixel->Blue;
fwrite(&b 1 1 output);
fwrite(&g 1 1 output);
fwrite(&r 1 1 output);
}
}
fclose(output);
return 0;
}
- 上一篇:基于fpga的dds波形产生设计
- 下一篇:基于QT的方块消除游戏
评论
共有 条评论