-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.cpp
48 lines (46 loc) · 1001 Bytes
/
image.cpp
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
#include "image.h"
Image::Image(string filename):PNG()
{
readFromFile(filename);
}
void Image::lighten(double amount)
{
for(unsigned i=0;i< width();i++)
{
for(unsigned j=0;j<height();j++)
{
HSLAPixel &p = getPixel(i,j);
p.l += amount;
p.l = (p.l>0) ? p.l:0;
p.l = (p.l<=1)? p.l:1;
}
}
}
void Image::saturate(double amount)
{
for(unsigned i=0;i< width();i++)
{
for(unsigned j=0;j<height();j++)
{
HSLAPixel &p = getPixel(i,j);
p.s += amount;
p.s = (p.s>0) ? p.s:0;
p.s = (p.s<=1)? p.s:1;
}
}
}
void Image::rotateColor(double angle)
{
for(unsigned i=0;i< width();i++)
{
for(unsigned j=0;j<height();j++)
{
HSLAPixel &p = getPixel(i,j);
p.h += angle;
while (p.h>360)
p.h=p.h-360;
while (p.h<0)
p.h=p.h+360;
}
}
}