Display one row of pixels out of two
in
Programming Questions
•
6 months ago
Hi,
I loaded an image and was able to play with the location of its pixels(yeah!).
Now I would like to display only one row of pixels out of two.
Let's say I have :
1st row
2nd row
3rd row
4th row
5th row
...
It would become :
1st row
3rd row (instead of the second row)
5th row (instead of the fourth row)
...
I don't want any spaces between the rows, I really want the next line to replace the previous one.
I believe I have to play with the indexes in the array of pixels but I am not sure how... all ideas welcomed!
Here is what I have so far :
PImage img;
int loc;
void setup() {
size(504,360);
noStroke();
img = loadImage("test1parr.jpg");
image(img,0,0);
loadPixels();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y+= 2) {
pixels[y*width+x] = loc;
}
}
updatePixels();
}
void draw() {
/*
for (int j = 0; j < pixels.length; j+= 503) {
for (int i = 0; i < pixels.length; i++) {
println("y equals "+ j + "x equals " + i);
}
}
*/
}
1