Skip to content

Commit

Permalink
Small code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrybig committed Apr 8, 2019
1 parent 96fb402 commit da759f4
Showing 1 changed file with 6 additions and 7 deletions.
Expand Up @@ -130,20 +130,19 @@ public void startRender() throws IOException {

@Override
protected void addImage(BufferedImage tile, int dimension, int x, int z) throws IOException {
// todo use dimension
int currentZoom = this.normalZoom;
int imageWidth = tile.getWidth();
int adjustedImageWidth = imageWidth;
int tilesToGenerate = 1;
int tilesInThisLayer = 1;

BufferedImage renderResult = new BufferedImage(this.normalRes, this.normalRes, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = renderResult.createGraphics();
g2.setComposite(AlphaComposite.Src);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
try {
for (; adjustedImageWidth >= this.normalRes; adjustedImageWidth /= 2, tilesToGenerate *= 2, currentZoom++) {
for (int tileX = 0; tileX < tilesToGenerate; tileX++) {
for (int tileZ = 0; tileZ < tilesToGenerate; tileZ++) {
for (; adjustedImageWidth >= this.normalRes; adjustedImageWidth /= 2, tilesInThisLayer *= 2, currentZoom++) {
for (int tileX = 0; tileX < tilesInThisLayer; tileX++) {
for (int tileZ = 0; tileZ < tilesInThisLayer; tileZ++) {
g2.drawImage(
tile,
// dst x1,y1
Expand All @@ -159,8 +158,8 @@ protected void addImage(BufferedImage tile, int dimension, int x, int z) throws
final Path imageLocation = getImageLocation(
dimension,
currentZoom,
x * tilesToGenerate + tileX,
z * tilesToGenerate + tileZ
x * tilesInThisLayer + tileX,
z * tilesInThisLayer + tileZ
);
if (DEBUG && false) {
System.err.println("Rendering zoom level " + currentZoom + ", tile: " + tileX + ", " + tileZ + " (" + x + "," + z + ") ");
Expand Down

0 comments on commit da759f4

Please sign in to comment.