Hi guys

I want to take an image and cut it into blocks, then store each block in an array of bufferedimages.

I have tried many things

public void splitImage(int cols, int rows) 
  		{  
         int w = thePic.getWidth()/cols;  
         int h = thePic.getHeight()/rows;  
         int num = 0;  
         tileset = new BufferedImage[w*h];  
         for(int y = 0; y < rows; y++) {  
             for(int x = 0; x < cols; x++) {  
                 tileset[num] = new BufferedImage(w, h, thePic.getType());  
                 // Tell the graphics to draw only one block of the image  
                 Graphics2D g = tileset[num].createGraphics();  
                 g.drawImage(thePic, 0, 0, w, h, w*x, h*y, w*x+w, h*y+h, null);  
                 g.dispose();  
              num++;     
             }  
         }    
     }

This looks like it would work, but i tried testing it and it didn't. can anyone test it or point out the obvious flaw?

Thanks alot if you can

Don't know why that didn't work, but why not just use getSubimage(int x, int y, int w, int h) to create your array of sub-images directly?