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 › Arrayindexoutofbounds //HELP ME PLEASE!
Page Index Toggle Pages: 1
Arrayindexoutofbounds //HELP ME PLEASE! (Read 979 times)
Arrayindexoutofbounds //HELP ME PLEASE!
Feb 4th, 2010, 1:21am
 
I am new to processing and have been working on this program for a school project.  The due date has past and I am desperate.  Any help would be greatly appreciated. Here is the code.

//Joseph Dusseault
//import a background image
//Important quicktime movie , loop it, and draw
//using it.  Press the mouse button and a PDF file of your drawing
//will be saved
//this program can serve many different purposes, it makes availible
//a way in which to portray video in a new and exciting manner.
//For example, if a person had a video clip of themselves in a basletball game
//or giving a speech, they coult create a representation of that event within
//this program that could then be used for a keep sake, an advertisement, or
//any number of other things.

import processing.video.*;//command to play quicktime video

Movie myMovie;

void setup() {

 import processing.pdf.*;//creates a pdf file representing the application
                         //window

{
 size(1000, 850);//size of window and pdf



 beginRecord(PDF, "everything.pdf");//PDF file is created, lable it as
                                    //you wish
}

PImage b;//load image
        // Images must be in the "data" directory to load correctly
b = loadImage("Project-1bck-grd-img.jpg");//select background image
image(b, 0, 0);

 
 // Load and play the video in a loop, must be in "data" directory
 myMovie = new Movie(this, "8x-quicktime-#1.mov");//select quicktime movie
 myMovie.loop();
 
}

void movieEvent(Movie myMovie) {
 myMovie.read();
}
//this function is what enables you to draw using the movie being played
void draw() {
 tint(255, 20);
 image(myMovie, mouseX-myMovie.width/2, mouseY-myMovie.height/2);//THE PROBLEM SEEMS TO BE HERE! ON CODE ABOVE
}
//tell the program to capture PDF, close the program, and save PDF
void mousePressed() {
 endRecord();
 exit();
}
//sometimes the program experiences an error.  
//when this happens, try moving the window to a different location
//on the screen while it is running,then
//stop running the program and try again

ArrayindexOutOfBoundsException: Coordinates out of bounds!

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
     at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.
java:404)
     at processing.core.PGraphicsJava2D$ImageCache.update(PGraphicsJava2D.java:922)
     at processing.core.PGraphicsJava2D.imageImpl(PGraphicsJava2D.java:809)
     at processing.core.PGraphics.image(PGraphics.java:2182)
     at processing.core.PApplet.image(PApplet.java:7279)
     at Project_1.draw(Project_1.java:68)
     at processing.core.PApplet.handleDraw(PApplet.java:1425)
     at processing.core.PApplet.run(PApplet.java:1327)
     at java.lang.Thread.run(Thread.java:619)


Re: Arrayindexoutofbounds
Reply #1 - Feb 4th, 2010, 2:02am
 
When you report an error, include the full stacktrace, so we can see the context, and where the error happened.

Note: apparently it doesn't trouble Processing, but all the imports should be at the top of the .pde file.
Re: Arrayindexoutofbounds //HELP ME PLEASE!
Reply #2 - Feb 4th, 2010, 6:56pm
 
public  void setDataElements(int x,  int y, Raster inRaster)

Stores the data elements for all bands at the specified location. An ArrayIndexOutOfBounds exception will be thrown at runtime if the pixel coordinate is out of bounds. A ClassCastException will be thrown if the input object is non null and references anything other than an array of transferType.

There you have it!  Your pixel coordinate is out of bounds.  What happens if you use 0,0 instead of mouseX-myMovie.width/2, mouseY-myMovie.height/2 ?
Page Index Toggle Pages: 1