Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
image.cpp File Reference

Texture modifiers mainly applied on load. More...

#include <boost/algorithm/clamp.hpp>
#include <string.h>
#include <algorithm>
#include "SDL_opengl.h"
#include "inexor/network/SharedVar.hpp"
#include "inexor/shared/cube_endian.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/texture/image.hpp"
#include "inexor/texture/macros.hpp"
#include "inexor/texture/texsettings.hpp"

Functions

template<int BPP>
static void halvetexture (uchar *src, uint sw, uint sh, uint stride, uchar *dst)
 
template<int BPP>
static void shifttexture (uchar *src, uint sw, uint sh, uint stride, uchar *dst, uint dw, uint dh)
 
template<int BPP>
static void scaletexture (uchar *src, uint sw, uint sh, uint stride, uchar *dst, uint dw, uint dh)
 
void scaletexture (uchar *src, uint sw, uint sh, uint bpp, uint pitch, uchar *dst, uint dw, uint dh)
 
void resizetexture (int w, int h, bool mipmap, bool canreduce, GLenum target, int compress, int &tw, int &th)
 
static void reorienttexture (uchar *src, int sw, int sh, int bpp, int stride, uchar *dst, bool flipx, bool flipy, bool swapxy, bool normals=false)
 
static void reorients3tc (GLenum format, int blocksize, int w, int h, uchar *src, uchar *dst, bool flipx, bool flipy, bool swapxy, bool normals=false)
 
void texreorient (ImageData &s, bool flipx, bool flipy, bool swapxy, bool isnormalmap)
 
void texrotate (ImageData &s, int numrots, bool isnormalmap)
 
void texoffset (ImageData &s, int xoffset, int yoffset)
 
void texmad (ImageData &s, const vec &mul, const vec &add)
 
void texcolorify (ImageData &s, const vec &color, vec weights)
 
void texcolormask (ImageData &s, const vec &color1, const vec &color2)
 
void texdup (ImageData &s, int srcchan, int dstchan)
 
void texmix (ImageData &s, int c1, int c2, int c3, int c4)
 
void texgrey (ImageData &s)
 
void texpremul (ImageData &s)
 
void texagrad (ImageData &s, float x2, float y2, float x1, float y1)
 
void texflip (ImageData &s)
 
void texnormal (ImageData &s, int emphasis)
 
template<int n, int bpp, bool normals>
static void blurtexture (int w, int h, uchar *dst, const uchar *src, int margin)
 
void blurtexture (int n, int bpp, int w, int h, uchar *dst, const uchar *src, int margin)
 
void blurnormals (int n, int w, int h, bvec *dst, const bvec *src, int margin)
 
void texblur (ImageData &s, int n, int r)
 
void forcergbimage (ImageData &s)
 
void scaleimage (ImageData &s, int w, int h)
 

Detailed Description

Texture modifiers mainly applied on load.

Function Documentation

void blurnormals ( int  n,
int  w,
int  h,
bvec dst,
const bvec src,
int  margin 
)
template<int n, int bpp, bool normals>
static void blurtexture ( int  w,
int  h,
uchar dst,
const uchar src,
int  margin 
)
static
void blurtexture ( int  n,
int  bpp,
int  w,
int  h,
uchar dst,
const uchar src,
int  margin 
)
void forcergbimage ( ImageData s)
template<int BPP>
static void halvetexture ( uchar src,
uint  sw,
uint  sh,
uint  stride,
uchar dst 
)
static

References loopi().

static void reorients3tc ( GLenum  format,
int  blocksize,
int  w,
int  h,
uchar src,
uchar dst,
bool  flipx,
bool  flipy,
bool  swapxy,
bool  normals = false 
)
static
static void reorienttexture ( uchar src,
int  sw,
int  sh,
int  bpp,
int  stride,
uchar dst,
bool  flipx,
bool  flipy,
bool  swapxy,
bool  normals = false 
)
inlinestatic

References gle::end(), loopi(), loopk, and normals.

Referenced by texreorient().

void resizetexture ( int  w,
int  h,
bool  mipmap,
bool  canreduce,
GLenum  target,
int  compress,
int &  tw,
int &  th 
)
void scaleimage ( ImageData s,
int  w,
int  h 
)
template<int BPP>
static void scaletexture ( uchar src,
uint  sw,
uint  sh,
uint  stride,
uchar dst,
uint  dw,
uint  dh 
)
static
void scaletexture ( uchar src,
uint  sw,
uint  sh,
uint  bpp,
uint  pitch,
uchar dst,
uint  dw,
uint  dh 
)
template<int BPP>
static void shifttexture ( uchar src,
uint  sw,
uint  sh,
uint  stride,
uchar dst,
uint  dw,
uint  dh 
)
static
void texagrad ( ImageData s,
float  x2,
float  y2,
float  x1,
float  y1 
)
void texblur ( ImageData s,
int  n,
int  r 
)
void texcolorify ( ImageData s,
const vec color,
vec  weights 
)

References ImageData::bpp, f(), vec::iszero(), loopk, and writetex.

Referenced by texturedata().

void texcolormask ( ImageData s,
const vec color1,
const vec color2 
)
void texdup ( ImageData s,
int  srcchan,
int  dstchan 
)

References ImageData::bpp, inexor::rpc::max(), and writetex.

Referenced by texturedata().

void texflip ( ImageData s)
void texgrey ( ImageData s)
void texmad ( ImageData s,
const vec mul,
const vec add 
)
void texmix ( ImageData s,
int  c1,
int  c2,
int  c3,
int  c4 
)
void texnormal ( ImageData s,
int  emphasis 
)
void texoffset ( ImageData s,
int  xoffset,
int  yoffset 
)
void texpremul ( ImageData s)

References ImageData::bpp, and writetex.

Referenced by texturedata().

void texreorient ( ImageData s,
bool  flipx,
bool  flipy,
bool  swapxy,
bool  isnormalmap = false 
)
Parameters
sThe texture/image which you want to orientate
flipxFlip from x axis
flipyFlip from y axis
swapxySwap on both x and y
isnormalmapspecifies whether you pass in a normal map and hence need to shift the blue/red channels accordingly.

References ImageData::align, ImageData::bpp, ImageData::calclevelsize(), ImageData::compressed, hmap::d, ImageData::data, ImageData::h, ImageData::levels, loopi(), inexor::rpc::max(), ImageData::pitch, reorients3tc(), reorienttexture(), ImageData::replace(), and ImageData::w.

Referenced by cubemaploadwildcard(), texrotate(), and texturedata().

void texrotate ( ImageData s,
int  numrots,
bool  isnormalmap 
)
Parameters
isnormalmapspecifies whether you pass in a normal map and hence need to shift the blue/red channels accordingly.

References texreorient().

Referenced by texturedata().