-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.cpp
More file actions
45 lines (35 loc) · 761 Bytes
/
Copy pathImage.cpp
File metadata and controls
45 lines (35 loc) · 761 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
39
40
41
42
43
44
45
#include "Image.h"
namespace Dithering
{
bool Image::openImage(const std::string& path)
{
image_.load(path.c_str());
if (!image_)
{
return false;
}
path_ = path;
pixel_components_step_ = image_.width() * image_.height() * image_.depth();
return true;
}
bool Image::createImage(const std::string& path, int rows, int columns)
{
image_ = cimg_library::CImg<unsigned char>(columns, rows, 1, 3, 0);
if (!image_)
{
return false;
}
path_ = path;
pixel_components_step_ = image_.width() * image_.height() * image_.depth();
return true;
}
void Image::saveImage() const
{
image_.save(path_.c_str());
}
void Image::getSize(int& rows, int& columns) const
{
rows = image_.height();
columns = image_.width();
}
}