Image quality (pixel image is blurry)

edited March 2017 in Python Mode

Hi, I'm back with another question:

Is there a way to have an image be drawn without it becoming blurry? I am just drawing an 8x8 png image, and since the game i'm making is completely adapting the interface with the screen size, I have to make the image bigger. I could just resize the image to, like, 128x128, but I since I think displaying an 8x8 image is easier, I'd rather like to use that.

I am now using

image(ImgPowerupPoint, height/2, height/2, height/2, height/2)

for an 8x8 image, and it becomes pretty blurry (it is a red 8x8 sphere, as far as that can still be called a sphere): IMG_24032017_203337_0

I am also having problems with looping a certain sound, but that is not relevant in this topic and I don't think people would be eager to try to help since my code is already 636 lines long...

Kind regards, OrOrg

Tagged:

Answers

  • I don't use python but in java mode it's

    smooth(0);

    in setup()

  • Sorry for the late response. I tried it and it works, but it only works when I put the noSmooth() option in setup, which is probably how it should work. However, The problem is that my buttons and everything else also become noSmooth, then. Is there a way to only have the images display in a noSmooth() way? For example, I tried putting noSmooth() in front of the image(..., ..., ...) line, which didn't work.

  • edited March 2017

    @OrOrg -- when you tried using noSmooth in draw did you remember to turn smoothing back on after? (not tested)

    noSmooth();
    image(ImgPowerupPoint, height/2, height/2, height/2, height/2);
    smooth();
    

    EDIT: This was a bad idea. In Java mode, this generates the error:

    smooth() and noSmooth() cannot be used in the same sketch

  • I put your line of code in the program, but it did not work. It might be because I put it in a method in a class definition, but that is just where it should be.

    I tried putting it in a normal fuction definition as well, but it didn't work either. Is it possible to change that smoothness outside of setup()?

  • Does the Processing.py test sketch work for you? If you put it in a simple test draw(), does it work? If you put it in a simple test class, does it work?

    http://py.processing.org/reference/noSmooth.html

    If those all work, you may need to share your code for more detailed feedback. This could by a python-specific problem, or it could just be a bug.

  • background(0)
    noStroke()
    smooth()
    ellipse(30, 48, 36, 36)
    noSmooth()
    ellipse(70, 48, 36, 36)
    

    I tried several different cases:

    (1) I tried to put the above mentioned part of code in a new, empty sketch, not enclosed in the setup() function. Result: The ellipses were both drawn smoothly.

    (2) I tried to put the above mentioned code in a new, empty sketch, but this time I did put it in the setup() function. Result: The ellipses were both drawn noSmooth-ly.

    (3) I tried the same, but now I put the code in the draw() function. Result: The ellipses were both drawn smoothly.

    It's most probably a bug; the behavior is pretty inconsistent. When I put it in the setup() function, only then is stuff drawn noSmooth-ly, but everything is drawn that way, it doesn't matter if the smooth() or noSmooth() statements are executed before or after the ellipse()...

    And when I put it somewhere else, nothing happens.

  • Please report these results as a bug, here:

    https://github.com/jdf/processing.py/issues

  • Very well then, I have posted it on the github issue tracker and linked to this thread as well.

    Thanks for the help!

  • edited March 2017 Answer ✓

    https://github.com/jdf/processing.py/issues/251

    An attempt to do what you're doing in Java mode results in smooth() and noSmooth() cannot be used in the same sketch, so Python Mode should detect the same problem and react the same way.

  • That's rather unfortunate. Well, I'll just stick with 128x128 images then.

  • edited December 2017

    @OrOrg I made myself a method that resizes an image but keeps the size of the original pixel relative to the image. With this I resized some sprite sheets of minecraft :p guess this thread is already forgotten

Sign In or Register to comment.