MakeTiles: use BufferedImage, to be the same as gui
This commit is contained in:
parent
7592117306
commit
28be533163
2 changed files with 21 additions and 24 deletions
|
@ -441,13 +441,23 @@ public class MakeTiles
|
||||||
|
|
||||||
if (!loadedImages.containsKey(fileName)) {
|
if (!loadedImages.containsKey(fileName)) {
|
||||||
loadedImages.put(fileName,
|
loadedImages.put(fileName,
|
||||||
loadImageReal(fileName));
|
loadImageNoCache(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadedImages.get(fileName);
|
return loadedImages.get(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SourceImage loadImageReal(String fileName)
|
static SourceImage loadImageReal(File pngFile, int basisSize)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
BufferedImage bi = ImageIO.read(pngFile);
|
||||||
|
return new SourceImage(
|
||||||
|
bi,
|
||||||
|
basisSize,
|
||||||
|
TILE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SourceImage loadImageNoCache(String fileName)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
File svgFile, pngFile = null;
|
File svgFile, pngFile = null;
|
||||||
|
@ -465,40 +475,24 @@ public class MakeTiles
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngFile != null && pngFile.exists()) {
|
if (pngFile != null && pngFile.exists()) {
|
||||||
ImageIcon ii = new ImageIcon(pngFile.toString());
|
return loadImageReal(pngFile, TILE_SIZE);
|
||||||
return new SourceImage(
|
|
||||||
ii.getImage(),
|
|
||||||
TILE_SIZE,
|
|
||||||
TILE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile = new File(fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".png");
|
pngFile = new File(fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".png");
|
||||||
if (pngFile.exists()) {
|
if (pngFile.exists()) {
|
||||||
ImageIcon ii = new ImageIcon(pngFile.toString());
|
return loadImageReal(pngFile, TILE_SIZE);
|
||||||
return new SourceImage(
|
|
||||||
ii.getImage(),
|
|
||||||
TILE_SIZE,
|
|
||||||
TILE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TILE_SIZE < 128) {
|
if (TILE_SIZE < 128) {
|
||||||
pngFile = new File(fileName+"_128x128.png");
|
pngFile = new File(fileName+"_128x128.png");
|
||||||
if (pngFile.exists()) {
|
if (pngFile.exists()) {
|
||||||
ImageIcon ii = new ImageIcon(pngFile.toString());
|
return loadImageReal(pngFile, 128);
|
||||||
return new SourceImage(
|
|
||||||
ii.getImage(),
|
|
||||||
128,
|
|
||||||
TILE_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pngFile = new File(fileName+".png");
|
pngFile = new File(fileName+".png");
|
||||||
if (pngFile.exists()) {
|
if (pngFile.exists()) {
|
||||||
ImageIcon ii = new ImageIcon(pngFile.toString());
|
return loadImageReal(pngFile, STD_SIZE);
|
||||||
return new SourceImage(
|
|
||||||
ii.getImage(),
|
|
||||||
STD_SIZE,
|
|
||||||
TILE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IOException("File not found: "+fileName+".{svg,png}");
|
throw new IOException("File not found: "+fileName+".{svg,png}");
|
||||||
|
|
|
@ -48,13 +48,16 @@ public abstract class TileImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports rescaling of tile images.
|
||||||
|
*/
|
||||||
public static class SourceImage extends TileImage
|
public static class SourceImage extends TileImage
|
||||||
{
|
{
|
||||||
public final Image image;
|
public final BufferedImage image;
|
||||||
public final int basisSize;
|
public final int basisSize;
|
||||||
public final int targetSize;
|
public final int targetSize;
|
||||||
|
|
||||||
public SourceImage(Image image, int basisSize, int targetSize)
|
public SourceImage(BufferedImage image, int basisSize, int targetSize)
|
||||||
{
|
{
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.basisSize = basisSize;
|
this.basisSize = basisSize;
|
||||||
|
|
Reference in a new issue