forked from kost/dcled
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpixmap.h
44 lines (34 loc) · 1.21 KB
/
pixmap.h
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
// dcled-hidapi - userland driver for the Dream Cheeky LED Message Board
// Copyright 2018 Jahn Fuchs <[email protected]>
// Distributed under the MIT License. See accompanying LICENSE file.
#pragma once
#include <vector>
#include <cstdint>
#include <string>
namespace dcled
{
class Screen;
class PixMap {
public:
PixMap(uint32_t width = 0, uint32_t height = 0);
PixMap(const Screen& screen);
PixMap(PixMap&& other) = default;
PixMap(const PixMap& other) = default;
PixMap& operator=(PixMap&& other) = default;
PixMap& operator=(const PixMap& other) = default;
static PixMap fromFile(const std::string& filename);
bool toFile(const std::string& filename) const;
void toStdout() const;
const uint8_t& at(uint32_t x, uint32_t y) const {
return pixels_.at(y).at(x);
}
uint8_t& at(uint32_t x, uint32_t y) {
return pixels_.at(y).at(x);
}
uint32_t width() const { return pixels_.size() ? static_cast<uint32_t>(pixels_.front().size()) : 0; }
uint32_t height() const { return static_cast<uint32_t>(pixels_.size()); }
void resize(uint32_t width, uint32_t height);
private:
std::vector<std::vector<uint8_t>> pixels_;
};
} // end namespace dcled