UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
images.cpp File Reference

Image loading and saving functions. More...

#include "images.h"
#include "shared.h"
#include <jpeglib.h>
#include <png.h>
#include <zlib.h>
#include <jerror.h>

Go to the source code of this file.

Data Structures

struct  bufState_t
 

Macros

#define TGA_UNMAP_COMP   10
 
#define TGA_CHANNELS   3
 

Functions

char const *const * 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 bytereadFile (char const *const name, char const *const suffix, size_t &len)
 
static SDL_Surface * createSurface (int const height, int const width)
 
static void readMem (png_struct *const png, png_byte *const dst, png_size_t const size)
 
static SDL_Surface * Img_LoadPNG (char const *const name)
 
static void djpeg_nop (jpeg_decompress_struct *)
 
static boolean djpeg_fill_input_buffer (jpeg_decompress_struct *const cinfo)
 
static void djpeg_skip_input_data (jpeg_decompress_struct *const cinfo, long const num_bytes)
 
static SDL_Surface * Img_LoadJPG (char const *const name)
 
SDL_Surface * Img_LoadImage (char const *name)
 Loads the specified image from the game filesystem and populates the provided SDL_Surface. More...
 

Variables

static char const *const IMAGE_TYPES [] = { "png", "jpg", nullptr }
 

Detailed Description

Image loading and saving functions.

Definition in file images.cpp.

Macro Definition Documentation

#define TGA_CHANNELS   3

Definition at line 95 of file images.cpp.

Referenced by R_WriteCompressedTGA().

#define TGA_UNMAP_COMP   10

Definition at line 44 of file images.cpp.

Referenced by R_WriteCompressedTGA().

Function Documentation

static SDL_Surface* createSurface ( int const  height,
int const  width 
)
static

Definition at line 270 of file images.cpp.

Referenced by Img_LoadJPG(), and Img_LoadPNG().

static boolean djpeg_fill_input_buffer ( jpeg_decompress_struct *const  cinfo)
static

Definition at line 350 of file images.cpp.

Referenced by Img_LoadJPG().

static void djpeg_nop ( jpeg_decompress_struct *  )
static

Definition at line 348 of file images.cpp.

Referenced by Img_LoadJPG().

static void djpeg_skip_input_data ( jpeg_decompress_struct *const  cinfo,
long const  num_bytes 
)
static

Definition at line 356 of file images.cpp.

Referenced by Img_LoadJPG().

char const* const* Img_GetImageTypes ( void  )

Definition at line 46 of file images.cpp.

References IMAGE_TYPES.

Referenced by R_ImageExists().

SDL_Surface* Img_LoadImage ( char const *  name)

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 435 of file images.cpp.

References Img_LoadJPG(), and Img_LoadPNG().

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

static SDL_Surface* Img_LoadJPG ( char const *const  name)
static
static SDL_Surface* Img_LoadPNG ( char const *const  name)
static

Definition at line 298 of file images.cpp.

References createSurface(), FS_FreeFile(), len, readFile(), and readMem().

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 101 of file images.cpp.

References FS_Write(), index, OBJZERO, 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 224 of file images.cpp.

References qFILE_s::f.

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 56 of file images.cpp.

References qFILE_s::f, and i.

Referenced by R_ScreenShot(), and SL_CreatePNGFile().

static byte* readFile ( char const *const  name,
char const *const  suffix,
size_t &  len 
)
static

Definition at line 261 of file images.cpp.

References FS_LoadFile(), and MAX_QPATH.

Referenced by Img_LoadJPG(), and Img_LoadPNG().

static void readMem ( png_struct *const  png,
png_byte *const  dst,
png_size_t const  size 
)
static

Definition at line 287 of file images.cpp.

References bufState_t::end, and bufState_t::ptr.

Referenced by Img_LoadPNG().

Variable Documentation

char const* const IMAGE_TYPES[] = { "png", "jpg", nullptr }
static

image formats, tried in this order

Definition at line 42 of file images.cpp.

Referenced by Img_GetImageTypes().