-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathImage.h
110 lines (82 loc) · 2.55 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef IMAGE_H
#define IMAGE_H
#include "Pixel.h"
#include "lodepng.h"
#include <iostream>
#include <vector>
#include <string>
#include <exception>
#include <algorithm>
using namespace std;
class Image{
public:
unsigned int width, height;
vector <Pixel> pixels;
/*Default constructor*/
Image();
/*Constructor
width - width of image
height - height of image
pixels - vector of pixels for image. Must contains width*height pixels
Construct Image instance from pixels
*/
Image(int width, int height, vector <Pixel> pixels);
/*Constructor
width - width of image
height - height of image
Construct Image instance from width and height with white pixels
*/
Image(int width, int height);
/*Constructor
img - Image instance
Construct Image instance from another
*/
Image(const Image& img);
/*Constructor
filename - path to image
Construct Image instance from .png image file
*/
Image(string filename);
/*setPixel(Pixel pixel, unsigned x);
pixel - pixel for set
x - pos of pixel in flat array of pixels
Set pixel in pos x to pixel value
*/
void setPixel(Pixel pixel, unsigned x);
/*setPixel(Color c, unsigned x, unsigned y);
c - color
x - X pos of pixel in image
y - Y pos of pixel in image
Set color of pixel in pos (x,y) to c
*/
void setPixel(Color c, unsigned x, unsigned y);
/*setPixel(Pixel pixel);
pixel - new val for pixel
Set new val of pixel to pos of pixel
*/
void setPixel(Pixel pixel);
/*Pixel getPixel(unsigned x);
x - pos of pixel in flat array of pixels
return copy of pixel from image in pos x
Returned value: pixel from pos x
*/
Pixel getPixel(unsigned x);
/*Pixel getPixel(unsigned x, unsigned y);
x - X pos of pixel in image
y - Y pos of pixel in image
return copy of pixel from image point (x,y)
Returned value: pixel from point (x,y)
*/
Pixel getPixel(unsigned x, unsigned y);
/*vector <Pixel> getPixels();
return copy of pixels from image
Returned value: flat array of image pixels
*/
vector <Pixel> getPixels();
/*outputImage(string filename);
filename - path to image
save image into disk to path
*/
void outputImage(string filename);
};
#endif