Page 1 of 1

TGAs

PostPosted: Aug 1, 2001 @ 5:33am
by suchiaruzu
Hello,<br>a friend of mine would like to know how to use (decompress or whatever) TGAs in his game, as he now uses bitmaps which make the game pretty large and slow. Any suggestions? Fredrik? Carpe? I know you're using TGAs in Argentum...<br>Thanks,<br>Shape

Re: TGAs

PostPosted: Aug 1, 2001 @ 6:07am
by Phantom
Shape,<br><br>Check out my tutorials at http://pizza.hvu.nl/~kouwenhs . One of them contains a simple tga loader. TGA's are very simple, as long as you don't save them as compressed tga's. Basically they consist of a 18 byte header (or so) plus the raw image data. I love them for their simplicity. :)<br><br>- Jacco.

Re: TGAs

PostPosted: Aug 1, 2001 @ 12:17pm
by suchiaruzu
Thanks a lot, Jacco!<br>Uhm, what about compressed ones?

Re: TGAs

PostPosted: Aug 1, 2001 @ 12:21pm
by Digby
Um... if he has a problem with size how is an uncompressed TGA going to help him any?<br><br>Why doesn't he store them in a compressed format like jpeg, png, or gif and use the image loading library (imgdecmp.dll)?  Here's an that describes how to use it.

Re: TGAs

PostPosted: Aug 1, 2001 @ 12:29pm
by suchiaruzu
He's the author of "Dove Hunt" and gifs/jpegs/pngs would look shitty. Maybe, MAYBE pngs, but I dunno...

Re: TGAs

PostPosted: Aug 1, 2001 @ 12:57pm
by Dan East
He should choose whatever image format is most condicive to his existing code, and use gzip to compress them.<br><br>Dan East

Re: TGAs

PostPosted: Aug 1, 2001 @ 2:52pm
by Phantom
Ehm yes. Didn't notice that he wanted small files. And yes, zlib is ideal for this. It saves you the hassle of working with a gif compressor, an audio compressor and so on and does all of that on the data type that you like. I even got zlib to load mod files. Or rather, MikMod can load a mod file using zlib. :) Very nifty.

Re: TGAs

PostPosted: Aug 2, 2001 @ 1:50am
by Frank W. Zammetti
Two questions:<br><br>(1) Whar is zlib (I can guess, but I'd still like to be told!) and where can I get it?<br><br>(2) Does it work with data stored in memory?  I prefer to develop all my software as stand-alone EXE's butI haven't been able to figure out how to store compressed binary data (read: GIFs or JPGs) and decompress them (short of writing my own algorithms which I'm sure I could manage, but ICK!)<br><br>Thanks guys!

Re: TGAs

PostPosted: Aug 2, 2001 @ 1:04pm
by suchiaruzu
Thanks a bunch!!!<br>-Shape

Re: TGAs

PostPosted: Aug 2, 2001 @ 2:59pm
by Dan East
zlib (gZip) is a non-patented, open source, extremely high performance compression algorithm. It is the primary algorithm used by zip. You can get the source at http://www.gzip.org. zlib is designed to be used similarly to the ANSI-C file functions (fopen, fread, fwrite, etc). It could be adapted to work with memory buffers instead, but it would probably take a pretty good amount of work.<br>Do you mean that you embed all data directly into your EXE so you won't have to load it? File I/O is really very easy. I'll show you how to decompress a .gz gzipped file into a buffer right now:<br>[fixed]<br>#include "zlib.h"<br><br>gzFile pgzin=gzopen( "MyGzippedFile.gz", "rb" );<br>if ( !pgzin )<br>  return 0;        //failed to open<br><br>char buf[100000]; //This buf needs to be large enough<br>                   //to hold the uncompressed data.<br>int bytesread=gzread(pgzin, buf, sizeof(buf));<br>gzclose(pgzin);<br>[/fixed]<br><br>Dan East<br><br><br>

Re: TGAs

PostPosted: Aug 4, 2001 @ 12:09pm
by Larry Bank
Depending on the type of images, TGA may be an easy route.  The compressed TGA's use a simple run-length scheme which can be coded in about 20 lines of C code.<br><br>I don't like to depend on unsupported libraries from Microsoft - especially slow and cumbersome ones.<br><br>L.B.<br>

Re: TGAs

PostPosted: Aug 7, 2001 @ 1:26pm
by Frank W. Zammetti
I'll have to go play with that a bit.  Yes Dan, I prefer to embed everything into one monolithic EXE, but only because I think that's cleaner in terms of installation and removal.  Wouldn't be much of a hassle to write my own poor-performing compression algo using standard file I/O, but I'd rather have it all in one place.<br><br>I certainly know about flexibility, and that approach ain't it, but in my mind (a scary place indeed!) I'd rather sacrifice that flexibility than having to worry about multiple files, possibly in multiple locations.  I've dealt with DLL Hell, like everyone else, far more than I'd ever like, and even though that's not really what we're talking about, anything even remotely like it I disdain.  <br><br>However, I may have to re-think that stance seeing as the apparent simplicity and performance of zlib probably makes it a moot point.  Thanks for the insight, I appreciate it!