# Generating 8k images in P3D

**URL:** <https://discourse.processing.org/t/generating-8k-images-in-p3d/35545>\
**Category:** Coding Questions\
**Created:** [March 4, 2022, 12:49am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545 "2022-03-04T00:49:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@Raul](https://discourse.processing.org/u/Raul)\
**Post date:** [March 4, 2022, 12:49am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/1 "2022-03-04T00:49:52Z")

</div>

Hi!

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.

```auto
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");
}

```

Any idea would be more than welcome!!!

Best,  
r.-

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [March 5, 2022, 8:54pm UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/2 "2022-03-05T20:54:04Z")

</div>

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.”

```auto
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 );
}

```

---

<div class="post-metadata">

**Author:** ![Raul](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@Raul](https://discourse.processing.org/u/Raul)\
**Post date:** [March 6, 2022, 12:11am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/3 "2022-03-06T00:11:02Z")

</div>

Thanks scudly for your answer!

Note that your sketch size is (1920, 1080)

> [@scudly](#):
>
> `size(1920, 1080, P3D);`

if I save the screen with

```auto
void mouseClicked() {
  save("test.png");
}

```

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [March 6, 2022, 12:32am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/4 "2022-03-06T00:32:10Z")

</div>

use img.save(“test.png”); instead

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [March 6, 2022, 12:35am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/5 "2022-03-06T00:35:42Z")

</div>

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();

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [March 6, 2022, 1:26am UTC](https://discourse.processing.org/t/generating-8k-images-in-p3d/35545/6 "2022-03-06T01:26:10Z")

</div>

The effects you’re getting are moiré patterns caused by sampling errors. You can create other cool ones by rotating the image.

```auto
void draw() {
  float t = frameCount/120.;
  background(0);
  translate( width/2, height/2 );
  rotateX( 0.0317*sin(3.14159*t) );
  rotateY( 0.0409*sin(2.71828*t) );
  rotateZ( 0.03*sin( t ) );
  image( img, -0.5*img.width, -0.5*img.height );
}

```
