From 6fd61889a84f43a9c85e0e571e4240697b35d615 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 17:20:54 -0400 Subject: [PATCH] byte array to save memory. --- src/engine/InterestManagement/HeightMap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index b863a143..312928cc 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -40,7 +40,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _pixelData = new HashMap<>(); // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; @@ -326,16 +326,16 @@ public class HeightMap { try { BufferedImage heightmapImage = ImageIO.read(imageFile); - // Generate pixel for this heightmap. RPG channels are all the same + // Generate pixel data for this heightmap. RPG channels are all the same // in this greyscale TGA heightmap. We will choose red. - int[][] colorData = new int[heightmapImage.getWidth()][heightmapImage.getHeight()]; + byte[][] colorData = new byte[heightmapImage.getWidth()][heightmapImage.getHeight()]; for (int y = 0; y < heightmapImage.getHeight(); y++) { for (int x = 0; x < heightmapImage.getWidth(); x++) { Color color = new Color(heightmapImage.getRGB(x, y)); - colorData[x][y] = color.getRed(); + colorData[x][y] = (byte) color.getRed(); } }