Fixed writing pre-rendered font TGAs, needed to flip image.

This commit is contained in:
Zack Middleton 2012-03-29 04:49:36 +00:00
parent ea0102d403
commit f15a3cca21

View file

@ -58,11 +58,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// 4. Exit the game and there will be three dat files and at least three tga files. The
// tga's are in 256x256 pages so if it takes three images to render a 24 point font you
// will end up with fontImage_0_24.tga through fontImage_2_24.tga
// 5. You will need to flip the tga's in Photoshop as the tga output code writes them upside
// down.
// 6. In future runs of the game, the system looks for these images and data files when a s
// 5. In future runs of the game, the system looks for these images and data files when a s
// specific point sized font is rendered and loads them for use.
// 7. Because of the original beta nature of the FreeType code you will probably want to hand
// 6. Because of the original beta nature of the FreeType code you will probably want to hand
// touch the font bitmaps.
//
// Currently a define in the project turns on or off the FreeType code which is currently
@ -148,6 +146,9 @@ FT_Bitmap *R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t* glyphOut) {
void WriteTGA (char *filename, byte *data, int width, int height) {
byte *buffer;
int i, c;
int row;
unsigned char *flip;
unsigned char *src, *dst;
buffer = ri.Malloc(width*height*4 + 18);
Com_Memset (buffer, 0, 18);
@ -168,6 +169,19 @@ void WriteTGA (char *filename, byte *data, int width, int height) {
buffer[i+3] = data[i-18+3]; // alpha
}
// flip upside down
flip = (unsigned char *)ri.Malloc(width*4);
for(row = 0; row < height/2; row++)
{
src = buffer + 18 + row * 4 * width;
dst = buffer + 18 + (height - row - 1) * 4 * width;
Com_Memcpy(flip, src, width*4);
Com_Memcpy(src, dst, width*4);
Com_Memcpy(dst, flip, width*4);
}
ri.Free(flip);
ri.FS_WriteFile(filename, buffer, c);
//f = fopen (filename, "wb");