Background image doesn't load

I get the message: background image must be the same size as your application.

The image is 1000 x 1000. Checked that in Photoshop.

PImage BackgroundGradient;

void setup () {
  size (1000, 1000);
  smooth();
  noStroke ();

  // Load the background image
  BackgroundGradient = loadImage ("gradient.png");
}

void draw() {
  background (BackgroundGradient);
}

Working with Processing 4.4.4
MacStudio 2023
MacOS Sequoia 15.5

Hello @henk_lamers ,

Related post here:
Processing Java Background Bug - #2 by glv

Try:

  • Displaying image.
  • What is pixelDensity? Try setting it to 1
  • Use println() to display size of image after loading

Report back.

Reference:

This works on my W10 PC and loads an image from Wikipedia:

PImage BackgroundGradient;

void setup () {
  size (1000, 1000);
  smooth();
  noStroke ();

  // Load the background image
  BackgroundGradient = loadImage ("https://upload.wikimedia.org/wikipedia/commons/0/08/1000X1000-01.jpg");
}

void draw() {
  background (BackgroundGradient);
}

:)

1 Like

Hello glv

Setting the pixelDensity to 1 solved the problem.
println (width, height); gives me 1000 1000

Thanks for helping me out!

2 Likes

You are very welcome!