images.c File Reference

Image loading and saving functions. More...

#include "images.h"
#include <jpeglib.h>
#include <png.h>
Include dependency graph for images.c:

Go to the source code of this file.

Defines

#define TGA_UNMAP_UNCOMP   2
#define TGA_UNMAP_COMP   10
#define TGA_CHANNELS   3

Functions

const char ** Img_GetImageTypes (void)
void R_WritePNG (qFILE *f, byte *buffer, int width, int height)
void R_WriteCompressedTGA (qFILE *f, const byte *buffer, int width, int height)
void R_WriteJPG (qFILE *f, byte *buffer, int width, int height, int quality)
static qboolean Img_LoadTypedImage (const char *name, char *type, SDL_Surface **surf)
 Loads the specified image from the game filesystem and populates the provided SDL_Surface.
qboolean Img_LoadImage (const char *name, SDL_Surface **surf)
 Loads the specified image from the game filesystem and populates the provided SDL_Surface.

Variables

static char * IMAGE_TYPES [] = { "tga", "png", "jpg", NULL }
static SDL_PixelFormat format

Detailed Description

Image loading and saving functions.

Definition in file images.c.


Define Documentation

#define TGA_CHANNELS   3

Definition at line 120 of file images.c.

Referenced by R_WriteCompressedTGA().

#define TGA_UNMAP_COMP   10

Definition at line 68 of file images.c.

Referenced by R_WriteCompressedTGA().

#define TGA_UNMAP_UNCOMP   2

Definition at line 67 of file images.c.


Function Documentation

const char** Img_GetImageTypes ( void   ) 

Definition at line 70 of file images.c.

References IMAGE_TYPES.

Referenced by R_ImageExists().

qboolean Img_LoadImage ( const char *  name,
SDL_Surface **  surf 
)

Loads the specified image from the game filesystem and populates the provided SDL_Surface.

Image formats are tried in the order they appear in TYPES.

Note:
Make sure to free the given SDL_Surface after you are done with it.

Definition at line 338 of file images.c.

References i, IMAGE_TYPES, Img_LoadTypedImage(), qfalse, and qtrue.

Referenced by CalcTextureReflectivity(), R_FindImage(), and R_LoadImage().

static qboolean Img_LoadTypedImage ( const char *  name,
char *  type,
SDL_Surface **  surf 
) [static]

Loads the specified image from the game filesystem and populates the provided SDL_Surface.

Definition at line 293 of file images.c.

References byte, format, FS_FreeFile(), FS_LoadFile(), len, MAX_QPATH, qfalse, and qtrue.

Referenced by Img_LoadImage().

void R_WriteCompressedTGA ( qFILE f,
const byte buffer,
int  width,
int  height 
)
See also:
R_LoadTGA
R_WriteTGA

Definition at line 126 of file images.c.

References byte, FS_Write(), header, TGA_CHANNELS, and TGA_UNMAP_COMP.

Referenced by R_ScreenShot().

void R_WriteJPG ( qFILE f,
byte buffer,
int  width,
int  height,
int  quality 
)
See also:
R_ScreenShot_f
R_LoadJPG

Definition at line 252 of file images.c.

References byte, qFILE_s::f, and qtrue.

Referenced by R_ScreenShot().

void R_WritePNG ( qFILE f,
byte buffer,
int  width,
int  height 
)
See also:
R_LoadTGA
R_LoadJPG
R_FindImage

Definition at line 80 of file images.c.

References qFILE_s::f, and i.

Referenced by R_ScreenShot().


Variable Documentation

SDL_PixelFormat format [static]
Initial value:
 {
    NULL,  
    32,  
    4,  
    0,  
    0,  
    0,  
    0,  
    24,  
    16,  
    8,  
    0,  

    0xff000000,
    0x00ff0000,
    0x0000ff00,
    0x000000ff,






    0,  
    1   
}

default pixel format to which all images are converted

Definition at line 40 of file images.c.

Referenced by G_ClientAction(), Img_LoadTypedImage(), and sound::WavFileLoader::LoadFromStream().

char* IMAGE_TYPES[] = { "tga", "png", "jpg", NULL } [static]

image formats, tried in this order

Definition at line 37 of file images.c.

Referenced by Img_GetImageTypes(), and Img_LoadImage().


Generated by  doxygen 1.6.2