資源簡介
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??“
< return?1;
}
if(!?input.ReadFromFile(argv[1])?)
{
cout?<“open?file?“?< return?1;
}
if(24?!=?input.TellBitDepth())
{
cout?< return?1;
}
output?=?fopen(argv[2]?“w+“);
if(output?==?NULL)
{
cout?<“create?file“?< return?1;
}
w?=?input.TellWidth();
h?=?input.TellHeight();
for(int?j=0;?j? {
for(?int?i=0;?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波形產(chǎn)生設計
- 下一篇:基于QT的方塊消除游戲
評論
共有 條評論