FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   background image, sizing giving funny results.
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: background image, sizing giving funny results.  (Read 443 times)
Jeff Berg
Guest
Email
background image, sizing giving funny results.
« on: Jan 30th, 2003, 3:51am »

I have a jpg image that is 700x200 px.
 
I use this code to set the bg as per the previous thread on background images.
 
BImage bg;  
 
void setup()  
{  
  size(700,200);
  noBackground();  
  bg = loadImage("land.jpg");  
}  
 void loop(){  
  System.arraycopy(bg.pixels, 0, pixels, 0, width*height);  
}  
 
But I get an "Array index Out Of Bounds Exception"
 
 
But I found if I make the height 80 and the width 240, it works ok again. Is there some limit to the width and height using this method? Am I doing somehting wrong that I can't see? I;d like the bg to be 700x200!
 
 
 
 
BImage bg;  
 
void setup()  
{  
  size(240,80);
  noBackground();  
  bg = loadImage("land.jpg");  
}  
 void loop(){  
  System.arraycopy(bg.pixels, 0, pixels, 0, width*height);  
}  
 
 
??
 
Glen Murphy

WWW Email
Re: background image, sizing giving funny results.
« Reply #1 on: Jan 30th, 2003, 4:35am »

I tested your code with a self-made 700x200 jpg image and it worked fine. Check bg.width and bg.height to make sure the image is actually the full 700x200, maybe something got stuffed along the way.
 
Eloquence!
 
Jeff Berg
Guest
Email
Re: background image, sizing giving funny results.
« Reply #2 on: Jan 30th, 2003, 5:47pm »

I appreciate you taking the time to create a test! I Tested mine using the size trace you suggested. Indeed the program returned 240x80.
 
In the first test run of the program, I used a 240x80 jpeg image. I then resized that image to 700x200 and replaced the 240x80 image with this new larger image. This is when I was getting the exception errors.  
 
Interestingly enough, ANY jpeg I put into the data folder of the project and rename land.jpg seemed to inherit the 240x80 size. Some of the jpegs were 20x20, 700x100, 320x240, etc. But the program would insist they were 240x80 upon runtime.
 
I decided to delete the project and create a new project. Putting the 700x200 land.jpg that I used in the first project into this new projects data folder. I rewrote the script, and it worked fine.
 
Apparently the project was somehow caching the jpeg size from the first run of the project.
 
??
 
anyhow, it's working now, your idea to trace the size worked.
 
Thanks!
 
fry


WWW
Re: background image, sizing giving funny results.
« Reply #3 on: Jan 31st, 2003, 2:55pm »

hm, are you on a mac? i wonder if the images are getting cached.. also, were you testing in a browser, or just inside the p5 environment?
 
Glen Murphy

WWW Email
Re: background image, sizing giving funny results.
« Reply #4 on: Feb 3rd, 2003, 11:56pm »

FWIW, If I run a project in P5, change the images, and re-run, the old images would appear (and load much much faster).
 
I use a ?'+random(X) on the end of loadImage for http stuff to stop this.
 
fry


WWW
Re: background image, sizing giving funny results.
« Reply #5 on: Feb 4th, 2003, 4:11pm »

ah, good to know. most java vms have an image cache, which can be disabled. it was in a previous version of p5.. will have to get it back in there as it seems to have escaped..
 
fry


WWW
Re: background image, sizing giving funny results.
« Reply #6 on: Feb 14th, 2003, 2:37am »

a question.. having thought about ths a little.  
 
what would folks prefer: that images cache by default or that they don't?
 
for instance, in one thread we've got people doing video with piles of images and it only becomes usable once the images have cached, and on the other.. it makes it a little weird to have the old image stuck in the vm when the image file has changed.
 
unfortunately, i can only choose cache or no cache, i can't tell if the thing has changed since last download.
 
so, question is, what's the default behavior?
 
fry


WWW
Re: background image, sizing giving funny results.
« Reply #7 on: Mar 5th, 2003, 10:33pm »

images no longer cache by default in 0052. let us know if you're still having problems.
 
benelek

35160983516098 WWW Email
Re: background image, sizing giving funny results.
« Reply #8 on: Mar 6th, 2003, 3:56am »

seems nobody replied to ur question Fry... would there be a way to toggle caching from within a sketch?
 
-jacob
 
benelek

35160983516098 WWW Email
Re: background image, sizing giving funny results.
« Reply #9 on: Mar 6th, 2003, 4:21am »

ahh, i just saw the release notes for 52.
 
Pages: 1 

« Previous topic | Next topic »