-
-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Most appropriate sub-area of Processing 4?
Image
Processing version
4.4.7
Operating system
MacOS
Bug description
When using .get() on a PImage or PGraphics layer, only data from the top left quadrant of the layer is retrieved, and it is scaled up. I tested this on an old sketch that used to use a buffer this way and I can confirm that it behaves improperly now.
Steps to reproduce this
-
Display image in a PGraphics Layer
-
(optional) Create PImage buffer of PGraphics layer with .get()
-
Use .get() on either the PGraphics layer or the PImage buffer and display the data. I illustrate this with a pixel grid below.
snippet
PImage img;
PGraphics imgLoad;
void setup() {
size(1080, 1080);
imgLoad = createGraphics(width, height);
img = loadImage("1.jpeg");
img.resize(width, height);
}
void draw() {
background(0);
imgLoad.beginDraw();
imgLoad.image(img, 0, 0, width, height);
imgLoad.endDraw();
PImage imgBuffer = imgLoad.get();
float tilesX = 150;
float tilesY = tilesX;
float tileW = ceil(width / tilesX);
float tileH = ceil(height / tilesY);
for (int x = 0; x < tilesX; x++) {
for (int y = 0; y < tilesY; y++) {
int px = int(x * tileW);
int py = int(y * tileH);
//CHANGE BETWEEN THESE OPTIONS TO SEE THE ISSUE:
color c = img.get(px, py); // Displays the full image
//color c = imgLoad.get(px, py); // Displays the top left quadrant of the image
//color c = imgBuffer.get(px, py); // Displays the top left quadrant of the image
push();
stroke(c);
fill(c);
rect(px, py, tileW, tileH);
pop();
}
}
}
Additional context
What it looks like with the bug:
Would you like to work on the issue?
No, I’m just reporting the issue
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working