'Java - What's a good and efficient way to construct an Image out of several smaller images?

I'm making a 2d topdown view game where the camera follows the player so that the player is always in the center of the screen. I'm using Swing for all of my Graphics at the moment. I currently have a set of tiles that I use to create Sprites which all contain an Image. I can display all of the Images in the Sprites, but player movement always jerks the camera around, and I thought of combining all of my smaller Images into a large one, several times the screen, which I can take neat sub-tile precision slices of for smoother camera movement. When trying to do this I couldn't quite figure out how a Raster is constructed so I thought I might as well ask if better methods are available. My current attempt for creating the big Image looks something like this:

private Image prepareBackground() {
        Raster raster = background.getData();
        int[] rgb = new int[background.getColorModel().getNumComponents()];
        for( int i=0;i< everySprite.length;++i){
            for(int j=0;j<everySprite[0].length;++j){
                Raster tileImage = ((BufferedImage)everySprite[i][j].getImage()).getData();
                for(int k=0;k< tileImage.getHeight();++k){
                    for(int l =0;l<tileImage.getWidth();++l){
                        int[] values = tileImage.getPixel(k,l, rgb);
                        //how do I set the new pixel?
                    }
                }
            }
        }
    }

When I got this far I realized there are no setters for a Raster's single pixel, just getters.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source