Jump to content
  • Advertisement
Sign in to follow this  
Myth000

BMP Class

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I want to write a bitmap writer. I found enough readers but no bitmaps writer, one that actually just plots pixels and doesn't mess with hdc or anything else. Just with simple functions:
void PlotPixel(const int x, const int y, const int r, const int g, const int b);
void Open(const char *file, const int dimensionX, const int dimensionY);
void Close();


I found things like this: http://atlc.sourceforge.net/bmp.html But then still if I want to write that, how can I write to 0002h? So how to write to hex addresses in hex values. Thank you, - Myth

Share this post


Link to post
Share on other sites
Advertisement
To make the compiler view a value a hexidecimal, prefix it with 0x. For example, to write the value 1Bh to index 12h of an array:

arr[0x12] = 0x1b;

Share this post


Link to post
Share on other sites
If you want to write a BMP file, try using The BMP file format. Here is some info.
As for file IO operations in C, you can find a nice tutorial here.

EDIT: Oh, I just realized you never mentioned BMP specifically, just bitmaps in general. In that case, you can make up your own format, or try something simple like PPM.

[Edited by - Peregrin on September 11, 2005 7:22:44 AM]

Share this post


Link to post
Share on other sites
The bitmaps MS Paint saves are Windows Bitmap files (BMP). The format is a little tricky, although it is not rocket science.
If this is your first experience with file formats, I would strongly suggest you try writing a small program that saves PPM files first. It can be a great introduction to the subject, and is also a semi-useful format. Most image viewers support PPM files, so will be able to view the files you save in IrfanView, for example.

Share this post


Link to post
Share on other sites
Glad to help. :)

I remember the first time I actually saved an image from my code. It was a simple blur, if I recall correctly. Opening it in an image viewer and actually seeing the picture was really amazing! I hope you will have as much fun with this as I had.

Share this post


Link to post
Share on other sites
Having the fun now. Calculating transparants etc...
Though I'm not sure about the color amount.
I want RGB colors. With max of 255 255 255.
Then the max color value must be 255 * 255 * 255 = 16 581 375?
That seems pretty correct, but then the image is considered invalid.
EDIT: Max = <65536

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!