-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilters.java
More file actions
54 lines (46 loc) · 1.74 KB
/
Filters.java
File metadata and controls
54 lines (46 loc) · 1.74 KB
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
import java.awt.Color;
import java.util.Random;
public class Filters {
public int frameWidth;
public int frameHeight;
public Random rand = new Random();
public Filters(int frameWidth, int frameHeight) {
this.frameWidth = frameWidth;
this.frameHeight = frameHeight;
}
final int spacesBetweenLines = 7;
final int widthOfBlackLine = 1;
final int RGB_BLACK = new Color(0, 0, 0).getRGB();
public int[] applyTVFilter(int[] pixels) { //black lines
for(int pos = 0; pos < frameHeight; pos += spacesBetweenLines) {
int index = 0;
while(index < widthOfBlackLine) {
for(int i = 0; i < frameWidth; i++) {
pixels[(pos * frameWidth) + i] = RGB_BLACK;
}
index++;
if(index != 0 || index != widthOfBlackLine) {
pos++;
}
}
}
// for(int pos = 0; pos < pixels.length; pos++) {
// Color tempColor = new Color(pixels[pos]);
// int colorRandomizerInt = getRandomInt(-5, 10);
// tempColor = new Color(truncateValue(tempColor.getRed()+colorRandomizerInt), truncateValue(tempColor.getGreen()+colorRandomizerInt), truncateValue(tempColor.getBlue()+colorRandomizerInt));
// pixels[pos] = tempColor.getRGB();
// }
return pixels;
} // end of applyTVFilter
private int truncateValue(int value) {
if(value < 0)
return 0;
else if(value > 255)
return 255;
else
return value;
}
private int getRandomInt(int min, int max) {
return (rand.nextInt(max)+min);
}
}