From: Rudolf Polzer Date: Wed, 23 Feb 2011 09:50:31 +0000 (+0100) Subject: support for writing greyscale TGA files (for minimap) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7132b13c293f4f8670c319d1f993a0fa7647aef8;p=xonotic%2Fnetradiant.git support for writing greyscale TGA files (for minimap) --- diff --git a/tools/quake3/common/imagelib.c b/tools/quake3/common/imagelib.c index fa588321..5bc248b0 100644 --- a/tools/quake3/common/imagelib.c +++ b/tools/quake3/common/imagelib.c @@ -1182,6 +1182,24 @@ void WriteTGA (const char *filename, byte *data, int width, int height) { free (buffer); } +void WriteTGAGray (const char *filename, byte *data, int width, int height) { + byte buffer[18]; + FILE *f; + + memset (buffer, 0, 18); + buffer[2] = 3; // uncompressed type + buffer[12] = width&255; + buffer[13] = width>>8; + buffer[14] = height&255; + buffer[15] = height>>8; + buffer[16] = 8; // pixel size + + f = fopen (filename, "wb"); + fwrite (buffer, 1, 18, f); + fwrite (data, 1, width * height, f); + fclose (f); +} + /* ============================================================================ diff --git a/tools/quake3/common/imagelib.h b/tools/quake3/common/imagelib.h index 1379427d..8ac02e1e 100644 --- a/tools/quake3/common/imagelib.h +++ b/tools/quake3/common/imagelib.h @@ -39,6 +39,7 @@ void Save256Image (const char *name, byte *pixels, byte *palette, void LoadTGA (const char *filename, byte **pixels, int *width, int *height); void LoadTGABuffer ( const byte *buffer, const byte* enddata, byte **pic, int *width, int *height); void WriteTGA (const char *filename, byte *data, int width, int height); +void WriteTGAGray (const char *filename, byte *data, int width, int height); int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height ); void Load32BitImage (const char *name, unsigned **pixels, int *width, int *height);