How is everyone loading tiles. I have a map which uses mutliple tiles(~400)
each tile is a seperate png file. Loading time for the app is now in the minutes. I load the Images using awt.ToolKit. Is there a better way? ???
Sticking them all in one image might help, but then you’ve got the overhead of splitting them apart at initialisation…
I believe ImageIO.read() is considerably faster than Toolkit.get().getImage()
Kev
Thanks Kevin;
That speeded it up about 10x. 8)
heh sorry…i used to use getImage() too.
But how does ImageIO.read() work?
sorry if i bothered anyone…but new X_X
Just remember that images returned by ImageIO are curerntly now ‘managed’ images (previously referred to as ‘automatic’ images)… and therefore won’t be hardware accelerated… For loading a large image containing multiple tiles this likely doesn’t matter because you will create smaller images for each tile after you have loaded the big tile map. The smaller single tile images will likley be ‘managed’ images.
So How would I make accelerated tiles from a large Image? Is there another API call for that?
So How would I make accelerated tiles from a large Image? Is there another API call for that?
Something like this :-
BufferedImage unmanagedImage = ImageIO.read(...);
BufferedImage [][] managedTiles = new BufferedImage[NUM_TILES_X][NUM_TILES_Y];
GraphicsConfiguration gc = *intendedDestinationComponent*.getGraphicsConfiguration();
int xOffset=0,yOffset=0;
for(blah x;blah;blah)
{
yOffset=0;
for(blah y;blah;blah)
{
managedTiles[x][y] = gc.createCompatibleImage(TILE_WIDTH,TILE_HEIGHT,Transparency.BIT_MASK);
managedTiles[x][y].getGraphics().drawImage(unmanagedImage,-xOffset,-yOffset,null);
yOffset+=TILE_HEIGHT;
}
xOffset+=TILE_WIDTH;
}
Suggestions for using ImageIo for encrypted image files? We read all of our image strips, decrypt them then create automatic images out of them. I’d like to use the ImageIo framework for loading in the images and comparing speed but I’m not seeing how to initialize it with a byte array.
Another person trying to ‘protect’ the art work in a game??
I honestly don’t see the need.
[quote]Suggestions for using ImageIo for encrypted image files? We read all of our image strips, decrypt them then create automatic images out of them. I’d like to use the ImageIo framework for loading in the images and comparing speed but I’m not seeing how to initialize it with a byte array.
[/quote]
The ImageIO classes will take an InputStream so just use a ByteInputStream to wrap your byte arrays.