]> icculus.org git repositories - divverent/darkplaces.git/blob - image.h
tweaked GLSL lighting shader to get a bit more performance (at least 7%) on GF6 by...
[divverent/darkplaces.git] / image.h
1
2 #ifndef IMAGE_H
3 #define IMAGE_H
4
5
6 extern int image_width, image_height;
7
8
9 // swizzle components (even converting number of components) and flip images
10 // (warning: input must be different than output due to non-linear read/write)
11 // (tip: component indices can contain values | 0x80000000 to tell it to
12 // store them directly into output, so 255 | 0x80000000 would write 255)
13 void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int inputwidth, int inputheight, qboolean inputflipx, qboolean inputflipy, qboolean inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices);
14
15 // applies gamma correction to RGB pixels, in can be the same as out
16 void Image_GammaRemapRGB(const qbyte *in, qbyte *out, int pixels, const qbyte *gammar, const qbyte *gammag, const qbyte *gammab);
17
18 // converts 8bit image data to RGBA, in can not be the same as out
19 void Image_Copy8bitRGBA(const qbyte *in, qbyte *out, int pixels, const unsigned int *pal);
20
21 // makes a RGBA mask from RGBA input, in can be the same as out
22 int image_makemask (const qbyte *in, qbyte *out, int size);
23
24 qbyte *LoadTGA (const qbyte *f, int matchwidth, int matchheight);
25
26 // loads a texture, as pixel data
27 qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth, int matchheight);
28
29 // loads a texture, as a texture
30 rtexture_t *loadtextureimage (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags);
31
32 // loads a texture's alpha mask, as pixel data
33 qbyte *loadimagepixelsmask (const char *filename, qboolean complain, int matchwidth, int matchheight);
34
35 // loads a texture's alpha mask, as a texture
36 rtexture_t *loadtextureimagemask (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags);
37
38 // loads a texture and it's alpha mask at once (NULL if it has no translucent pixels)
39 extern rtexture_t *image_masktex;
40 extern rtexture_t *image_nmaptex;
41 rtexture_t *loadtextureimagewithmask (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags);
42 rtexture_t *loadtextureimagewithmaskandnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale);
43 rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale);
44
45 // writes a RGB TGA that is already upside down (which TGA wants)
46 qboolean Image_WriteTGARGB_preflipped (const char *filename, int width, int height, const qbyte *data, qbyte *buffer);
47
48 // writes a RGB TGA
49 void Image_WriteTGARGB (const char *filename, int width, int height, const qbyte *data);
50
51 // writes a RGBA TGA
52 void Image_WriteTGARGBA (const char *filename, int width, int height, const qbyte *data);
53
54 // returns true if the image has some translucent pixels
55 qboolean Image_CheckAlpha(const qbyte *data, int size, qboolean rgba);
56
57 // resizes the image (in can not be the same as out)
58 void Image_Resample (const void *indata, int inwidth, int inheight, int indepth, void *outdata, int outwidth, int outheight, int outdepth, int bytesperpixel, int quality);
59
60 // scales the image down by a power of 2 (in can be the same as out)
61 void Image_MipReduce(const qbyte *in, qbyte *out, int *width, int *height, int *depth, int destwidth, int destheight, int destdepth, int bytesperpixel);
62
63 // only used by menuplyr coloring
64 qbyte *LoadLMP (const qbyte *f, int matchwidth, int matchheight, qboolean loadAs8Bit);
65
66 void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale);
67
68 typedef struct imageskin_s
69 {
70         qbyte *basepixels;int basepixels_width;int basepixels_height;
71         qbyte *nmappixels;int nmappixels_width;int nmappixels_height;
72         qbyte *glowpixels;int glowpixels_width;int glowpixels_height;
73         qbyte *glosspixels;int glosspixels_width;int glosspixels_height;
74         qbyte *pantspixels;int pantspixels_width;int pantspixels_height;
75         qbyte *shirtpixels;int shirtpixels_width;int shirtpixels_height;
76         qbyte *maskpixels;int maskpixels_width;int maskpixels_height;
77 }
78 imageskin_t;
79
80 int image_loadskin(imageskin_t *s, char *name);
81 void image_freeskin(imageskin_t *s);
82
83 #endif
84