byte array to save memory.

This commit is contained in:
2023-09-20 17:20:54 -04:00
parent 85983954de
commit 6fd61889a8
+4 -4
View File
@@ -40,7 +40,7 @@ public class HeightMap {
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
public static final HashMap<Integer, int[][]> _pixelData = new HashMap<>();
public static final HashMap<Integer, byte[][]> _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();
}
}