1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
SOURCE.CPP
void Bitmap::Create(string name, int h2, int w2) {
h = h2;
w = w2;
filename = name;
Header temp1 = {19778, ( sizeof(Color) *(w*h) )+ 54, 0, 0, 54};
Info temp2 = {sizeof(Bitmap::Info), w, h, 1, sizeof(Color)*8, 0,header.size - 54, 0, 0, 0, 0};
Color temp3 = {0,255,90, 0};
header = temp1;
info = temp2;
color = temp3;
Color *c = new Color[w*h];
pic.open(filename.c_str(), ios::out|ios::binary);
pic.write(reinterpret_cast<char*>(&header), sizeof(header));
pic.write(reinterpret_cast<char*>(&info), sizeof(info));
for (int f = 0; f <= w*h; ++f) {
c[f] = temp3;
}
pic.write((char*)&c,info.size); //attempting to write data to bitmap
}
void Bitmap::Load(string f) {
filename = f;
pic.open(filename.c_str(), ios::in|ios::binary);
pic.read(reinterpret_cast<char*>(&header), sizeof(Bitmap::Header));
pic.read(reinterpret_cast<char*>(&info), sizeof(Bitmap::Info));
h = info.height;
w = info.width;
}
|