upscaling an image using Nearest-neighbor in processing

Viewed 105

While doing something like this in processing 3.5.4

void draw() {
  image(img.source, 0, 0, 50000, 50000);
}

The image comes out blurry. Is there a way I can do this using nearest-neighbor? The image is 1000 by 1000 pixels.

1 Answers

If it's the default (JAVA2D) renderer you're using with size() then

simply calling noSmooth() in setup() should do the trick.

If you use P2D you need to tell OpenGL to use nearest neighbour in setup():

((PGraphicsOpenGL) g).textureSampling(2);

(I learned this from Vallentin's answer)

Related