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 & HelpSyntax Questions › Bug/limit dealing with image sizes
Page Index Toggle Pages: 1
Bug/limit dealing with image sizes? (Read 1383 times)
Bug/limit dealing with image sizes?
Apr 23rd, 2005, 11:37am
 
I'm working from the included Linear Image example.

The code has the following lines, among other things:
int[] aPixels = new int[200*200];
size(200, 200);
a = loadImage("florence03.jpg");

Since florence03.jpg is 200x200 px itself, it seems safe to assume that to deal with any other size image, I only have to modify those first two lines to match whatever the dimensions of my new image are, right?


So, I change the dimensions to 728x90(don't ask), feed it a matching image, and after working to the bottom of the image, instead of reversing direction, Processing barfs up:

java.lang.ArrayIndexOutOfBoundsException: 65520      at Temporary_6528_815.draw(Temporary_6528_815.java:50)      at
processing.core.PApplet.display(PApplet.java:1070)      at processing.core.PGraphics.requestDisplay(PGraphics.java:362)    at
processing.core.PApplet.run(PApplet.java:916)      at
java.lang.Thread.run(Unknown Source)

I've taken the same image and regenerated it as a GIF and JPG, also made sure they're fairly plain(no interlacing/progressive, etc), with no improvement.

Next, I leave my image in there, but force aPixels and the window size back to 200x200 and everything is suddenly fine, although the image is obviously mangled when I hold a key down.

So, let's assume that the problem is still somehow my image. I go back to loading florence03.jpg at 200square, and everything is back to normal.
I force aPixels and size to 400x400, still no problem, although it chugs.
Then I force aPixels and size to 728x90(still using florence03.jpg), and the error above reappears.
I actually resize florence03 to 728x90, and the problem reoccurs.

I think I've safely established that the images aren't the problem. I haven't touched a single thing beyond the lines above. Am I missing something that should be obvious? Please keep in mind that this is pretty much the first thing I've tried. It seemed simple enough *grin*
Re: Bug/limit dealing with image sizes?
Reply #1 - Apr 23rd, 2005, 5:12pm
 
sounds like ou have your loop set up incorrectly.

728x90 = 65520, which means that since you're getting an ArrayIndexOutOfBoundsException at 65520 that you're running off the edge of the array. (an array that has length 65520 uses indices 0 through 65519)

my guess would be that your loop or math is just a little off. for instance, are you using the width and height of the screen or the image when walking through the array?

also, make sure size() is the very first thing in your code, just to get in that habit.
Page Index Toggle Pages: 1