summaryrefslogtreecommitdiff
path: root/libraries/daguerre/include/daguerre.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/daguerre/include/daguerre.hpp')
-rw-r--r--libraries/daguerre/include/daguerre.hpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/libraries/daguerre/include/daguerre.hpp b/libraries/daguerre/include/daguerre.hpp
index 274e257..62d10f0 100644
--- a/libraries/daguerre/include/daguerre.hpp
+++ b/libraries/daguerre/include/daguerre.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
+#include <cstring>
#include <cstdio>
namespace daguerre {
@@ -13,14 +14,6 @@ namespace daguerre {
uint8_t b;
};
- template <class to_type, class from_type>
- to_type convert_color(const from_type &from);
-
- template <>
- inline hilbert_color convert_color<hilbert_color, rgb24>(const rgb24 &from) {
- return __euler_encode_color(from.r, from.g, from.b);
- }
-
template <class color_t>
class image {
@@ -88,15 +81,15 @@ namespace daguerre {
//from [from_x, from_x + width) x [from_y, from_y + height).
template <class color_t>
void copy_region(
- image<color_t> &to, const image<color_t> &from, unsigned from_x,
- unsigned from_y, unsigned to_x, unsigned to_y, unsigned width,
- unsigned height) {
+ image<color_t> &to, unsigned to_x, unsigned to_y,
+ const image<color_t> &from, unsigned from_x, unsigned from_y,
+ unsigned width, unsigned height) {
color_t *to_start = to.buffer + to.pitch * to_y + to_x;
const color_t *from_start = from.buffer + from.pitch * from_y + from_x;
for (unsigned y = 0; y < height; ++y)
- memcpy(
+ std::memcpy(
to_start + to.pitch * y, from_start + from.pitch * y,
width * sizeof(color_t));
@@ -107,12 +100,11 @@ namespace daguerre {
//from [from_x, from_x + width) x [from_y, from_y + height).
template <
class to_color_t, class from_color_t,
- to_color_t converter(const from_color_t &) =
- convert_color<to_color_t, from_color_t>>
- void copy_region(
- image<to_color_t> &to, const image<from_color_t> &from, unsigned from_x,
- unsigned from_y, unsigned to_x, unsigned to_y, unsigned width,
- unsigned height) {
+ void overlay(to_color_t &dest, const from_color_t &src)>
+ void overlay_region(
+ image<to_color_t> &to, unsigned to_x, unsigned to_y,
+ const image<from_color_t> &from, unsigned from_x, unsigned from_y,
+ unsigned width, unsigned height) {
to_color_t *to_start = to.buffer + to.pitch * to_y + to_x;
const from_color_t *from_start =
@@ -120,8 +112,12 @@ namespace daguerre {
for (unsigned y = 0; y < height; ++y)
for (unsigned x = 0; x < width; ++x)
- to_start[to.pitch * y + x] = converter(from_start[from.pitch * y + x]);
+ overlay(to_start[to.pitch * y + x], from_start[from.pitch * y + x]);
+
+ }
+ static inline void encode(hilbert_color &dest, const rgb24 &src) {
+ dest = __euler_encode_color(src.r, src.g, src.b);
}
image<hilbert_color> get_hilbert_framebuffer();