Not the same result with version 4.4.1 and 4.4.6 using "copy" function with PGraphics into PImage

Hello,

here’s a piece of code that doesn’t give the same result in versions 4.4.1 and 4.4.6.
The result is normal in 4.4.1, and the entire image is copied into the “Preview” variable.
With version 4.4.6, only the top-left corner is copied.

(Mac Intel version)

fred

PImage img; 
PGraphics Graphics; 
PImage Preview;
void setup() {

size(1000, 1000, P2D);
img = loadImage("sunset.jpg");  // Load the image into the program
Graphics = createGraphics(width, height, P2D);
}
void draw() {
Graphics.beginDraw();
Graphics.image(img, 0, 0, Graphics.width, Graphics.height);
Graphics.endDraw();
Preview = createImage(200, 200, RGB); 
/// This next line will copy the all Graphics into preview with version 4.4.1 
// and only a part of it with version 4.4.6 
Preview.copy(Graphics, 0, 0, width,  height, 0, 0, Preview.width,Preview.height); 
image(Preview, 0, 0, width,  height); 
}

Hi , I just found the solution .

This fix the problem

pixelDensity(1);

In fact in version 4.4.1, pixelDensity = 1 by default

and in version 4.4.6, pixelDensity = 2 by default

(MacBook Pro retina screen)

2 Likes

Hi!

How did you find the solution?

Please read topic below and share your feedback.

Related:

:)

1 Like

Hi @fredciel. Glad you found the solution! Just one thing I would clarify about your conclusion. The default pixelDensity is not determined by version number, but is dynamically determined depending on display density.

Hi,

I have the two versions installed on the same computer (macbook pro Intel version retina screen)

And at startup:
println(pixelDensity);

make 1 on version 4.4.1

make 2 on version 4.4.6

So my code was not working anymore on 4.4.6 until I set the pixelDensity to 1

Have a good day

Hi @fredciel,

Both you and @moon are correct.

Since Processing 4.4.3, the default pixelDensity() is no longer fixed at 1. Instead, it automatically matches your display’s resolution. On a Retina screen that often means 2, but the exact value depends on the display.

This change was made so sketches appear sharper on high-resolution screens without requiring extra setup. The trade-off is that some image functions, like copy(), may behave differently, as you noticed.

The issue is being tracked in issue #693 and a there is a fix in progress in PR #1145.

2 Likes