+ 3

How to adapt images' size to Display size in Java ?

I'd like to code a game that runs fullscreen, but if the running display isn't 1080p 16x9, there are going to be errors. I've tried : PImage example; void setup() { example = loadImage("example.jpg"); fullScreen(); scale (displayWidth/1920, displayHeight/1080); } void draw() { image(example, 0, 0); } with the example image being 1920x1080, but when I've tried turning my screen into 1280x720 this didn't work. I'm a beginner. I code on Processing. Thanks for your help 🙂

5th Jun 2017, 12:08 PM
Baptiste
Baptiste - avatar
10 ответов
+ 1
processing don't allow to set an image as background if is not the same size as the window, but you could load an image in PImage and use the resize method , then set the PImage as background search for the reference of the sintax of PImage and resize () in the processing foundation page
16th Jun 2017, 4:51 AM
Pablo De Laforé
Pablo De Laforé - avatar
+ 2
Thank you very much dude 😀 I'll try it asap !
16th Jun 2017, 5:06 AM
Baptiste
Baptiste - avatar
+ 2
@Pablo De Laforé There's no resize() method in the documentation, and when I type it it says "The function " resize() " does not exist" I use Processing 3.3.4 which I think is the latest
17th Jun 2017, 3:39 PM
Baptiste
Baptiste - avatar
+ 2
You're right, when I go to PImage's Doc there's resize() in the attached methods. You got the answer for everything that's unbelievable 😂 GG and thank you for help !
17th Jun 2017, 3:52 PM
Baptiste
Baptiste - avatar
+ 1
OK my bad idk what I've done 😂😂
17th Jun 2017, 3:42 PM
Baptiste
Baptiste - avatar
+ 1
No problem 😆
17th Jun 2017, 3:43 PM
Pablo De Laforé
Pablo De Laforé - avatar
+ 1
Well I tried to go in my Doc and CTRL+F resize but it still doesn't work for some reason, so I'll fav your link 😜
17th Jun 2017, 3:45 PM
Baptiste
Baptiste - avatar
+ 1
probably because it's inside PImage class and not displayed in the main index reference
17th Jun 2017, 3:49 PM
Pablo De Laforé
Pablo De Laforé - avatar
+ 1
haha not for everything but it's nice to be helpful
17th Jun 2017, 4:02 PM
Pablo De Laforé
Pablo De Laforé - avatar
17th Jun 2017, 3:41 PM
Pablo De Laforé
Pablo De Laforé - avatar