We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello list, i have this problem: i'd like to copy a portion of my screen into an image. both are different sizes. usually I use
myImage = get(x, y, w, h).
now I'd like to use pixels[] array to speed up a little the program.
loadPixels(); // load data from the screen
for (int i = 0; i < grab.width; i++) {
for (int j = 0; j < grab.height; j++) {
grab.pixels[i + j*grab.width] = pixels[i + j*grab.width];
}
}
grab.updatePixels(); // push data into grab image
image(grab, 500, 500);
What's wrong with this code?
thank you, Bruno
Answers
http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text
https://Processing.org/reference/copy_.html
"What's wrong with this code?"
Well, you should tell us... :-)
One missing thing is the coordinates of the grabbing, the x and y of the get() call. Something like
pixels[x + i + (y + j)*grab.width]
philho thanks for the hint.
i figure out with this:
still doubt to clean the code to make it more readable and put it in a class