Skip to content

Commit 2128557

Browse files
Added renamed directories
Added new directories with the same names, just without spaces.
1 parent acaa49a commit 2128557

File tree

311 files changed

+12317
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+12317
-0
lines changed

ABitmapClass/src/Bitmap.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Bitmap.cpp
3+
*
4+
* Created on: Jul 2, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#include "Bitmap.h"
9+
10+
namespace caveofprogramming {
11+
12+
Bitmap::Bitmap(int width, int height): m_width(width), m_height(height) {
13+
// TODO Auto-generated constructor stub
14+
15+
}
16+
17+
bool Bitmap::write(string filename) {
18+
return false;
19+
}
20+
21+
void Bitmap::setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) {
22+
23+
}
24+
25+
Bitmap::~Bitmap() {
26+
// TODO Auto-generated destructor stub
27+
}
28+
29+
} /* namespace caveofprogramming */

ABitmapClass/src/Bitmap.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Bitmap.h
3+
*
4+
* Created on: Jul 2, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#ifndef BITMAP_H_
9+
#define BITMAP_H_
10+
11+
#include <string>
12+
#include <cstdint>
13+
using namespace std;
14+
15+
namespace caveofprogramming {
16+
17+
class Bitmap {
18+
private:
19+
int m_width{0};
20+
int m_height{0};
21+
22+
public:
23+
Bitmap(int width, int height);
24+
void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue);
25+
bool write(string filename);
26+
virtual ~Bitmap();
27+
};
28+
29+
} /* namespace caveofprogramming */
30+
31+
#endif /* BITMAP_H_ */

ABitmapClass/src/BitmapFileHeader.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* BitmapFileHeader.h
3+
*
4+
* Created on: Jun 21, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#ifndef BITMAPFILEHEADER_H_
9+
#define BITMAPFILEHEADER_H_
10+
11+
#include <cstdint>
12+
13+
using namespace std;
14+
15+
#pragma pack(2)
16+
17+
namespace caveofprogramming {
18+
19+
struct BitmapFileHeader {
20+
char header[2] { 'B', 'M' };
21+
int32_t fileSize;
22+
int32_t reserved { 0 };
23+
int32_t dataOffset;
24+
};
25+
26+
}
27+
28+
#endif /* BITMAPFILEHEADER_H_ */

ABitmapClass/src/BitmapInfoHeader.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef BITMAPINFOHEADER_H_
2+
#define BITMAPINFOHEADER_H_
3+
4+
#include <cstdint>
5+
6+
using namespace std;
7+
8+
#pragma pack(2)
9+
10+
namespace caveofprogramming {
11+
12+
struct BitmapInfoHeader {
13+
int32_t headerSize{40};
14+
int32_t width;
15+
int32_t height;
16+
int16_t planes{1};
17+
int16_t bitsPerPixel{24};
18+
int32_t compression{0};
19+
int32_t dataSize{0};
20+
int32_t horizontalResolution{2400};
21+
int32_t verticalResolution{2400};
22+
int32_t colors{0};
23+
int32_t importantColors{0};
24+
};
25+
26+
}
27+
28+
#endif

