Skip to content

Commit 07e5b45

Browse files
committed
.
1 parent 09ac437 commit 07e5b45

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Fractal Images/Bitmap.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#include<fstream>
12
#include "Bitmap.h"
23
#include "BitmapFileHeader.h"
34
#include "BitmapInfoHeader.h"
45

56
using namespace fractal;
7+
using namespace std;
68

79
namespace fractal {
810

@@ -20,8 +22,25 @@ namespace fractal {
2022
infoheader.width = m_width;
2123
infoheader.height = m_height;
2224

25+
ofstream file;
26+
27+
file.open(filename, ios::out | ios::binary);
28+
29+
if (!file) {
30+
return false;
31+
}
32+
33+
file.write((char*)&fileheader, sizeof(fileheader));
34+
file.write((char*)&infoheader, sizeof(infoheader));
35+
file.write((char*)m_pPixel.get(), m_width * m_height * 3);
36+
37+
file.close();
38+
39+
if (!file) {
40+
return false;
41+
}
2342

24-
return false;
43+
return true;
2544
}
2645
void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) {
2746

Fractal Images/main.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
// Main
33

44
#include<iostream>
5-
#include"BitmapFileHeader.h"
6-
#include"BitmapInfoHeader.h"
5+
#include"Bitmap.h"
76

87
using namespace std;
98
using namespace fractal;
109

1110
int main() {
12-
cout << "Hello World" << endl;
11+
12+
Bitmap bitmap(800, 600);
13+
14+
bitmap.write("test.bmp");
15+
16+
cout << "Finished" << endl;
1317

1418
return 0;
1519
}

test.bmp

1.37 MB
Binary file not shown.

0 commit comments

Comments
 (0)