saving bitmap file

Hey guys i have a header file and now i am writing the implementation file and defining the constructors..i am having trouble with 1 but..

void bitmap:save (string filename)
{


}

//The bitmap representation is written to filename. The bitmap file will consist of two positive integers R and C representing the number of rows and columns followed by R rows of C columns of zeroes and ones. For example :

3 5
00000
00000
01100
//i have to save it into string file name
can anyone plz help me
Stop double posting
well wen no1 answers my question i havta ask again
if you dont wanna help dont respond or look at it
closed account (z05DSL3A)
@shotjase

That Kind of attitude is not going to get you many friends here...

It looks like you left it a grand total of one minute before posting again to another forum.

There are good reasons to only post in one forum, one of them is not to P!$$ off the people you are asking to help you.

I would also recommend that you read:
How To Ask Questions The Smart Way
http://www.cplusplus.com/forum/articles/1295/
and
How to put code into your postings:
http://www.cplusplus.com/forum/articles/1624/
Last edited on
I assume that would be :
void bitmap::save (string filename) {
}

If it is your own personal "bitmap" class you could probably do something like :
1
2
3
4
5
6
7
8
void bitmap::save (string filename) {
	ofstream file(filename, std::ios::out | std::ios::binary); // Note this might be filename.c_str(), I don't know

	if (file.is_open()) {
		file.write((char *)bmp_object, sizeof(YourBitmapStructure));
		file.write(bmp_object->data, (bmp_object->width * bmp_object->height) * (bmp_object->bits_per_pixel / 8));
	}
}


Works for me, and was found quite suprisingly on a tutorial on this very site... :/
As your method is local to the function you may want to replace bmp_object with this.
Good Luck.
thanks man...nice 4 som1 2 help
closed account (z05DSL3A)
Hmm...

@shotjase

I had posted a reply to your other copy of this question. (maybe that is another reason for not posting the same question in two forums at the same time)

I also noticed you posted the same question on DaniWeb, didn't get much of a response there either. When I recommended that you read 'How To Ask Questions The Smart Way' I was not having a dig at you, it will be worth your time to read it. It may help you understand why your questions have not been answered.
Last edited on
Topic archived. No new replies allowed.