free (buffer);
}
+void WriteTGAGray (const char *filename, byte *data, int width, int height) {
+ byte buffer[18];
+ int i;
+ int c;
+ 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);
+}
+
/*
============================================================================
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);
void Load32BitImage (const char *name, unsigned **pixels, int *width, int *height);
1.0f, /* minimap sharpener */\r
0.0f, /* minimap border */\r
qtrue, /* minimap keep aspect */\r
+ MINIMAP_MODE_GRAY, /* minimap mode */\r
"%s.tga", /* minimap name format */\r
"IBSP", /* bsp file prefix */\r
46, /* bsp file version */\r
1.0f, /* minimap sharpener */\r
0.0f, /* minimap border */\r
qtrue, /* minimap keep aspect */\r
+ MINIMAP_MODE_GRAY, /* minimap mode */\r
"%s.tga", /* minimap name format */\r
"IBSP", /* bsp file prefix */\r
46, /* bsp file version */\r
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */
1, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */
1, /* bsp file version */
1.0f, /* minimap sharpener */
1.0f/66.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"../gfx/%s_mini.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */\r
0.0f, /* minimap border */\r
qtrue, /* minimap keep aspect */\r
+ MINIMAP_MODE_GRAY, /* minimap mode */\r
"%s.tga", /* minimap name format */\r
"IBSP", /* bsp file prefix */\r
46, /* bsp file version */\r
0.0f, /* minimap sharpener */
0.0f, /* minimap border */
qfalse, /* minimap keep aspect */
+ MINIMAP_MODE_WHITE, /* minimap mode */
"../minimaps/%s.tga", /* minimap name format */
"FBSP", /* bsp file prefix */
1, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
47, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"RBSP", /* bsp file prefix */
1, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
"%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
/* minimap stuff */
-/* borrowed from light.c */
-void WriteTGA24( char *filename, byte *data, int width, int height, qboolean flip );
typedef struct minimap_s
{
bspModel_t *model;
char relativeMinimapFilename[1024];
float minimapSharpen;
float border;
- byte *data3b, *p;
+ byte *data4b, *p;
float *q;
int x, y;
int i;
+ miniMapMode_t mode;
vec3_t mins, maxs;
qboolean keepaspect;
minimap.width = minimap.height = game->miniMapSize;
border = game->miniMapBorder;
keepaspect = game->miniMapKeepAspect;
+ mode = game->miniMapMode;
minimap.samples = 1;
minimap.sample_offsets = NULL;
i += 6;
Sys_Printf( "Map mins/maxs overridden\n" );
}
+ else if( !strcmp( argv[ i ], "-gray" ) )
+ {
+ mode = MINIMAP_MODE_GRAY;
+ Sys_Printf( "Writing as white-on-black image\n" );
+ }
+ else if( !strcmp( argv[ i ], "-black" ) )
+ {
+ mode = MINIMAP_MODE_BLACK;
+ Sys_Printf( "Writing as black alpha image\n" );
+ }
+ else if( !strcmp( argv[ i ], "-white" ) )
+ {
+ mode = MINIMAP_MODE_WHITE;
+ Sys_Printf( "Writing as white alpha image\n" );
+ }
}
MiniMapMakeMinsMaxs(mins, maxs, border, keepaspect);
MergeRelativePath(minimapFilename, path, relativeMinimapFilename);
Sys_Printf("Output file name automatically set to %s\n", minimapFilename);
}
+ ExtractFilePath(minimapFilename, path);
+ Q_mkdir(path);
if(minimapSharpen >= 0)
{
}
minimap.data1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
- data3b = safe_malloc(minimap.width * minimap.height * 3);
+ data4b = safe_malloc(minimap.width * minimap.height * 4);
if(minimapSharpen >= 0)
minimap.sharpendata1f = safe_malloc(minimap.width * minimap.height * sizeof(*minimap.data1f));
}
Sys_Printf( "\nConverting...");
- p = data3b;
- for(y = 0; y < minimap.height; ++y)
- for(x = 0; x < minimap.width; ++x)
- {
- byte b;
- float v = *q++;
- if(v < 0) v = 0;
- if(v > 255.0/256.0) v = 255.0/256.0;
- b = v * 256;
- *p++ = b;
- *p++ = b;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- ExtractFilePath(minimapFilename, path);
- Q_mkdir(path);
- WriteTGA24(minimapFilename, data3b, minimap.width, minimap.height, qfalse);
+ switch(mode)
+ {
+ case MINIMAP_MODE_GRAY:
+ p = data4b;
+ for(y = 0; y < minimap.height; ++y)
+ for(x = 0; x < minimap.width; ++x)
+ {
+ byte b;
+ float v = *q++;
+ if(v < 0) v = 0;
+ if(v > 255.0/256.0) v = 255.0/256.0;
+ b = v * 256;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGAGray(minimapFilename, data4b, minimap.width, minimap.height);
+ break;
+ case MINIMAP_MODE_BLACK:
+ p = data4b;
+ for(y = 0; y < minimap.height; ++y)
+ for(x = 0; x < minimap.width; ++x)
+ {
+ byte b;
+ float v = *q++;
+ if(v < 0) v = 0;
+ if(v > 255.0/256.0) v = 255.0/256.0;
+ b = v * 256;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
+ break;
+ case MINIMAP_MODE_WHITE:
+ p = data4b;
+ for(y = 0; y < minimap.height; ++y)
+ for(x = 0; x < minimap.width; ++x)
+ {
+ byte b;
+ float v = *q++;
+ if(v < 0) v = 0;
+ if(v > 255.0/256.0) v = 255.0/256.0;
+ b = v * 256;
+ *p++ = 255;
+ *p++ = 255;
+ *p++ = 255;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGA(minimapFilename, data4b, minimap.width, minimap.height);
+ break;
+ }
Sys_Printf( " done.\n" );
}
surfaceParm_t;
+typedef enum
+{
+ MINIMAP_MODE_GRAY,
+ MINIMAP_MODE_BLACK,
+ MINIMAP_MODE_WHITE
+}
+miniMapMode_t;
typedef struct game_s
{
float miniMapSharpen; /* minimap sharpening coefficient */
float miniMapBorder; /* minimap border amount */
qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
+ miniMapMode_t miniMapMode; /* minimap mode */
char *miniMapNameFormat; /* minimap name format */
char *bspIdent; /* 4-letter bsp file prefix */
int bspVersion; /* bsp version to use */