This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.hpp
133 lines (118 loc) · 3.59 KB
/
Script.hpp
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef __prog_Script_hpp__
#define __prog_Script_hpp__
#include <string>
#include <fstream>
#include "Image.hpp"
namespace prog
{
class Script
{
public:
Script(const std::string &filename);
~Script();
void run();
private:
// Current image.
Image *image;
// Input stream for reading script commands.
std::ifstream input;
private:
// Private functions
void clear_image_if_any();
void open();
void blank();
void save();
/**
* @brief Implements "invert" command.
* @details The command "invert" switches every color to its inverse counterpart.
* @author João Mendes
*/
void invert();
/**
* @brief Implements "to_gray_scale" command.
* @details Transforms each individual pixel (r, g, b) to (v, v, v), where
* v = (r + g + b)/3.
* @author Joana Noites
*/
void to_gray_scale();
/**
* @brief Implements "replace" command.
* @details The command "replace r1 g1 b1 r2 g2 b2" replaces all
* (r1, g1, b1) pixels by (r2, g2, b2).
* @author Bruno Oliveira
*/
void replace();
/**
* @brief Implements "fill" command.
* @details The command "fill x y w h r g b" assign the color (r, g, b) to
* all pixels contained in the rectangle defined by top-left corner
* (x, y), width w and height h.
* @author João Mendes
*/
void fill();
/**
* @brief Implements "h_mirror" command.
* @details The command "h_mirror" mirrors the image horizontally.
* @author Bruno Oliveira
*/
void h_mirror();
/**
* @brief Implements "v_mirror" command.
* @details The command "v_mirror" mirrors the image vertically.
* @author Bruno Oliveira
*/
void v_mirror();
/**
* @brief Implements "add" command.
* @details The command "add filename r g b x y" copies all pixels from
* the image given in PNG file "filename" (except the ones with
* "neutral" color (r, g, b)) to the rectangle with top-left
* corner (x, y) of the current image.
* @authors Joana Noites & João Mendes
*/
void add();
/**
* @brief Implements "crop" command.
* @details The command "crop x y w h" crops the image to the rectangle
* defined by top-left corner (x, y), width w and height h.
* @author Bruno Oliveira
*/
void crop();
/**
* @brief Implements "rotate_left" command.
* @details The command "rotate_left" rotates the image to the left by
* 90 degrees.
* @author Joana Noites
*/
void rotate_left();
/**
* @brief Implements "rotate_right" command.
* @details The command "rotate_right" rotates the image to the right by
* 90 degrees.
* @author Joana Noites
*/
void rotate_right();
/**
* @brief Implements "median_filter" command.
* @details The command "median_filter ws" applies a median filter with
* window size ws >= 3 to the current image.
* @author Bruno Oliveira
*/
void median_filter();
/**
* @brief Implements "xpm2_open" command.
* @details The command "xpm2_open filename" reads an image stored in the
* XPM2 file with name filename.
* @author Bruno Oliveira & João Mendes
*/
void xpm2_open();
/**
* @brief Implements "xpm2_save" command.
* @details The command "xpm2_save filename" saves an image to a XPM2 file
* with name filename.
* @author Bruno Oliveira & Joana Noites
*/
void xpm2_save();
};
}
#endif