ABitmapClass/src/main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//============================================================================
2+
// Name : Fractal.cpp
3+
// Author :
4+
// Version :
5+
// Copyright : Your copyright notice
6+
// Description : Hello World in C++, Ansi-style
7+
//============================================================================
8+
9+
#include <iostream>
10+
11+
#include "Bitmap.h"
12+
13+
using namespace std;
14+
using namespace caveofprogramming;
15+
16+
int main() {
17+
18+
Bitmap bitmap(800, 600);
19+
20+
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
21+
return 0;
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//============================================================================
2+
// Name : A.cpp
3+
// Author :
4+
// Version :
5+
// Copyright : Your copyright notice
6+
// Description : Hello World in C++, Ansi-style
7+
//============================================================================
8+
9+
#include <iostream>
10+
#include "Complex.h"
11+
12+
using namespace std;
13+
using namespace caveofprogramming;
14+
15+
int main() {
16+
17+
Complex c1(2, 3);
18+
Complex c2(c1);
19+
20+
Complex c3;
21+
22+
c3 = c2;
23+
24+
cout << c2 << ": " << c3 << endl;
25+
26+
return 0;
27+
}

AComplexNumberClass/src/Complex.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Complex.cpp
3+
*
4+
* Created on: 17 Oct 2014
5+
* Author: johnwpurcell
6+
*/
7+
8+
#include "Complex.h"
9+
10+
namespace caveofprogramming {
11+
12+
ostream &operator<<(ostream &out, const Complex &c) {
13+
out << "(" << c.getReal() << "," << c.getImaginary() << ")";
14+
return out;
15+
}
16+
17+
Complex::Complex(): real(0), imaginary(0) {
18+
// Nothing to do here
19+
}
20+
21+
Complex::Complex(double real, double imaginary): real(real), imaginary(imaginary) {
22+
23+
}
24+
25+
Complex::Complex(const Complex &other) {
26+
real = other.real;
27+
imaginary = other.imaginary;
28+
}
29+
30+
const Complex &Complex::operator=(const Complex &other) {
31+
real = other.real;
32+
imaginary = other.imaginary;
33+
34+
return *this;
35+
}
36+
37+
} /* namespace caveofprogramming */

AComplexNumberClass/src/Complex.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Complex.h
3+
*
4+
* Created on: 17 Oct 2014
5+
* Author: johnwpurcell
6+
*/
7+
8+
#ifndef COMPLEX_H_
9+
#define COMPLEX_H_
10+
11+
#include <iostream>
12+
using namespace std;
13+
14+
namespace caveofprogramming {
15+
16+
class Complex {
17+
private:
18+
double real;
19+
double imaginary;
20+
21+
public:
22+
Complex();
23+
Complex(double real, double imaginary);
24+
Complex(const Complex &other);
25+
const Complex &operator=(const Complex &other);
26+
27+
double getReal() const {
28+
return real;
29+
}
30+
double getImaginary() const {
31+
return imaginary;
32+
}
33+
};
34+
35+
ostream &operator<<(ostream &out, const Complex &c);
36+
37+
} /* namespace caveofprogramming */
38+
39+
#endif /* COMPLEX_H_ */

AMandelbrotClass/src/Bitmap.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Bitmap.cpp
3+
*
4+
* Created on: Jul 2, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#include <fstream>
9+
#include "Bitmap.h"
10+
#include "BitmapInfoHeader.h"
11+
#include "BitmapFileHeader.h"
12+
13+
using namespace caveofprogramming;
14+
using namespace std;
15+
16+
namespace caveofprogramming {
17+
18+
Bitmap::Bitmap(int width, int height) :
19+
m_width(width), m_height(height), m_pPixels(
20+
new uint8_t[width * height * 3] { }) {
21+
22+
}
23+
24+
bool Bitmap::write(string filename) {
25+
26+
BitmapFileHeader fileHeader;
27+
BitmapInfoHeader infoHeader;
28+
29+
fileHeader.fileSize = sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader)
30+
+ m_width * m_height * 3;
31+
fileHeader.dataOffset = sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader);
32+
33+
infoHeader.width = m_width;
34+
infoHeader.height = m_height;
35+
36+
ofstream file;
37+
file.open(filename, ios::out | ios::binary);
38+
39+
if (!file) {
40+
return false;
41+
}
42+
43+
file.write((char *) &fileHeader, sizeof(fileHeader));
44+
file.write((char *) &infoHeader, sizeof(infoHeader));
45+
file.write((char *) m_pPixels.get(), m_width * m_height * 3);
46+
47+
file.close();
48+
49+
if (!file) {
50+
return false;
51+
}
52+
53+
return true;
54+
}
55+
56+
void Bitmap::setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) {
57+
uint8_t *pPixel = m_pPixels.get();
58+
59+
pPixel += (y * 3) * m_width + (x * 3);
60+
61+
pPixel[0] = blue;
62+
pPixel[1] = green;
63+
pPixel[2] = red;
64+
}
65+
66+
Bitmap::~Bitmap() {
67+
// TODO Auto-generated destructor stub
68+
}
69+
70+
} /* namespace caveofprogramming */

AMandelbrotClass/src/Bitmap.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Bitmap.h
3+
*
4+
* Created on: Jul 2, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#ifndef BITMAP_H_
9+
#define BITMAP_H_
10+
11+
#include <string>
12+
#include <cstdint>
13+
#include <memory>
14+
using namespace std;
15+
16+
namespace caveofprogramming {
17+
18+
class Bitmap {
19+
private:
20+
int m_width{0};
21+
int m_height{0};
22+
unique_ptr<uint8_t[]> m_pPixels{nullptr};
23+
24+
25+
public:
26+
Bitmap(int width, int height);
27+
void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue);
28+
bool write(string filename);
29+
virtual ~Bitmap();
30+
};
31+
32+
} /* namespace caveofprogramming */
33+
34+
#endif /* BITMAP_H_ */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* BitmapFileHeader.h
3+
*
4+
* Created on: Jun 21, 2015
5+
* Author: johnpurcell
6+
*/
7+
8+
#ifndef BITMAPFILEHEADER_H_
9+
#define BITMAPFILEHEADER_H_
10+
11+
#include <cstdint>
12+
13+
using namespace std;
14+
15+
#pragma pack(2)
16+
17+
namespace caveofprogramming {
18+
19+
struct BitmapFileHeader {
20+
char header[2] { 'B', 'M' };
21+
int32_t fileSize;
22+
int32_t reserved { 0 };
23+
int32_t dataOffset;
24+
};
25+
26+
}
27+
28+
#endif /* BITMAPFILEHEADER_H_ */

0 commit comments

Comments
 (0)