-1

I am currently trying to get some kind of 2D dungeoncrawler (think: roguelike) running. Now I want to work with square tiles (32x32) but I wonder if there's a way to make my textures in a higher resolution, say 64x64, and scale them down onto a 32x32 square?

I imagine there has to be since almost all games do this in one way or another but all I can seem to find online is about 3D stuff.

Vorax
  • 1
  • 1
  • It's possible, there are a couple of methods available. Don't know of any libraries, though. And a fair number of games just provide files in multiple resolutions (one game has an install size of over 100Gb because they provide texture files for up to 4k or 8k, I can't remember which). – AntonH Dec 15 '16 at 00:54
  • *"Is there a way?"* Yes. – Andreas Dec 15 '16 at 01:03

1 Answers1

1

Yeah. When you draw an image, you can add the new width and height to it to resize it.

public static BufferedImage resizeImage(BufferedImage image, int newwidth, int newheight) {
    BufferedImage image2 = new BufferedImage(newwidth, newheight, BufferedImage.TYPE_INT_ARGB);
    Graphics g = image2.getGraphics();
    g.drawImage(image, 0, 0, newwidth, newheight, null);
    g.dispose();
    return image2;
}

Refer to here for more info.

Aaron Esau
  • 1,083
  • 3
  • 15
  • 31