use of com.b3dgs.lionengine.graphic.Transparency in project lionengine by b3dgs.
the class FactoryGraphicAwt method generateTileset.
@Override
public void generateTileset(ImageBuffer[] images, Media media) {
Check.notNull(images);
Check.notNull(media);
if (images.length == 0) {
throw new LionEngineException("No images found !");
}
final int width = images[0].getWidth();
final int height = images[0].getHeight();
final Transparency transparency = images[0].getTransparency();
final int multDistance = (int) Math.ceil(width * images.length / (double) height) / 4;
final int[] mult = UtilMath.getClosestSquareMult(images.length, multDistance);
final ImageBuffer tile = new ImageBufferAwt(ToolsAwt.createImage(width * mult[1], height * mult[0], ToolsAwt.getTransparency(transparency)));
int x = 0;
int y = 0;
int line = 0;
final Graphic g = tile.createGraphic();
for (final ImageBuffer b : images) {
g.drawImage(b, x, y);
x += b.getWidth();
line++;
if (line == mult[1]) {
x = 0;
y += b.getHeight();
line = 0;
}
}
g.dispose();
saveImage(tile, media);
}
Aggregations