-
Notifications
You must be signed in to change notification settings - Fork 0
/
aspng_surface.cpp
41 lines (36 loc) · 1.24 KB
/
aspng_surface.cpp
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
#include "aspng_surface.h"
#include "common.h"
std::ostream &operator<<(std::ostream &os, const Rgb &rgb) {
std::ios_base::fmtflags f(os.flags());
os << std::hex;
os << "Rgb(" << (int)rgb.r << ", " << (int)rgb.g << ", " << (int)rgb.b << ")";
os.flags(f);
return os;
}
bool AspngSurface::contains(AspngSurface *other, int32_t x, int32_t y) {
if (x + other->get_width() >= this->get_width()) {
return false;
}
if (y + other->get_height() >= this->get_height()) {
return false;
}
for (int32_t u = 0; u < other->get_width(); u++) {
for (int32_t v = 0; v < other->get_height(); v++) {
if (this->get_pixel(x + u, y + v) != other->get_pixel(u, v)) {
return false;
}
}
}
return true;
}
void AspngSurface::copy(AspngSurface *other, int32_t x, int32_t y) {
ASSERT(x + other->get_width() < this->get_width());
ASSERT(y + other->get_height() < this->get_height());
for (int32_t u = 0; u < other->get_width(); u++) {
for (int32_t v = 0; v < other->get_height(); v++) {
this->set_pixel(x + u, y + v, other->get_pixel(u, v));
}
}
}
void AspngSurface::start_draw(void) {}
void AspngSurface::finish_draw(void) {}