-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSepia.java
More file actions
26 lines (23 loc) · 881 Bytes
/
Copy pathSepia.java
File metadata and controls
26 lines (23 loc) · 881 Bytes
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
import java.awt.Color;
/**
* Write a description of class InvertColour here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Sepia implements PerPixelFilter
{
public Color applyFilter(Color source)
{
int colorRed = Math.round((source.getRed() * 0.393f) + (source.getGreen() * 0.769f) + (source.getBlue() * 0.189f));
int colorGreen = Math.round((source.getRed() * 0.349f) + (source.getGreen() * 0.686f) + (source.getBlue() * 0.168f));
int colorBlue = Math.round((source.getRed() * 0.272f) + (source.getGreen() * 0.534f) + (source.getBlue() * 0.131f));
if(colorRed > 255)
colorRed = 255;
if(colorGreen > 255)
colorGreen = 255;
if(colorBlue > 255)
colorBlue = 255;
return new Color(colorRed, colorGreen, colorBlue);
}
}