-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitmapImage.cpp
More file actions
38 lines (33 loc) · 919 Bytes
/
Copy pathBitmapImage.cpp
File metadata and controls
38 lines (33 loc) · 919 Bytes
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
#include "BitmapImage.h"
BitmapImage::BitmapImage() : width(640), height(480), channels(3), depth(8) {
buffer = new int[width * height * channels];
}
bool BitmapImage::load(std::string name) {
// check it is a supported image file
std::string fileExt = name.substr(name.find_last_of(".") + 1);
if (fileExt == "jpg" || fileExt == "jpeg" || fileExt == "png" || fileExt == "bmp") {
// load image file
// decompress into buffer
return true;
}
return false;
}
// ciao
BitmapImage::~BitmapImage() {
delete[] buffer;
}
bool BitmapImage::save() {
//...... save files ....
bool res = false;
if (res)
resize(width / 2, height / 2);
return true;
}
bool BitmapImage::resize(int width, int height) {
if (width > 0 || height > 0) {
this->width = width;
this->height = height;
return true;
} else
return false;
}