pixelDensity() not working with exported application

edited February 2018 in Using Processing

This is a pretty straight forward question (though who knows if the answer is also straight forward?). I'm using pixelDensity(displayDensity()) in order to compensate for a high density display. It works just fine when run from the IDE, but once I've built the application it gets totally ignored and just sets the pixel density to 1.

I've tried hard coding the value to pixelDensity(2) to see if that worked, but it also has no effect.

Let me know if I'm doing something wrong, or if this function is only meant to be used in the editor.

Thanks!

Answers

  • I believe it is use in retina displays on macs so I have read in other posts in the last few months. Not sure if you can use it in other systems. What do you mean you want to compensate for a high density display? If I draw a 100x50 rectangle in a PC and in a tablet, they will have different "physical" dimensions when it is displayed and this is because of the density definition of each display.

    I am curious about answers from other forum goers.

    Kf

  • edited February 2018

    @kfrajer my windows laptop has a high dpi display and runs some software at twice the resolution which means everything is half the size (text, UI elements, etc).

    More info: https://tinyurl.com/y6wy7zz5

    A lot of software is compensating for it by scaling stuff up to fit (Photoshop, Maya, Chrome, etc). I imagine they added something similar to what I'm trying to do which is to set the pixel density to match the display density of the computer that the application is running in.

  • bump

    Does anyone have any ideas for this?

  • Have you checked whether this is a known issue, and filed a bug if not? If it works fine in the IDE but not on export then it sounds like a bug. Test code and specifying your exact Windows platform would help.

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

  • @jeremydouglass thanks so much for the reply.

    I don't see it in the known issues nor have I filed a bug report, but I'll go ahead and do that.

    Here is some test code for you to try:

    void setup()
    {
      size(400, 400);
      pixelDensity(2);
    
      rectMode(CENTER);
    }
    
    void draw()
    {
      rect(width/2, height/2, 150, 150);
    }
    

    I'm honestly not sure what this will do if you don't have a high dpi monitor, but I'm guessing it should "scale" it to 800x800 px. I've hard coded the pixel density to 2 for the simple reason that those are the results I want to test, but if you have a high dpi monitor you can change it to pixelDensity(displayDensity()) to test.

    This code works just fine in my editor but once it's exported it no longer achieves the correct pixel density.

    Thanks again!

  • @deciduous Can you check what values you get in your sketch for width vs. displayWidth when using pixelDensity(2); Also I notice you said:

    I'm using pixelDensity(displayDensity()) in order to compensate for a high density display

    Can you post your settings() and setup() method? If you are making the above call, are you expecting processing detecting for you if you are in a higher pixel density environment? Based on the following:

    https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L1129

    I can see the Windows & Linux section needs some work.

    Kf

  • @kfrajer width and displayWidth do not change when using pixelDensity(2).

    Yes, I am expecting processing to detect whether or not the monitor has a high density display. As I said before, it detects this just fine when run from the editor.

    Don't know why I didn't think about this before, but I wrote some debug text to the screen using displayDensity():

    text(displayDensity(), 100, 100);

    This draws a 2 to the window when running from the editor, and a 1 when running the executable. I'm thinking this is an issue with the library rather than the way I've written it.

  • Answer ✓

    Consider opening a ticket in github. Provide some sample code, short description and a link to this forum and hopefully somebody will hear soon from the community there.

    Kf

  • @kfrajer and @jeremydouglass, thanks for all your help. I really appreciate it.

    I've submitted a ticket like you both suggested:

    https://github.com/processing/processing/issues/5414

    Hopefully I will hear back soon!

  • edited February 2018 Answer ✓

    As per discussion on issue 5414, it looks like detection is currently not supported on Win/Linux - only manually setting density.

    Sorry, for now the density detection works only on Mac, on Win/Linux only when run from the editor. You can manually tell the sketch which screen density should be allowed

Sign In or Register to comment.