Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. File newFile = null;
  2. BufferedImage oldImage = null;
  3. BufferedImage newImage = null;
  4. String fileName = new String((args[0]));
  5.  
  6. String newFileName = new String(fileName.replaceFirst(".png", "-tiled.png"));
  7.  
  8. try{
  9. oldImage = ImageIO.read(new File(fileName));
  10. System.out.println("Reading Complete");
  11. }
  12. catch(IOException e) {
  13. System.out.println("Error: "+ e);
  14. }
  15.  
  16. int width = oldImage.getWidth();
  17. int height = oldImage.getHeight();
  18. newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  19.  
  20. int imagePixels [][] = new int [height][width];
  21. for (int i = 0; i < height -1; ++i) {
  22. for (int j = 0; j < width - 1; ++j) {
  23. imagePixels[i][j] = oldImage.getRGB(i,j); //error here
  24.  
  25. }
  26. }
  27.  
  28. "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
  29. at sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source)
  30. at java.awt.image.BufferedImage.getRGB(Unknown Source)
  31. at imagery.ImageTiler.main(ImageTiler.java:35)
  32.  
  33. for (int i = 0; i < width -1; ++i) {
  34. for (int j = 0; j < height - 1; ++j) {
  35. imagePixels[i][j] = oldImage.getRGB(i,j); //error here
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement