blob: 938e6c0d41deda87798a43ce541cb57ff2af917a (
plain) (
blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/******************************************************************/
/* This file is part of the homework assignments for CSCI-427/527 */
/* at The College of William & Mary and authored by Pieter Peers. */
/* No part of this file, whether altered or in original form, can */
/* be distributed or used outside the context of CSCI-427/527 */
/* without consent of either the College of William & Mary or */
/* Pieter Peers. */
/******************************************************************/
#ifndef _IMAGE_H_
#define _IMAGE_H_
#include <string>
#include <memory>
#include <ostream>
#include "color.h"
class image {
public:
//////////////
// Typedefs //
//////////////
typedef color value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef std::unique_ptr<value_type[]>::pointer iterator;
typedef std::unique_ptr<const value_type[]>::pointer const_iterator;
typedef size_t difference_type;
typedef size_t size_type;
//////////////////
// Constructors //
//////////////////
image(size_type width=0, size_type height=0);
image(size_type width, size_type height, const_reference col);
image(const image& src);
image(image&& src);
virtual ~image(void) { _data.reset(); }
////////////////
// Inspectors //
////////////////
iterator begin(void);
const_iterator begin(void) const;
iterator end(void);
const_iterator end(void) const;
size_type size(void) const { return width()*height(); }
size_type width(void) const { return _width; }
size_type height(void) const { return _height; }
///////////////
// Operators //
///////////////
image& operator=(const image& src);
image& operator=(image&& src);
reference operator()(size_type x, size_type y);
const_reference operator()(size_type x, size_type y) const;
/////////////
// Friends //
/////////////
friend void swap(image& a, image& b) { a._swap(b); }
friend std::ostream& operator<<(std::ostream& s, const image& img)
{
s << "Image: (" << img.width() << ", " << img.height() << ")";
return s;
}
protected:
/////////////////////
// Private Methods //
/////////////////////
void _swap(image& img);
void _assign(const image& src);
private:
//////////////////////////
// Private Data Members //
//////////////////////////
size_type _width, _height;
std::unique_ptr<value_type[]> _data;
};
#endif /* _IMAGE_H_ */
|