We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!
I'm trying to resize an image and display it without any smoothing (mipmap, bicubic, linear or other).
The point is i want it to stay "pixelated" (sharp pixels). See picture below...
I'm using P2D.
Any ideas?
Answers
Do you have example code?
P2D has smoothing on by default. Call noSmooth():
Alternately, loop through the pixels array of your source image and copy a subset of pixels to a new image -- for example, every other column and every other row to resize by x1/2, or double-copy each pixel and each row to resize by x2.
I have tested noSmooth(), unfortunatly it doesn't work. I also tried hint(DISABLE_OPENGL_2X_SMOOTH), but that doesn't work either.
I guess your second suggestion is the one i have to do. Manually scaling it.
some discussion here:
https://forum.processing.org/two/discussion/comment/22759/#Comment_22759
involves setting the texture sampling value
if 3 doesn't work, try lower values.
(0 and 1 don't work. 2 does. still can't find a reference for those numbers though)
ok, here
https://github.com/processing/processing/blob/0abee5af6ad3b11cf2b73bb794b8a97c157c4762/core/src/processing/opengl/Texture.java#L54
The following code it's a quick and dirty method to double an image without interpolation:
Hope this helps a bit :)
Thanks for your answers!
The "((PGraphicsOpenGL)g).textureSampling(2);" work as i expect if you scale the image "on the fly" (with the image() function) but doesn't work with resize().
I suppose that means that it need to be rescaled every frame, but on the other hand i recon the hardware does it if one use P2D.