File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes map program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "map program" Watch "map program" New topic

map program

Syamsul Hussin
Ranch Hand

Joined: Feb 09, 2003
Posts: 59
Hi, I want to write a program that generates a map. The map should be represented as colors, the colors being the height(z-axis) of that point in the map. The way I store the data is by using a 2-dimensional integer array and setting each (x,y,z) point in the map as map[x][y]=z and when i want to draw the map, I iterate through the array and paint each point according to its z value. Is there a better way to store the data and to draw the map?

----------------------------------<br />SCJP 1.4
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
the two-dimensional array aproach is actually the same as a bitmap (bmp) image. (eg. an colour bitmap with 16.7 m. colours is a 3 dimensional array of 8 bit values: (2^8)^3 = 16.7m )
so you could probably apply a "non lossy reduction" algorithm such as gif or png to your data (gif only works for 256 colours, i think png is better. so much about the theory...i dont have a clue how to do this...
maybe this can give you some new ideas...
I agree. Here's the link:
subject: map program
It's not a secret anymore!