A
Alexandre
public Contenu()
{
super();
setVisible(true);
setBounds(50,50,1024,768);
setDoubleBuffered(true);
Toolkit tk = Toolkit.getDefaultToolkit();
fond = tk.getImage("solgalactic.jpg");
MediaTracker mt = new MediaTracker(this);
mt.addImage(fond, 0);
try{mt.waitForAll(); } catch(Exception e){e.printStackTrace();}
int[] pix = new int[fond.getWidth(this)*fond.getHeight(this)];
PixelGrabber pg = new PixelGrabber(fond, 0, 0,
fond.getWidth(this),fond.getHeight(this), pix, 0,
fond.getWidth(this)*fond.getHeight(this));
//the bug comes in this try catch block
try{pg.grabPixels();}catch(ArrayIndexOutOfBoundsException
e){e.printStackTrace();}catch(Exception e){e.printStackTrace();}
}
While executing the previous code I get this blocking uncaught error.
Uncaught error fetching image:
java.lang.ArrayIndexOutOfBoundsException: 786432
at java.awt.image.PixelGrabber.setPixels(PixelGrabber.java:563)
at sun.awt.image.PixelStore32.replayLines(PixelStore32.java:41)
at sun.awt.image.PixelStore.replay(PixelStore.java:224)
at sun.awt.image.PixelStore.replay(PixelStore.java:153)
at sun.awt.image.InputStreamImageSource.updateFromStore(InputStreamImageSource.java:282)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:235)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:221)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:189)
can anyone help me ?
{
super();
setVisible(true);
setBounds(50,50,1024,768);
setDoubleBuffered(true);
Toolkit tk = Toolkit.getDefaultToolkit();
fond = tk.getImage("solgalactic.jpg");
MediaTracker mt = new MediaTracker(this);
mt.addImage(fond, 0);
try{mt.waitForAll(); } catch(Exception e){e.printStackTrace();}
int[] pix = new int[fond.getWidth(this)*fond.getHeight(this)];
PixelGrabber pg = new PixelGrabber(fond, 0, 0,
fond.getWidth(this),fond.getHeight(this), pix, 0,
fond.getWidth(this)*fond.getHeight(this));
//the bug comes in this try catch block
try{pg.grabPixels();}catch(ArrayIndexOutOfBoundsException
e){e.printStackTrace();}catch(Exception e){e.printStackTrace();}
}
While executing the previous code I get this blocking uncaught error.
Uncaught error fetching image:
java.lang.ArrayIndexOutOfBoundsException: 786432
at java.awt.image.PixelGrabber.setPixels(PixelGrabber.java:563)
at sun.awt.image.PixelStore32.replayLines(PixelStore32.java:41)
at sun.awt.image.PixelStore.replay(PixelStore.java:224)
at sun.awt.image.PixelStore.replay(PixelStore.java:153)
at sun.awt.image.InputStreamImageSource.updateFromStore(InputStreamImageSource.java:282)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:235)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:221)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:189)
can anyone help me ?