Smoothing loadImage()

Hi,
I work with an image which is smooth
tempppp
source

but once I load and read it in Processing it looks like it loose some quality, see :
tempp

below is my code, all is in the setup() function.

 size( 700, 900);
  smooth(8);
  background(250);
  

  imageMode(CENTER);
  img = loadImage("img.png");
 image(img, xpos, ypos, w, h);
1 Like

Can we have the whole code to be able to run it home?

We don’t know the w and h value you are using.

yes :


PImage img = new PImage();
img = loadImage("../img.png");
imageMode(CENTER);
size(650, 1050);
smooth(8);
background(255);
int s = 40;

image(img, width/2, height/2, s * 640/100, s * 1000/100);

in fact it happens when I reduce the size,
when the size is the same (640*1000) no pb…

1 Like

I tried with the P2D renderer and the problem disappeared.

No need to add the smooth(8) line; the default behavior is smooth(2) and it should be enough.

If you can’t use the P2D renderer for some reasons, a workaround would be to create 2 or 3 versions of your image with photoshop or gimp to get different sizes and then depending of the size of the image you want to draw select the one that is the closest to avoid that problem.

Let us know how it goes! :slight_smile:

1 Like

tks for the feedback,
yes, I have reduce the img size before loading them.