I have a program that generates images, displays them (in a 3D space) and saves them.
There is no problem if the images’ resolution is up to 4k, since my screen is 4k. But I can’t do the same with, for example, 8k images. It seems that, in 3D mode, the size of the sketch cannot be bigger than the screen size.
I am interested in displaying the images on the screen before saving them, since the aliasing creates interesting artifacts (the option ‘Antialiasing - Gamma correction’ in my NVIDIA is ‘Off’).
There are a lot of HDMI dummy plug 4k display emulators, but I haven’t been able to find any 8k.
This code is an example of what I am trying to do.
PImage img;
void settings() {
size(7680, 4320, P3D);
}
void setup() {
background(0);
img = createImage(7680, 4320, RGB);
// generation of a 'random' image
img.loadPixels();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int loc = x + y * width;
img.pixels[loc] = color(random(0, 256));
}
}
img.updatePixels();
// translate and draw the image to the screen
translate(0, 0, -30);
image(img, 0, 0);
// saves the image from the display window
save("test.png");
}
Your program runs fine on my machine. I’m able to generate images up to 16k on a computer that’s around seven years old, running linux, with an nvidia GTX 750 Ti. I only have a 2k monitor, but your program pops up a window that is bigger than the screen and I can move it around to the extent that the window bar stays on the screen to give me a handle.
This runs fine on my machine, though you have to wait a while at startup for it to fill up the image pixels. Note that I changed it to use img.width and img.height to fill the pixel array.
What errors or wrong behavior are you getting?
I can increase the image size up to 16384x16384. At 16385 I get an error message “Image width and height cannot be larger than 16384 with this graphics card.”
PImage img;
void settings() {
size(1920, 1080, P3D);
}
void setup() {
background(0);
img = createImage(15360, 8640, RGB);
//img = createImage(7680, 4320, RGB);
// generation of a 'random' image
img.loadPixels();
for (int x = 0; x < img.width; x++) {
for (int y = 0; y < img.height; y++) {
int loc = x + y * img.width;
img.pixels[loc] = color(random(0, 256));
}
}
img.updatePixels();
// translate and draw the image to the screen
//translate(0, 0, -30);
//image(img, 0, 0);
// saves the image from the display window
//save("test.png");
}
void draw() {
float t = frameCount/120.;
background(0);
translate( width/2, height/2 );
translate( img.width*0.5*(cos(2*t)-1), img.height*0.5*(sin(3*t)-1), -600+600*sin(t) );
image( img, 0, 0 );
}
the result is a (1920, 1080) image, not a 16k image.
This is the point. I display the image in the screen to capture the aliasing artifacts (because of the P3D mode). If I try images greater than 4k I get the message ‘The sketch has been automatically resized to fit the screen resolution’.
Another approach is to calculate how the image looks in a P3D space without really display it. But I have no idea how this can be done.
You can also use a PGraphics of whatever output size you want, create a noise image of whatever size you want, and use pg.image( noiseImage, 0, 0, someWidth, someHeight ); onto it and then pg.save();