-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImage.h
52 lines (41 loc) · 1.25 KB
/
Image.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
45
46
47
48
49
50
51
52
#pragma once
#include "Color.h"
#include <vector>
#include <cstddef>
namespace Gif2UnicornHat {
class Image {
public: // Construction.
typedef size_t Dimension;
Image(Dimension width, Dimension height, Color background = Color());
public: // Dimensions.
Dimension width() const;
Dimension height() const;
Image scale2x() const;
public: // Drawing.
void fill(const Color&);
public: // Pixel Access.
// A proxy object used to index into an Image twice for x and y.
// https://en.wikibooks.org/wiki/More_C++_Idioms/Temporary_Proxy
class AccessorProxy {
public: // Construction.
AccessorProxy(Image* image, Dimension x);
public: // Default construct, copy construct, copy assign, and destruct.
AccessorProxy() = default;
AccessorProxy(const AccessorProxy&) = default;
AccessorProxy& operator=(const AccessorProxy&) = default;
~AccessorProxy() = default;
public: // Pixel Access.
Color& operator[] (Dimension y);
const Color& operator[] (Dimension y) const;
private: // Data.
Image* image_;
Dimension x_;
};
AccessorProxy operator[] (Dimension x);
const AccessorProxy operator[] (Dimension x) const;
private: // Data.
Dimension width_;
Dimension height_;
std::vector<Color> canvas_;
};
}