We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › background problem under Linux
Page Index Toggle Pages: 1
background problem under Linux (Read 608 times)
background problem under Linux
Jun 14th, 2007, 3:46pm
 
Hallo!

I have the following problem:

I simply load an image and set it as background and always get the following exception:

----8<-----
java.lang.RuntimeException: background image must be the same size as your application
at processing.core.PGraphicsJava2D.background(PGraphicsJava2D.java:1051)
at processing.core.PApplet.background(PApplet.java:7928)
at Temporary_2607_5256.draw(Temporary_2607_5256.java:11)
at processing.core.PApplet.handleDisplay(PApplet.java:1355)
at processing.core.PGraphics.requestDisplay(PGraphics.java:564)
at processing.core.PApplet.run(PApplet.java:1450)
at java.lang.Thread.run(Unknown Source)
----8<-----

The same code works on windows.

A minimum example would be the following:

----8<-----
PImage bg;

void setup()
{
 size(200, 200);
 
 bg = loadImage("test.jpg");
}

void draw() {
background(bg);
}
----8<-----


Is this a known bug or a workaround ?

Many thanks,
LG
Georg

PS: I use processing 0124 Beta
Re: background problem under Linux
Reply #1 - Jun 14th, 2007, 3:46pm
 
and of course test.jpg is 200x200 ...
Re: background problem under Linux
Reply #2 - Jun 14th, 2007, 5:28pm
 
you're probably hitting this linux-specific bug:
http://dev.processing.org/bugs/show_bug.cgi?id=341

for now, you can use image(bg, 0, 0) at the beginning of setup.
Re: background problem under Linux
Reply #3 - Jun 15th, 2007, 9:40am
 
Thanks - okay, then I have to use image ...

Is this less efficient as background ?
(I am just curious ...)
Re: background problem under Linux
Reply #4 - Jun 15th, 2007, 2:19pm
 
generallly yes, though it depends on how it's used. if you need to call background() to clear the zbuffer (i.e. with P3D), then it's slower because you're replacing all the pixels twice.

actually, hopefully you can use set() instead of image() (though set() also needs a bounds fix check so it may have the same problem--another bug). set() is faster because it does a direct copy of the pixels (same as background()) rather than scaling/transforming the image.
Re: background problem under Linux
Reply #5 - Jun 15th, 2007, 2:50pm
 
Many thanks!

set is working and if I have problems I will use image Wink
Page Index Toggle Pages: 1