| 
    Quake II RTX doxygen
    1.0 dev
    
   | 
           
 | 
 
 
 
 
#include "shared/shared.h"
#include "common/common.h"
#include "common/cvar.h"
#include "common/files.h"
#include "refresh/images.h"
#include "format/pcx.h"
#include "format/wal.h"
#include "stb_image.h"
#include "stb_image_write.h"
Go to the source code of this file.
 | 
| void  | stbi_write (void *context, void *data, int size) | 
|   | 
| static void  | IMG_FloodFill (byte *skin, int skinwidth, int skinheight) | 
|   | 
| static qerror_t  | IMG_DecodePCX (byte *rawdata, size_t rawlen, byte *pixels, byte *palette, int *width, int *height) | 
|   | 
| static int  | IMG_Unpack8 (uint32_t *out, const uint8_t *in, int width, int height) | 
|   | 
|   | IMG_LOAD (PCX) | 
|   | 
|   | IMG_LOAD (WAL) | 
|   | 
|   | IMG_LOAD (STB) | 
|   | 
|   | IMG_SAVE (TGA) | 
|   | 
|   | IMG_SAVE (JPG) | 
|   | 
|   | IMG_SAVE (PNG) | 
|   | 
| static qhandle_t  | create_screenshot (char *buffer, size_t size, const char *name, const char *ext) | 
|   | 
| static void  | make_screenshot (const char *name, const char *ext, qerror_t(*save)(qhandle_t, const char *, byte *, int, int, int, int), int param) | 
|   | 
| static void  | IMG_ScreenShot_f (void) | 
|   | 
| static void  | IMG_ScreenShotTGA_f (void) | 
|   | 
| static void  | IMG_ScreenShotJPG_f (void) | 
|   | 
| static void  | IMG_ScreenShotPNG_f (void) | 
|   | 
| void  | IMG_ResampleTexture (const byte *in, int inwidth, int inheight, byte *out, int outwidth, int outheight) | 
|   | 
| void  | IMG_MipMap (byte *out, byte *in, int width, int height) | 
|   | 
| static void  | IMG_List_f (void) | 
|   | 
| static image_t *  | alloc_image (void) | 
|   | 
| static image_t *  | lookup_image (const char *name, imagetype_t type, unsigned hash, size_t baselen) | 
|   | 
| static int  | _try_image_format (imageformat_t fmt, image_t *image, byte **pic) | 
|   | 
| static int  | try_image_format (imageformat_t fmt, image_t *image, byte **pic) | 
|   | 
| static int  | try_other_formats (imageformat_t orig, image_t *image, byte **pic) | 
|   | 
| static void  | get_image_dimensions (imageformat_t fmt, image_t *image) | 
|   | 
| static void  | r_texture_formats_changed (cvar_t *self) | 
|   | 
| qerror_t  | load_img (const char *name, image_t *image) | 
|   | 
| static qerror_t  | find_or_load_image (const char *name, size_t len, imagetype_t type, imageflags_t flags, image_t **image_p) | 
|   | 
| image_t *  | IMG_Find (const char *name, imagetype_t type, imageflags_t flags) | 
|   | 
| image_t *  | IMG_ForHandle (qhandle_t h) | 
|   | 
| qhandle_t  | R_RegisterImage (const char *name, imagetype_t type, imageflags_t flags, qerror_t *err_p) | 
|   | 
| qhandle_t  | R_RegisterRawImage (const char *name, int width, int height, byte *pic, imagetype_t type, imageflags_t flags) | 
|   | 
| void  | R_UnregisterImage (qhandle_t handle) | 
|   | 
| qboolean  | R_GetPicSize (int *w, int *h, qhandle_t pic) | 
|   | 
| void  | IMG_FreeUnused (void) | 
|   | 
| void  | IMG_FreeAll (void) | 
|   | 
| void  | IMG_GetPalette (void) | 
|   | 
| void  | IMG_Init (void) | 
|   | 
| void  | IMG_Shutdown (void) | 
|   | 
◆ FLOODFILL_FIFO_MASK
◆ FLOODFILL_FIFO_SIZE
      
        
          | #define FLOODFILL_FIFO_SIZE   0x1000 | 
        
      
 
 
◆ FLOODFILL_STEP
      
        
          | #define FLOODFILL_STEP | 
          ( | 
            | 
          off,  | 
        
        
           | 
           | 
            | 
          dx,  | 
        
        
           | 
           | 
            | 
          dy  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Value:    do { \
        if (pos[off] == fillcolor) { \
            pos[off] = 255; \
            fifo[inpt].x = x + (dx); \
            fifo[inpt].y = y + (dy); \
        } else if (pos[off] != 255) { \
            fdc = pos[off]; \
        } \
    } while(0)
 
Definition at line 68 of file images.c.
 
 
◆ IMG_LOAD
Value:    static qerror_t 
IMG_Load##x(
byte *rawdata, 
size_t rawlen, \
 
 
Definition at line 37 of file images.c.
 
 
◆ IMG_SAVE
Value:    static qerror_t IMG_Save##x(qhandle_t f, const char *filename, \
        byte *pic, 
int width, 
int height, 
int row_stride, 
int param)
 
 
Definition at line 41 of file images.c.
 
 
◆ R_COLORMAP_PCX
      
        
          | #define R_COLORMAP_PCX   "pics/colormap.pcx" | 
        
      
 
 
