-
Notifications
You must be signed in to change notification settings - Fork 11
/
Image.h
66 lines (50 loc) · 1.47 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Image.h
//
// Author: Robert Crandall
//
// Generic, templated Image class
// Contains pseudo 2d array of type T, and functions
// for memory management
#ifndef IMAGE_H
#define IMAGE_H
#include <assert.h>
template <typename T>
class Image
{
public:
// Constructors
Image();
Image(unsigned int nr, unsigned int nc);
// Destructor; calls Free()
~Image(){Free();}
// Free memory allocated by this class
void Free();
// Set every pixel in the image to a given value
void Set(T val);
// Reallocate memory for a certain size image
void Allocate(unsigned int nr, unsigned int nc);
// Return a sub-image of current image
Image<T>* subImage(unsigned int rowStart,
unsigned int colStart,
unsigned int rowEnd,
unsigned int colEnd);
// Copy data from another image of the same type,
// resizing if necessary
void CopyFrom(const Image<T>* imageIn);
// Copy data from an image of smaller or equal size
// into this image, starting at a given row/col index
void CopyFrom(const Image<T>* imageIn,
unsigned int rowStart,
unsigned int colStart);
// Accessors
T** data() const {return m_Data;}
unsigned int nRows() const {return m_nRows;}
unsigned int nCols() const {return m_nCols;}
private:
// Image data
T** m_Data;
// Image info
unsigned int m_nRows;
unsigned int m_nCols;
};
#endif