This site is no longer active and is available for archival purposes only. Registration and login is disabled.

TGAs


TGAs

Postby suchiaruzu » Aug 1, 2001 @ 5:33am

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
<div align="center">Image<br></div>
User avatar
suchiaruzu
pm Insider
 
Posts: 2570
Joined: May 3, 2001 @ 9:29am
Location: BFE


Re: TGAs

Postby Phantom » Aug 1, 2001 @ 6:07am

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.
Phantom
 


Re: TGAs

Postby suchiaruzu » Aug 1, 2001 @ 12:17pm

Thanks a lot, Jacco!<br>Uhm, what about compressed ones?
<div align="center">Image<br></div>
User avatar
suchiaruzu
pm Insider
 
Posts: 2570
Joined: May 3, 2001 @ 9:29am
Location: BFE


Re: TGAs

Postby Digby » Aug 1, 2001 @ 12:21pm

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.
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: TGAs

Postby suchiaruzu » Aug 1, 2001 @ 12:29pm

He's the author of "Dove Hunt" and gifs/jpegs/pngs would look shitty. Maybe, MAYBE pngs, but I dunno...
<div align="center">Image<br></div>
User avatar
suchiaruzu
pm Insider
 
Posts: 2570
Joined: May 3, 2001 @ 9:29am
Location: BFE


Re: TGAs

Postby Dan East » Aug 1, 2001 @ 12:57pm

He should choose whatever image format is most condicive to his existing code, and use gzip to compress them.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: TGAs

Postby Phantom » Aug 1, 2001 @ 2:52pm

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.
Phantom
 


Re: TGAs

Postby Frank W. Zammetti » Aug 2, 2001 @ 1:50am

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!
Frank W. Zammetti
 


Re: TGAs

Postby suchiaruzu » Aug 2, 2001 @ 1:04pm

Thanks a bunch!!!<br>-Shape
<div align="center">Image<br></div>
User avatar
suchiaruzu
pm Insider
 
Posts: 2570
Joined: May 3, 2001 @ 9:29am
Location: BFE


Re: TGAs

Postby Dan East » Aug 2, 2001 @ 2:59pm

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>
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: TGAs

Postby Larry Bank » Aug 4, 2001 @ 12:09pm

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>
Larry Bank
 


Re: TGAs

Postby Frank W. Zammetti » Aug 7, 2001 @ 1:26pm

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!
Frank W. Zammetti
 


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron