Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Implemented by: http://www.youtube.com/user/thecplusplusguy
- //pure C++, compile, run, and it creates a bmp image (in the same folder, where the executable is), just as a siple demonstration
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- struct bmpfile_magic {
- unsigned char magic[2];
- };
- struct bmpfile_header {
- int filesz;
- short creator1;
- short creator2;
- int bmp_offset;
- };
- typedef struct {
- int header_sz;
- int width;
- int height;
- short nplanes;
- short bitspp;
- int compress_type;
- int bmp_bytesz;
- int hres;
- int vres;
- int ncolors;
- int nimpcolors;
- } BITMAPINFOHEADER;
- const int WIDTH=1023;
- const int HEIGHT=1023;
- const int BPP=32;
- int main()
- {
- srand(time(0));
- std::ofstream out("ki.bmp",std::ios::binary);
- bmpfile_magic bm={'B','M'};
- bmpfile_header bh={54+((BPP*WIDTH)/8)*HEIGHT,0,0,54};
- BITMAPINFOHEADER bhi={40,WIDTH,HEIGHT,1,BPP,0,((BPP*WIDTH)/8)*HEIGHT,2750,2750,0,0};
- out.write((char*)&bm,sizeof(bm));
- out.write((char*)&bh,sizeof(bh));
- out.write((char*)&bhi,sizeof(bhi));
- for(int i=0;i<HEIGHT;i++)
- for(int j=0;j<WIDTH;j++)
- {
- out.put((char)(i/4));
- out.put((char)(j/4));
- out.put((char)((i+j)/8));
- out.put((char)0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement