Sign in to follow this  

Loading a .tga file in java to use as....

This topic is 3848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone. Ok, i don't know if this subject has been addressed again or anything, or if i should post it in the java-related part of the forums but still any help would be great. To the point.... I am currently working on java with JOGL API for my project and i am focused on terrain generation. I have found sources (books, net) talking about generating a terrain using a heightmap. Usually proposing to load data from a .tga image (though i suppose any grayscale image file or bitmap would do?) and use them to produce the heights for your terrain. Still I am completely clueless on how to load a .tga file correctly in java and how to proceed. Some sources i found on the net are doing the procedure in C++ but i guess my knowledge is not enough to either fully understand the procedure and use it in java. I know its a big subject but any help (sources to study from or any example or guideline) would be very appreciated. Thanks in advance for any help.

Share this post


Link to post
Share on other sites
My advice would be to find an image-loading library that lets you load a file into a buffer of memory that you can read back from.

These are common in C/C++, and I'd bet they are not that rare in Java.

Basically, avoid writing your own image loading code -- somebody else has already done it, and probably did it better than you would. :)

Share this post


Link to post
Share on other sites
ImageIO is the usual way to load images, but IIRC it doesn't support .tga files. If you don't specifically need tga I'd switch to png (which is also non-lossy compressed, and can be loaded via ImageIO).

If you were using LWJGL then you could use DevIL, which supports pretty much every graphics format known to man (including tga).

Share this post


Link to post
Share on other sites

This topic is 3848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this