//Pimage test
/* Trying to undersand Pimage
created a Pimage object named img
the idea is to acquire data from the Teensy
microcontroller and fill the img area.
line 27 fills the image with a stored jpg image
line 30 places the image in the 400x400 window at a specified location
if the location position is image(img,0,0)
the below example works fine. If you move the position
to image(img,75,75) the program does not work correctly.
Why?
*/
PImage img;
int i;
int x = 0;
int y = 0;
int loc;
void setup() {
size(400,400);
img = loadImage(“Test256.jpg”);
background(90);
//image(img,0,0);
image(img,50,50);
img.loadPixels();
textSize(24);
}
void draw() {
mousePos();
fillColor();
}
void mousePos() {
fill(50);
rect(185,360,50,25);
fill(255);
text(“mouseX”,100,380);
text(mouseX,190,380);
fill(50);
rect(340,360,50,25);
fill(255);
text(“mouseY”,250,380);
text(mouseY,340,380);
}
void fillColor() {
color c = img.get(mouseX,mouseY);
fill(c);
rect(0,350,50,50);
}