-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfo.txt
31 lines (26 loc) · 807 Bytes
/
info.txt
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
An m×n matrix has m rows and n columns.
M = rows
N = columns
// row iteration
for row in range(img.getHeight()):
for col in range(img.getWidth()):
p = img.getPixel(col, row)
newred = 255 - p.getRed()
newgreen = 255 - p.getGreen()
newblue = 255 - p.getBlue()
newpixel = image.Pixel(newred, newgreen, newblue)
img.setPixel(col, row, newpixel)
// column iteration
// Loop through every pixel column
for (int x = 0; x < width; x++) {
// Loop through every pixel row
for (int y = 0; y < height; y++) {
// Use the formula to find the 1D location
int loc = x + y * width;
if (x % 2 == 0) { // If we are an even column
pixels[loc] = color(255);
} else { // If we are an odd column
pixels[loc] = color(0);
}
}
}