写BITMAP标题 [英] writing BITMAP header

查看:57
本文介绍了写BITMAP标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我试图将BITMAP文件分成4个部分

在这个过程中我们必须为每个部分写标题

怎么写标题

请帮帮我

i am致命需要


i am attempting to split a BITMAP file into 4 parts
in that process we have to write header for each part
how to write the header
please help me
i am in deadly need

推荐答案

HI,
告诉我你在这方面的尝试以及ru卡住的地方?

那么这里的人可以帮你...

谢谢

Raghuram

Tell me what you have attempted on this and where r u stuck?
Then people here can hep u...
Thanks
Raghuram


嗨大家好,


希望你能帮助我。我有一个0-255的数字数组,我想创建一个bmp文件,但只有灰色,所以0 = schwarz,255 =白色。


我已经能够使用以下方法写入文件:(c ++)

[PHP]

fstream data(filename,ios ::''out''| ios :: binary | ios :: trunc);


if(!data.is_open()|| data.bad())

{

cout<< 错误:无法打开文件 << endl;

退出(-1);

}


writeBin(数据,''B'');

writeBin(数据,''M'');

writeBin(数据,(长)高*宽* 3 + 52);

writeBin (数据,(长)0);

writeBin(数据,(长)52);


writeBin(数据,(长)40);

writeBin(数据,宽度);

writeBin(数据,高度);

writeBin(数据,(短)1);

writeBin(数据,(短)8);

writeBin(数据,(长)0);

writeBin(数据,(长)0) ;

writeBin(数据,(长)0);

writeBin(数据,(长)0);

writeBin(数据,( long)0);

writeBin(data,(long)0);


std :: vector< pix> :: iterator pixIterator = grauwert.begin();

for(pixIterator; pixIterator!= grauwert.end(); pixIterator ++)

{

printf("%i test",(* pixIterator).grauwert);

writeBin(data,(* pixIterator).grauwert);

}

data.close();

[/ PHP]


[PHP]

struct pix

{

pix():grauwert(0),x(0),y(0){}

int grauwert;

int x;

int y;

};


//写作方法:

模板< class T>

void writeBin(fstream& Out,T data)

{

Out .write(reinterpret_cast< char *>(& data),sizeof(T));

}

[/ PHP]

所以我的问题是如何编辑我的标题,我可以使用我的矢量数字作为表示灰色值的数字?


如果您有任何建议,请随时回答:-)


bye
Hi Guys,

hopefully you can help me. I have an array of number from 0-255 and I would like to create a bmp file, but only grey colors so 0 = schwarz , 255 = white.

I am already able to write into the file with the following method: (c++)
[PHP]
fstream data(filename, ios::''out'' | ios::binary | ios::trunc);

if(!data.is_open() || data.bad())
{
cout << "error: cannot open file" << endl;
exit(-1);
}

writeBin(data, ''B'');
writeBin(data, ''M'');
writeBin(data, (long) height*width*3+52);
writeBin(data, (long) 0);
writeBin(data, (long) 52);

writeBin(data, (long) 40);
writeBin(data, width);
writeBin(data, height);
writeBin(data, (short) 1);
writeBin(data, (short) 8);
writeBin(data, (long) 0);
writeBin(data, (long) 0);
writeBin(data, (long) 0);
writeBin(data, (long) 0);
writeBin(data, (long) 0);
writeBin(data, (long) 0);

std::vector< pix >::iterator pixIterator = grauwert.begin();
for (pixIterator;pixIterator != grauwert.end();pixIterator++)
{
printf("%i test",(*pixIterator).grauwert);
writeBin(data, (*pixIterator).grauwert);
}
data.close();
[/PHP]

[PHP]
struct pix
{
pix():grauwert( 0 ),x(0),y(0) {}
int grauwert;
int x;
int y;
};

//the writing method:
template <class T>
void writeBin(fstream &Out, T data)
{
Out.write(reinterpret_cast<char*> (&data), sizeof(T));
}
[/PHP]
So my question is how can I edit my header, that I can use the numbers of my vector as numbers which indicate a grayvalue?

If you have any suggestions, please feel free to answer :-)

bye


明天我会回答这个问题(或者今晚晚些时候)。


Adrian
I''ll answer this tomorrow (or maybe later tonight).


Adrian


这篇关于写BITMAP标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