MakeTiles: track target size when loading a source image

This commit is contained in:
Jason Long 2014-06-19 13:10:23 -04:00
parent 70bb50fed2
commit d5dbd8dc64

View file

@ -164,10 +164,12 @@ public class MakeTiles
{ {
Image image; Image image;
int basisSize; int basisSize;
int targetSize;
SourceImage(Image image, int basisSize) { SourceImage(Image image, int basisSize, int targetSize) {
this.image = image; this.image = image;
this.basisSize = basisSize; this.basisSize = basisSize;
this.targetSize = targetSize;
} }
@Override @Override
@ -179,7 +181,7 @@ public class MakeTiles
gr.drawImage( gr.drawImage(
image, image,
destX, destY, destX, destY,
destX+TILE_SIZE, destY+TILE_SIZE, destX+targetSize, destY+targetSize,
srcX, srcY, srcX, srcY,
srcX+basisSize, srcY+basisSize, srcX+basisSize, srcY+basisSize,
null); null);
@ -359,6 +361,7 @@ public class MakeTiles
ImageIcon ii = new ImageIcon(pngFile.toString()); ImageIcon ii = new ImageIcon(pngFile.toString());
return new SourceImage( return new SourceImage(
ii.getImage(), ii.getImage(),
TILE_SIZE,
TILE_SIZE); TILE_SIZE);
} }
@ -367,6 +370,7 @@ public class MakeTiles
ImageIcon ii = new ImageIcon(pngFile.toString()); ImageIcon ii = new ImageIcon(pngFile.toString());
return new SourceImage( return new SourceImage(
ii.getImage(), ii.getImage(),
TILE_SIZE,
TILE_SIZE); TILE_SIZE);
} }
@ -375,7 +379,8 @@ public class MakeTiles
ImageIcon ii = new ImageIcon(pngFile.toString()); ImageIcon ii = new ImageIcon(pngFile.toString());
return new SourceImage( return new SourceImage(
ii.getImage(), ii.getImage(),
STD_SIZE); STD_SIZE,
TILE_SIZE);
} }
throw new IOException("File not found: "+fileName+".{svg,png}"); throw new IOException("File not found: "+fileName+".{svg,png}");