◆ RIMAGES_HASH
◆ _try_image_format()
  
  
      
        
          | static int _try_image_format  | 
          ( | 
          imageformat_t  | 
          fmt,  | 
         
        
           | 
           | 
          image_t *  | 
          image,  | 
         
        
           | 
           | 
          byte **  | 
          pic  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 787 of file images.c.
  794     len = FS_LoadFile(image->name, (
void **)&data);
 
  800     ret = 
img_loaders[fmt].load(data, len, image, pic);
 
  804     image->filepath[0] = 0;
 
  806         strcpy(image->filepath, image->name);
 
  808         image->last_modified = 0;
 
  811     return ret < 0 ? ret : fmt;
 
 
Referenced by find_or_load_image(), load_img(), and try_image_format().
 
 
◆ alloc_image()
◆ create_screenshot()
  
  
      
        
          | static qhandle_t create_screenshot  | 
          ( | 
          char *  | 
          buffer,  | 
         
        
           | 
           | 
          size_t  | 
          size,  | 
         
        
           | 
           | 
          const char *  | 
          name,  | 
         
        
           | 
           | 
          const char *  | 
          ext  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 415 of file images.c.
  425                                "screenshots/", name, 
ext);
 
  429     for (i = 0; i < 1000; i++) {
 
  431         ret = 
FS_FOpenFile(buffer, &f, FS_MODE_WRITE | FS_FLAG_EXCL);
 
  435         if (ret != Q_ERR_EXIST) {
 
  436             Com_EPrintf(
"Couldn't exclusively open %s for writing: %s\n",
 
  442     Com_EPrintf(
"All screenshot slots are full.\n");
 
 
Referenced by make_screenshot().
 
 
◆ find_or_load_image()
  
  
      
        
          | static qerror_t find_or_load_image  | 
          ( | 
          const char *  | 
          name,  | 
         
        
           | 
           | 
          size_t  | 
          len,  | 
         
        
           | 
           | 
          imagetype_t  | 
          type,  | 
         
        
           | 
           | 
          imageflags_t  | 
          flags,  | 
         
        
           | 
           | 
          image_t **  | 
          image_p  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 991 of file images.c.
 1005         return Q_ERR_NAMETOOSHORT;
 
 1007     if (name[len - 4] != 
'.') {
 
 1008         return Q_ERR_INVALID_PATH;
 
 1014     if ((image = 
lookup_image(name, type, hash, len - 4)) != NULL) {
 
 1015         image->flags |= flags & IF_PERMANENT;
 
 1018         return Q_ERR_SUCCESS;
 
 1024         return Q_ERR_OUT_OF_SLOTS;
 
 1028     if (!
vid_rtx->integer && (type != IT_PIC))
 
 1029         override_textures = 0;
 
 1031     for (
int use_override = override_textures; use_override >= 0; use_override--)
 
 1036             const char* last_slash = strrchr(name, 
'/');
 
 1042             strcpy(image->name, 
"overrides/");
 
 1043             strcat(image->name, last_slash);
 
 1044             image->baselen = strlen(image->name) - 4;
 
 1048             memcpy(image->name, name, len + 1);
 
 1049             image->baselen = len - 4;
 
 1052         image->flags = flags;
 
 1056         for (fmt = 0; fmt < IM_MAX; fmt++) {
 
 1057             if (!Q_stricmp(image->name + image->baselen + 1, 
img_loaders[fmt].ext)) {
 
 1065         if (fmt == IM_MAX) {
 
 1068             if (ret == Q_ERR_NOENT) {
 
 1070                 ret = Q_ERR_INVALID_PATH;
 
 1073         else if (override_textures) {
 
 1080             if (ret == Q_ERR_NOENT) {
 
 1087         image->last_modified = 0;
 
 1092             memcpy(image->name, name, len + 1);
 
 1093             image->baselen = len - 4;
 
 1098         if (fmt <= IM_WAL && ret > IM_WAL) {
 
 1107         memset(image, 0, 
sizeof(*image));
 
 1113     image->is_srgb = !!(flags & IF_SRGB);
 
 1119     return Q_ERR_SUCCESS;
 
 
Referenced by IMG_Find(), and R_RegisterImage().
 
 
◆ get_image_dimensions()
  
  
      
        
          | static void get_image_dimensions  | 
          ( | 
          imageformat_t  | 
          fmt,  | 
         
        
           | 
           | 
          image_t *  | 
          image  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 851 of file images.c.
  853     char        buffer[MAX_QPATH];
 
  860     memcpy(buffer, image->name, image->baselen + 1);
 
  864         memcpy(buffer + image->baselen + 1, 
"wal", 4);
 
  867             len = 
FS_Read(&mt, 
sizeof(mt), f);
 
  868             if (len == 
sizeof(mt)) {
 
  869                 w = LittleLong(mt.width);
 
  870                 h = LittleLong(mt.height);
 
  875         memcpy(buffer + image->baselen + 1, 
"pcx", 4);
 
  878             len = 
FS_Read(&pcx, 
sizeof(pcx), f);
 
  879             if (len == 
sizeof(pcx)) {
 
  880                 w = LittleShort(pcx.xmax) + 1;
 
  881                 h = LittleShort(pcx.ymax) + 1;
 
  887     if (w < 1 || h < 1 || w > 512 || h > 512) {
 
 
Referenced by find_or_load_image(), and load_img().
 
 
◆ IMG_DecodePCX()
  
  
      
        
          | static qerror_t IMG_DecodePCX  | 
          ( | 
          byte *  | 
          rawdata,  | 
         
        
           | 
           | 
          size_t  | 
          rawlen,  | 
         
        
           | 
           | 
          byte *  | 
          pixels,  | 
         
        
           | 
           | 
          byte *  | 
          palette,  | 
         
        
           | 
           | 
          int *  | 
          width,  | 
         
        
           | 
           | 
          int *  | 
          height  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 127 of file images.c.
  132     int     x, y, w, h, scan;
 
  133     int     dataByte, runLength;
 
  138     if (rawlen < 
sizeof(dpcx_t)) {
 
  139         return Q_ERR_FILE_TOO_SMALL;
 
  142     pcx = (dpcx_t *)rawdata;
 
  144     if (pcx->manufacturer != 10 || pcx->version != 5) {
 
  145         return Q_ERR_UNKNOWN_FORMAT;
 
  148     if (pcx->encoding != 1 || pcx->bits_per_pixel != 8) {
 
  149         return Q_ERR_INVALID_FORMAT;
 
  152     w = (LittleShort(pcx->xmax) - LittleShort(pcx->xmin)) + 1;
 
  153     h = (LittleShort(pcx->ymax) - LittleShort(pcx->ymin)) + 1;
 
  154     if (w < 1 || h < 1 || w > 640 || h > 480) {
 
  155         return Q_ERR_INVALID_FORMAT;
 
  158     if (pcx->color_planes != 1) {
 
  159         return Q_ERR_INVALID_FORMAT;
 
  162     scan = LittleShort(pcx->bytes_per_line);
 
  164         return Q_ERR_INVALID_FORMAT;
 
  172             return Q_ERR_FILE_TOO_SMALL;
 
  174         memcpy(palette, (
byte *)pcx + rawlen - 768, 768);
 
  182         end = (
byte *)pcx + rawlen;
 
  183         for (y = 0; y < h; y++, pixels += w) {
 
  184             for (x = 0; x < scan;) {
 
  186                     return Q_ERR_BAD_RLE_PACKET;
 
  189                 if ((dataByte & 0xC0) == 0xC0) {
 
  190                     runLength = dataByte & 0x3F;
 
  191                     if (x + runLength > scan)
 
  192                         return Q_ERR_BAD_RLE_PACKET;
 
  194                         return Q_ERR_BAD_RLE_PACKET;
 
  200                 while (runLength--) {
 
  202                         pixels[x] = dataByte;
 
  214     return Q_ERR_SUCCESS;
 
 
Referenced by IMG_GetPalette(), and IMG_LOAD().
 
 
◆ IMG_Find()
      
        
          | image_t* IMG_Find  | 
          ( | 
          const char *  | 
          name,  | 
        
        
           | 
           | 
          imagetype_t  | 
          type,  | 
        
        
           | 
           | 
          imageflags_t  | 
          flags  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 1122 of file images.c.
 1129         Com_Error(ERR_FATAL, 
"%s: NULL", __func__);
 
 1134     if (len >= MAX_QPATH) {
 
 1135         Com_Error(ERR_FATAL, 
"%s: oversize name", __func__);
 
 1144     if (ret != Q_ERR_NOENT) {
 
 1145         Com_EPrintf(
"Couldn't load %s: %s\n", name, 
Q_ErrorString(ret));
 
 
Referenced by bsp_mesh_register_textures(), GL_LoadWorld(), MOD_LoadMD2(), MOD_LoadMD2_GL(), MOD_LoadMD2_RTX(), MOD_LoadSP2(), ProcessTexinfo(), R_SetSky(), R_SetSky_GL(), R_SetSky_RTX(), vkpt_initialize_all(), vkpt_physical_sky_endRegistration(), and vkpt_textures_prefetch().
 
 
◆ IMG_FloodFill()
  
  
      
        
          | static void IMG_FloodFill  | 
          ( | 
          byte *  | 
          skin,  | 
         
        
           | 
           | 
          int  | 
          skinwidth,  | 
         
        
           | 
           | 
          int  | 
          skinheight  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 87 of file images.c.
   89     byte                fillcolor = *skin; 
 
   91     int                 inpt = 0, outpt = 0;
 
   96     if (fillcolor == filledcolor || fillcolor == 255) {
 
  100     fifo[inpt].
x = 0, fifo[inpt].
y = 0;
 
  103     while (outpt != inpt) {
 
  104         int         x = fifo[outpt].
x, y = fifo[outpt].
y;
 
  105         int         fdc = filledcolor;
 
  106         byte        *pos = &skin[x + skinwidth * y];
 
  115         skin[x + skinwidth * y] = fdc;
 
 
Referenced by IMG_LOAD().
 
 
◆ IMG_ForHandle()
      
        
          | image_t* IMG_ForHandle  | 
          ( | 
          qhandle_t  | 
          h | ) | 
           | 
        
      
 
Definition at line 1156 of file images.c.
 1159         Com_Error(ERR_FATAL, 
"%s: %d out of range", __func__, h);
 
 
Referenced by get_mesh_material(), R_AliasSetupSkin(), R_DrawChar(), R_DrawChar_GL(), R_DrawPic(), R_DrawPic_GL(), R_DrawPic_RTX(), R_DrawStretchPic(), R_DrawStretchPic_GL(), R_DrawString(), R_DrawString_GL(), R_GetPicSize(), R_TileClear(), R_TileClear_GL(), SCR_DrawActive(), and texnum_for_mesh().
 
 
◆ IMG_FreeAll()
◆ IMG_FreeUnused()
◆ IMG_GetPalette()
Definition at line 1376 of file images.c.
 1378     byte        pal[768], *src, *data;
 
 1398     for (i = 0, src = pal; i < 255; i++, src += 3) {
 
 1399         d_8to24table[i] = MakeColor(src[0], src[1], src[2], 255);
 
 1403     d_8to24table[i] = MakeColor(src[0], src[1], src[2], 0);
 
 
Referenced by GL_InitImages(), R_Init_RTX(), and R_InitImages().
 
 
◆ IMG_Init()
◆ IMG_List_f()
Definition at line 678 of file images.c.
  687         char path[MAX_OSPATH];
 
  691             Com_EPrintf(
"Error opening '%s'\n", path);
 
  697             if (!image->registration_sequence)
 
  701             sprintf(fmt, 
"%%-%ds, %%-%ds, (%% 5d %% 5d), sRGB:%%d\n", MAX_QPATH, MAX_QPATH);
 
  712         Com_Printf(
"Saved '%s'\n", path);
 
  717         static const char types[8] = 
"PFMSWY??";
 
  719         Com_Printf(
"------------------\n");
 
  723             if (!image->registration_sequence)
 
  726             Com_Printf(
"%c%c%c%c %4i %4i %s: %s\n",
 
  727                 types[image->type > IT_MAX ? IT_MAX : image->type],
 
  728                 (image->flags & IF_TRANSPARENT) ? 
'T' : 
' ',
 
  729                 (image->flags & IF_SCRAP) ? 
'S' : 
' ',
 
  730                 (image->flags & IF_PERMANENT) ? 
'*' : 
' ',
 
  732                 image->upload_height,
 
  733                 (image->flags & IF_PALETTED) ? 
"PAL" : 
"RGB",
 
  736             texels += image->upload_width * image->upload_height;
 
  739         Com_Printf(
"Total images: %d (out of %d slots)\n", count, 
r_numImages);
 
  740         Com_Printf(
"Total texels: %d (not counting mipmaps)\n", texels);
 
 
 
 
◆ IMG_LOAD() [1/3]
Definition at line 268 of file images.c.
  270     byte        buffer[640 * 480];
 
  278     if (image->type == IT_SKIN)
 
  281     *pic = IMG_AllocPixels(w * h * 4);
 
  283     image->upload_width = image->width = w;
 
  284     image->upload_height = image->height = h;
 
  285     image->flags |= 
IMG_Unpack8((uint32_t *)*pic, buffer, w, h);
 
  287     return Q_ERR_SUCCESS;
 
 
 
 
◆ IMG_LOAD() [2/3]
Definition at line 341 of file images.c.
  344     byte* data = stbi_load_from_memory(rawdata, rawlen, &w, &h, &
channels, 4);
 
  347         return Q_ERR_LIBRARY_ERROR;
 
  351     image->upload_width = image->width = w;
 
  352     image->upload_height = image->height = h;
 
  355         image->flags |= IF_OPAQUE;
 
  357     return Q_ERR_SUCCESS;
 
 
 
 
◆ IMG_LOAD() [3/3]
Definition at line 299 of file images.c.
  302     size_t      w, h, offset, size, endpos;
 
  304     if (rawlen < 
sizeof(miptex_t)) {
 
  305         return Q_ERR_FILE_TOO_SMALL;
 
  308     mt = (miptex_t *)rawdata;
 
  310     w = LittleLong(mt->width);
 
  311     h = LittleLong(mt->height);
 
  312     if (w < 1 || h < 1 || w > 512 || h > 512) {
 
  313         return Q_ERR_INVALID_FORMAT;
 
  318     offset = LittleLong(mt->offsets[0]);
 
  319     endpos = offset + size;
 
  320     if (endpos < offset || endpos > rawlen) {
 
  321         return Q_ERR_BAD_EXTENT;
 
  324     *pic = IMG_AllocPixels(size * 4);
 
  326     image->upload_width = image->width = w;
 
  327     image->upload_height = image->height = h;
 
  328     image->flags |= 
IMG_Unpack8((uint32_t *)*pic, (uint8_t *)mt + offset, w, h);
 
  330     return Q_ERR_SUCCESS;
 
 
 
 
◆ IMG_MipMap()
      
        
          | void IMG_MipMap  | 
          ( | 
          byte *  | 
          out,  | 
        
        
           | 
           | 
          byte *  | 
          in,  | 
        
        
           | 
           | 
          int  | 
          width,  | 
        
        
           | 
           | 
          int  | 
          height  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 623 of file images.c.
  630         for (j = 0; j < 
width; j += 8, out += 4, in += 8) {
 
  631             out[0] = (in[0] + in[4] + in[
width + 0] + in[
width + 4]) >> 2;
 
  632             out[1] = (in[1] + in[5] + in[
width + 1] + in[
width + 5]) >> 2;
 
  633             out[2] = (in[2] + in[6] + in[
width + 2] + in[
width + 6]) >> 2;
 
  634             out[3] = (in[3] + in[7] + in[
width + 3] + in[
width + 7]) >> 2;
 
 
Referenced by GL_Upload32(), and IMG_Load().
 
 
◆ IMG_ResampleTexture()
      
        
          | void IMG_ResampleTexture  | 
          ( | 
          const byte *  | 
          in,  | 
        
        
           | 
           | 
          int  | 
          inwidth,  | 
        
        
           | 
           | 
          int  | 
          inheight,  | 
        
        
           | 
           | 
          byte *  | 
          out,  | 
        
        
           | 
           | 
          int  | 
          outwidth,  | 
        
        
           | 
           | 
          int  | 
          outheight  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 577 of file images.c.
  581     const byte  *inrow1, *inrow2;
 
  582     unsigned    frac, fracstep;
 
  583     unsigned    p1[MAX_TEXTURE_SIZE], p2[MAX_TEXTURE_SIZE];
 
  584     const byte  *pix1, *pix2, *pix3, *pix4;
 
  587     if (outwidth > MAX_TEXTURE_SIZE) {
 
  588         Com_Error(ERR_FATAL, 
"%s: outwidth > %d", __func__, MAX_TEXTURE_SIZE);
 
  591     fracstep = inwidth * 0x10000 / outwidth;
 
  593     frac = fracstep >> 2;
 
  594     for (i = 0; i < outwidth; i++) {
 
  595         p1[i] = 4 * (frac >> 16);
 
  598     frac = 3 * (fracstep >> 2);
 
  599     for (i = 0; i < outwidth; i++) {
 
  600         p2[i] = 4 * (frac >> 16);
 
  604     heightScale = (float)inheight / outheight;
 
  606     for (i = 0; i < outheight; i++) {
 
  607         inrow1 = in + inwidth * (
int)((i + 0.25f) * heightScale);
 
  608         inrow2 = in + inwidth * (
int)((i + 0.75f) * heightScale);
 
  609         for (j = 0; j < outwidth; j++) {
 
  610             pix1 = inrow1 + p1[j];
 
  611             pix2 = inrow1 + p2[j];
 
  612             pix3 = inrow2 + p1[j];
 
  613             pix4 = inrow2 + p2[j];
 
  614             out[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2;
 
  615             out[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2;
 
  616             out[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2;
 
  617             out[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3]) >> 2;
 
 
Referenced by GL_Upload32(), and IMG_Load().
 
 
◆ IMG_SAVE() [1/3]
Definition at line 380 of file images.c.
  382     stbi_flip_vertically_on_write(1);
 
  386         return Q_ERR_SUCCESS;
 
  388     return Q_ERR_LIBRARY_ERROR;
 
 
 
 
◆ IMG_SAVE() [2/3]
Definition at line 392 of file images.c.
  394     stbi_flip_vertically_on_write(1);
 
  398         return Q_ERR_SUCCESS;
 
  400     return Q_ERR_LIBRARY_ERROR;
 
 
 
 
◆ IMG_SAVE() [3/3]
Definition at line 369 of file images.c.
  371     stbi_flip_vertically_on_write(1);
 
  375         return Q_ERR_SUCCESS;
 
  377     return Q_ERR_LIBRARY_ERROR;
 
 
 
 
◆ IMG_ScreenShot_f()
◆ IMG_ScreenShotJPG_f()
  
  
      
        
          | static void IMG_ScreenShotJPG_f  | 
          ( | 
          void  | 
           | ) | 
           | 
         
       
   | 
  
static   | 
  
 
Definition at line 533 of file images.c.
  538         Com_Printf(
"Usage: %s [name] [quality]\n", 
Cmd_Argv(0));
 
 
 
 
◆ IMG_ScreenShotPNG_f()
  
  
      
        
          | static void IMG_ScreenShotPNG_f  | 
          ( | 
          void  | 
           | ) | 
           | 
         
       
   | 
  
static   | 
  
 
Definition at line 551 of file images.c.
  556         Com_Printf(
"Usage: %s [name] [compression]\n", 
Cmd_Argv(0));
 
 
 
 
◆ IMG_ScreenShotTGA_f()
  
  
      
        
          | static void IMG_ScreenShotTGA_f  | 
          ( | 
          void  | 
           | ) | 
           | 
         
       
   | 
  
static   | 
  
 
 
◆ IMG_Shutdown()
◆ IMG_Unpack8()
  
  
      
        
          | static int IMG_Unpack8  | 
          ( | 
          uint32_t *  | 
          out,  | 
         
        
           | 
           | 
          const uint8_t *  | 
          in,  | 
         
        
           | 
           | 
          int  | 
          width,  | 
         
        
           | 
           | 
          int  | 
          height  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 222 of file images.c.
  225     qboolean    has_alpha = qfalse;
 
  227     for (y = 0; y < 
height; y++) {
 
  228         for (x = 0; x < 
width; x++) {
 
  234                 if (y > 0 && *(in - 
width) != 255)
 
  238                 else if (x > 0 && *(in - 1) != 255)
 
  240                 else if (x < 
width - 1 && *(in + 1) != 255)
 
  242                 else if (y > 0 && x > 0 && *(in - 
width - 1) != 255)
 
  243                     p = *(in - 
width - 1);
 
  244                 else if (y > 0 && x < 
width - 1 && *(in - 
width + 1) != 255)
 
  245                     p = *(in - 
width + 1);
 
  246                 else if (y < height - 1 && x > 0 && *(in + 
width - 1) != 255)
 
  247                     p = *(in + 
width - 1);
 
  249                     p = *(in + 
width + 1);
 
  263         return IF_PALETTED | IF_TRANSPARENT;
 
  265     return IF_PALETTED | IF_OPAQUE;
 
 
Referenced by IMG_LOAD().
 
 
◆ load_img()
      
        
          | qerror_t load_img  | 
          ( | 
          const char *  | 
          name,  | 
        
        
           | 
           | 
          image_t *  | 
          image  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 927 of file images.c.
  933     size_t len = strlen(name);
 
  937         return Q_ERR_NAMETOOSHORT;
 
  939     if (name[len - 4] != 
'.') {
 
  940         return Q_ERR_INVALID_PATH;
 
  943     memcpy(image->name, name, len + 1);
 
  944     image->baselen = len - 4;
 
  947     image->registration_sequence = 1;
 
  950     for (fmt = 0; fmt < IM_MAX; fmt++) {
 
  951         if (!Q_stricmp(image->name + image->baselen + 1, 
img_loaders[fmt].ext)) {
 
  961     if (ret == Q_ERR_NOENT) {
 
  968     if (fmt <= IM_WAL && ret > IM_WAL) {
 
  974     if (fmt <= IM_WAL && ret > IM_WAL) {
 
  979         memset(image, 0, 
sizeof(*image));
 
  983 #if USE_REF == REF_VKPT 
  984     image->pix_data = pic;
 
  987     return Q_ERR_SUCCESS;
 
 
Referenced by IMG_ReloadAll().
 
 
◆ lookup_image()
  
  
      
        
          | static image_t* lookup_image  | 
          ( | 
          const char *  | 
          name,  | 
         
        
           | 
           | 
          imagetype_t  | 
          type,  | 
         
        
           | 
           | 
          unsigned  | 
          hash,  | 
         
        
           | 
           | 
          size_t  | 
          baselen  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
 
◆ make_screenshot()
  
  
      
        
          | static void make_screenshot  | 
          ( | 
          const char *  | 
          name,  | 
         
        
           | 
           | 
          const char *  | 
          ext,  | 
         
        
           | 
           | 
          qerror_t(*)(qhandle_t, const char *, byte *, int, int, int, int)  | 
          save,  | 
         
        
           | 
           | 
          int  | 
          param  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 446 of file images.c.
  450     char        buffer[MAX_OSPATH];
 
  462     ret = save(f, buffer, pixels, w, h, rowbytes, param);
 
  463     FS_FreeTempMem(pixels);
 
  468         Com_EPrintf(
"Couldn't write %s: %s\n", buffer, 
Q_ErrorString(ret));
 
  470         Com_Printf(
"Wrote %s\n", buffer);
 
 
Referenced by IMG_ScreenShot_f(), IMG_ScreenShotJPG_f(), IMG_ScreenShotPNG_f(), and IMG_ScreenShotTGA_f().
 
 
◆ R_GetPicSize()
      
        
          | qboolean R_GetPicSize  | 
          ( | 
          int *  | 
          w,  | 
        
        
           | 
           | 
          int *  | 
          h,  | 
        
        
           | 
           | 
          qhandle_t  | 
          pic  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ R_RegisterImage()
      
        
          | qhandle_t R_RegisterImage  | 
          ( | 
          const char *  | 
          name,  | 
        
        
           | 
           | 
          imagetype_t  | 
          type,  | 
        
        
           | 
           | 
          imageflags_t  | 
          flags,  | 
        
        
           | 
           | 
          qerror_t *  | 
          err_p  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 1170 of file images.c.
 1174     char        fullname[MAX_QPATH];
 
 1181             *err_p = Q_ERR_NAMETOOSHORT;
 
 1188             *err_p = Q_ERR_AGAIN;
 
 1192     if (type == IT_SKIN) {
 
 1194     } 
else if (*name == 
'/' || *name == 
'\\') {
 
 1197         len = 
Q_concat(fullname, 
sizeof(fullname), 
"pics/", name, NULL);
 
 1198         if (len >= 
sizeof(fullname)) {
 
 1199             err = Q_ERR_NAMETOOLONG;
 
 1206     if (len >= 
sizeof(fullname)) {
 
 1207         err = Q_ERR_NAMETOOLONG;
 
 1214             *err_p = Q_ERR_SUCCESS;
 
 1222     else if (
err != Q_ERR_NOENT)
 
 
Referenced by Con_RegisterMedia(), and SCR_RegisterMedia().
 
 
◆ R_RegisterRawImage()
      
        
          | qhandle_t R_RegisterRawImage  | 
          ( | 
          const char *  | 
          name,  | 
        
        
           | 
           | 
          int  | 
          width,  | 
        
        
           | 
           | 
          int  | 
          height,  | 
        
        
           | 
           | 
          byte *  | 
          pic,  | 
        
        
           | 
           | 
          imagetype_t  | 
          type,  | 
        
        
           | 
           | 
          imageflags_t  | 
          flags  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 1228 of file images.c.
 1233     int len = strlen(name);
 
 1237     if ((image = 
lookup_image(name, type, hash, len)) != NULL) {
 
 1238         image->flags |= flags & IF_PERMANENT;
 
 1249     memcpy(image->name, name, len + 1);
 
 1250     image->baselen = len;
 
 1252     image->flags = flags;
 
 1254     image->last_modified = 0;
 
 1255     image->width = 
width;
 
 1257     image->upload_width = 
width;
 
 1258     image->upload_height = 
height;
 
 1262     image->is_srgb = !!(flags & IF_SRGB);
 
 
Referenced by SCR_ReadNextFrame().
 
 
◆ r_texture_formats_changed()
  
  
      
        
          | static void r_texture_formats_changed  | 
          ( | 
          cvar_t *  | 
          self | ) | 
           | 
         
       
   | 
  
static   | 
  
 
Definition at line 895 of file images.c.
  904     for (s = self->string; *s; s++) {
 
  906             case 't': 
case 'T': i = IM_TGA; 
break;
 
  907             case 'j': 
case 'J': i = IM_JPG; 
break;
 
  908             case 'p': 
case 'P': i = IM_PNG; 
break;
 
 
Referenced by IMG_Init().
 
 
◆ R_UnregisterImage()
      
        
          | void R_UnregisterImage  | 
          ( | 
          qhandle_t  | 
          handle | ) | 
           | 
        
      
 
 
◆ stbi_write()
◆ try_image_format()
  
  
      
        
          | static int try_image_format  | 
          ( | 
          imageformat_t  | 
          fmt,  | 
         
        
           | 
           | 
          image_t *  | 
          image,  | 
         
        
           | 
           | 
          byte **  | 
          pic  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
 
◆ try_other_formats()
  
  
      
        
          | static int try_other_formats  | 
          ( | 
          imageformat_t  | 
          orig,  | 
         
        
           | 
           | 
          image_t *  | 
          image,  | 
         
        
           | 
           | 
          byte **  | 
          pic  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
 
◆ d_8to24table
      
        
          | uint32_t d_8to24table[256] | 
        
      
 
Definition at line 654 of file images.c.
Referenced by cast_u32_to_f32_color(), CL_RailTrail(), GL_DrawBeams(), GL_DrawParticles(), IMG_GetPalette(), IMG_Unpack8(), R_AliasSetupBlend(), R_DrawBeam(), R_DrawFill8(), R_DrawFill8_GL(), R_DrawFill8_RTX(), R_DrawParticles(), and SCR_ReadNextFrame().
 
 
◆ ext
Definition at line 657 of file images.c.
Referenced by check_and_queue_download(), check_file_len(), CL_CheckDownloadExtension(), COM_DefaultExtension(), create_screenshot(), easy_open_read(), easy_open_write(), FS_Dir_f(), FS_EasyOpenFile(), FS_EasyWriteFile(), FS_ExtCmp(), FS_File_g(), get_vk_extension_list(), get_vk_layer_list(), init_vulkan(), make_screenshot(), and print_file_list().
 
 
◆ img_cmd
◆ img_loaders
      
        
          | const { ... }  img_loaders[IM_MAX] | 
        
      
 
Initial value:= {
    { "pcx", IMG_LoadPCX },
    { "wal", IMG_LoadWAL },
    { "tga", IMG_LoadSTB },
    { "jpg", IMG_LoadSTB },
    { "png", IMG_LoadSTB }
}
 
Referenced by _try_image_format(), find_or_load_image(), load_img(), and try_image_format().
 
 
◆ img_search
  
  
      
        
          | imageformat_t img_search[IM_MAX] | 
         
       
   | 
  
static   | 
  
 
 
◆ img_total
◆ load
      
        
          | qerror_t(* load) (byte *, size_t, image_t *, byte **) | 
        
      
 
 
◆ r_imageHash
◆ r_images
Definition at line 651 of file images.c.
Referenced by alloc_image(), enqueue_stretch_pic(), gl_anisotropy_changed(), gl_bilerp_chars_changed(), gl_bilerp_pics_changed(), gl_texturemode_changed(), IMG_ForHandle(), IMG_FreeAll(), IMG_FreeUnused(), IMG_List_f(), IMG_ReloadAll(), IMG_Unload_RTX(), prepare_ubo(), R_RegisterImage(), R_RegisterRawImage(), R_UnregisterImage(), vkpt_light_buffer_upload_to_staging(), vkpt_physical_sky_endRegistration(), vkpt_textures_end_registration(), vkpt_textures_update_descriptor_set(), and write_sprite_geometry().
 
 
◆ r_numImages
Definition at line 652 of file images.c.
Referenced by alloc_image(), gl_anisotropy_changed(), gl_bilerp_chars_changed(), gl_bilerp_pics_changed(), gl_texturemode_changed(), IMG_ForHandle(), IMG_FreeAll(), IMG_FreeUnused(), IMG_Init(), IMG_List_f(), IMG_ReloadAll(), IMG_Shutdown(), and R_RegisterImage().
 
 
◆ r_override_textures
  
  
      
        
          | cvar_t* r_override_textures | 
         
       
   | 
  
static   | 
  
 
 
◆ r_screenshot_compression
  
  
      
        
          | cvar_t* r_screenshot_compression | 
         
       
   | 
  
static   | 
  
 
 
◆ r_screenshot_format
  
  
      
        
          | cvar_t* r_screenshot_format | 
         
       
   | 
  
static   | 
  
 
 
◆ r_screenshot_quality
  
  
      
        
          | cvar_t* r_screenshot_quality | 
         
       
   | 
  
static   | 
  
 
 
◆ r_texture_formats
  
  
      
        
          | cvar_t* r_texture_formats | 
         
       
   | 
  
static   | 
  
 
 
◆ vid_rtx
 
 
static void r_texture_formats_changed(cvar_t *self)
 
qhandle_t FS_EasyOpenFile(char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext)
 
static cvar_t * r_screenshot_compression
 
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
 
ssize_t FS_Read(void *buf, size_t len, qhandle_t f)
 
qerror_t FS_LastModified(char const *file, uint64_t *last_modified)
 
channel_t channels[MAX_CHANNELS]
 
void(* IMG_Load)(image_t *image, byte *pic)
 
static cvar_t * r_screenshot_quality
 
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
 
const char * Q_ErrorString(qerror_t error)
 
static cvar_t * r_texture_formats
 
ssize_t FS_FPrintf(qhandle_t f, const char *format,...)
 
static void make_screenshot(const char *name, const char *ext, qerror_t(*save)(qhandle_t, const char *, byte *, int, int, int, int), int param)
 
static void IMG_List_f(void)
 
static void IMG_FloodFill(byte *skin, int skinwidth, int skinheight)
 
static image_t * alloc_image(void)
 
static const cmdreg_t img_cmd[]
 
static image_t * lookup_image(const char *name, imagetype_t type, unsigned hash, size_t baselen)
 
static int try_image_format(imageformat_t fmt, image_t *image, byte **pic)
 
static int IMG_Unpack8(uint32_t *out, const uint8_t *in, int width, int height)
 
static void IMG_ScreenShot_f(void)
 
void Cmd_Deregister(const cmdreg_t *reg)
 
static int _try_image_format(imageformat_t fmt, image_t *image, byte **pic)
 
ssize_t FS_FOpenFile(const char *name, qhandle_t *f, unsigned mode)
 
#define FLOODFILL_FIFO_MASK
 
size_t FS_NormalizePathBuffer(char *out, const char *in, size_t size)
 
void Com_Error(error_type_t type, const char *fmt,...)
 
static imageformat_t img_search[IM_MAX]
 
static cvar_t * r_override_textures
 
void stbi_write(void *context, void *data, int size)
 
static list_t r_imageHash[RIMAGES_HASH]
 
byte *(* IMG_ReadPixels)(int *width, int *height, int *rowbytes)
 
static void IMG_ScreenShotJPG_f(void)
 
#define FLOODFILL_FIFO_SIZE
 
void Cmd_Register(const cmdreg_t *reg)
 
static int try_other_formats(imageformat_t orig, image_t *image, byte **pic)
 
image_t r_images[MAX_RIMAGES]
 
void(* IMG_Unload)(image_t *image)
 
ssize_t FS_Write(const void *buf, size_t len, qhandle_t f)
 
static qerror_t find_or_load_image(const char *name, size_t len, imagetype_t type, imageflags_t flags, image_t **image_p)
 
static const struct @12 img_loaders[IM_MAX]
 
static ALCcontext * context
 
static void IMG_ScreenShotPNG_f(void)
 
int registration_sequence
 
#define FLOODFILL_STEP(off, dx, dy)
 
static qhandle_t create_screenshot(char *buffer, size_t size, const char *name, const char *ext)
 
size_t COM_DefaultExtension(char *path, const char *ext, size_t size)
 
image_t * IMG_ForHandle(qhandle_t h)
 
void IMG_FreeUnused(void)
 
void FS_FCloseFile(qhandle_t f)
 
size_t Q_concat(char *dest, size_t size,...)
 
static void IMG_ScreenShotTGA_f(void)
 
void Com_PageInMemory(void *buffer, size_t size)
 
CONST PIXELFORMATDESCRIPTOR int
 
static void get_image_dimensions(imageformat_t fmt, image_t *image)
 
static cvar_t * r_screenshot_format
 
size_t FS_NormalizePath(char *out, const char *in)
 
static qerror_t IMG_DecodePCX(byte *rawdata, size_t rawlen, byte *pixels, byte *palette, int *width, int *height)
 
uint32_t d_8to24table[256]