Problem with splitting BufferedImage

so here is where the problem is

	public void init(int worldSize, BufferedImage map){
		this.worldSize = worldSize;
		this.map = map;
		

		//createChunks
		int chunkW = map.getWidth() / worldSize;
		int chunkH = map.getHeight() / worldSize;
		
     	int count = 0;
		
		BufferedImage imgs[] = new BufferedImage[chunkW*chunkH];
		
		for (int x = 0; x < worldSize; x++) {  
            for (int y = 0; y < worldSize; y++) { 
				imgs[count] = new BufferedImage(chunkW, chunkH, map.getType());

        		Chunk chunke = new Chunk(x*8*32, y*8*32,imgs[count++]);	
            	chunkList.add(chunke);
				
				System.out.println(count+" IMG: "+map.getData()+" RGB: "+map.getRGB(x, y));
            }	
        }

		for(Chunk chunks : chunkList){
			chunks.initChunk();
		}
		
	}

what i’am trying to do is get 8 pixels out off the BF and create a chunk out off it then jump another 8 pixels and make a new chunk but they are all black when they go into the array why?

tell me if you need more info this is the chunk init

	public void initChunk(){
		
		
		if(currChunkImg != null){
			for(int w = 0; w < chunkSize; w++){
				for(int h = 0; h < chunkSize; h++){
					 int rgb = currChunkImg.getRGB(w, h);
					 
					 switch(rgb & 0x000000){
					 	case 0x000000:
					 		blocks.add(new Block(pos.xpos + w*32,pos.ypos + h*32));
						break;
//					 	case 0xFFFFFF:
//					 		blocks.add(new Block(pos.xpos + w*32,pos.ypos + h*32));
//						break;
					 }
					 
					 
				}
		        	 
			}
		}
		
	}

and when i render with

g.drawImage(currChunkImg,(int)pos.xpos, (int)pos.ypos,64,64,null);

in the chunk class
it shows a black image

I don’t see where you are drawing to the BufferedImage. Of course the internal array is going to be all 0’s when you first create it, so all black.

Depending on whether they actually need to be separate instances, you may get utility out of getSubImage().

E.g:


/** Split parent into numX by numY spritesheet */
public static BufferedImage[][] split(BufferedImage parent, int numX, int numY) {
    BufferedImage[][] tiles = new BufferedImage[numX][numY];
    int tileW = parent.getWidth() / numX;
    int tileH = parent.getHeight() / numY;

    for (int x = 0; x < numX; x++)
        for (int y = 0; y < numY; y++)
            tiles[x][y] = parent.getSubImage(x * tileW, y * tileH, tileW, tileH);

    return tiles;
}

i want to get the data out off the map image and split in to smaller temp images

Then do what BurntPizza suggests. I used a similar method for a thing I scribbled some two years ago (also implemented it in NodeJS since I was getting into that at the time) which cuts a sprite sheet into smaller icon-sized images - which then serves a random of these icons on each request through http.

http://d.heartpirates.com:40000/

http://twimg.jin.fi/

source for the nodejs implementation