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();
BMP Class
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:
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
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;
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]
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]
I don't know the exact defination, but I mean those 24 or 32 bit bmp's you can make in paint uh...
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.
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.
Yup, that was easy and it works.
I can now actually create patterns and gradients YAY:-D
Thanks man,
- Myth
I can now actually create patterns and gradients YAY:-D
Thanks man,
- Myth
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement