Filtering on image resize

ch3ch3
edited October 2015 in How To...

I want to scale up a PImage or a PGraphics ten times or more, but rather than a smooth interpolation, I want none so the pixels appear likes big blocks. I tried to run the noSmooth() function before the image() or scale()/.resize(), but I didn't see any difference in the result.

Any ideas?

Answers

  • Version of processing?

    What does your size() say?

    (Answer depends on the renderer and version)

  • For the time being I haven't specified a rendered, so my size function is like: size( 800, 600 );

    I ended up manually drawing squares, which is ok for 10x10 pixel images that I am currently working on. But I definitely want to find out about the filtering options.

    thank you

  • Them tell us the processing version!

    (The default renderer, the one it uses if you don't specify one, which you haven't, changes with version so we need both bits of information)

  • sorry I skipped that bit. I am still at 2.2.1

  • Answer ✓

    ah, ok, i don't have 2.2.1 here but...

    http://forum.processing.org/two/discussion/comment/22761/#Comment_22761

    this works in v3

    PImage donkey;
    
    void setup() {
      size(300, 300, P2D);
      donkey = loadImage("donkey.gif");
      ((PGraphicsOpenGL)g).textureSampling(3);
      noLoop();
    }
    
    void draw() {
      background(0);
      image(donkey, 0, 0, width, height);
    }
    

    where donkey.gif is a 16x16 original image

  • ah super, I will give it a try

    thanks a lot koogs

  • After a bit of time I got to try out and unfortunately it doesn't work for the javaScript mode (v2.2.1) that I need it for. I tried both resizing the image as well as calling the scale() function before drawing the image and both give a smoothed version.

    Searching online I came across this javascript forum talking about the same issue, but I think they managed to fix it because they are dealing with a texture rather than an image.

    http://www.html5gamedevs.com/topic/11601-problem-with-texture-sampling-mode/

    Any other ideas? thank you

Sign In or Register to comment.