Pixel get() buggy in Processing 4.1?

I am attempting to get the color of each pixel in an image. Using the get() function with coordinates yield garbage values or strange results (only a single color from the image rather than the color at a particular x,y point).
The image shows up fine. If I use the pixels array I can get the colors correctlu, but not the get() function.

PImage img;
size(400, 300); //4:3
img = loadImage("myjpg.jpg");
image(img, 0,0, width, height);

// draw a square every 5 pixels with the fill color the same as a pixel at that point
for(int i=0; i < width*height; i+=5){
  int x = i%width;
  int y = floor(i/width)*5;
  color c = get(x, y);  // <--- have tried both img.get(x,y) and get(x,y) based on reference. 
  fill(red(c), green(c), blue(c), 255); //same results as fill(c)
  rect(x, y, 20, 20);
}

Is this a bug or am I doing something incorrectly?

Hello @Jaz,

This works with Processing 4.2:

PImage img;
size(800, 400);
String url = "http://learningprocessing.com/code/assets/sunflower.jpg";
img = loadImage(url);
img.resize(400, 400);
image(img, 0, 0);

// draw a square every 5 pixels with the fill color the same as a pixel at that point
for(int i=0; i < width*height; i+=10)
  {
  int x = i%img.width;
  int y = floor(i/img.height)*10;
  color c = img.get(x, y);  // get() or img.get () works!
  //fill(red(c), green(c), blue(c), 255); //same results as fill(c)
  fill(c);
  rect(x+width/2, y, 10, 10);
  }

I suspect that you were overwriting the pixels with a rect() and then using get().

:)