1 /* 2 * PNG loader library for OpenGL v1.46 (02/06/14) 3 * by Ben Wyatt ben@wyatt100.freeserve.co.uk 4 * Using LibPNG 1.0.2 and ZLib 1.1.3 5 * 6 * This software is provided 'as-is', without any express or implied warranty. 7 * In no event will the author be held liable for any damages arising from the 8 * use of this software. 9 * 10 * Permission is hereby granted to use, copy, modify, and distribute this 11 * source code, or portions hereof, for any purpose, without fee, subject to 12 * the following restrictions: 13 * 14 * 1. The origin of this source code must not be misrepresented. You must not 15 * claim that you wrote the original software. If you use this software in 16 * a product, an acknowledgment in the product documentation would be 17 * appreciated but is not required. 18 * 2. Altered versions must be plainly marked as such and must not be 19 * misrepresented as being the original source. 20 * 3. This notice must not be removed or altered from any source distribution. 21 */ 22 23 #ifndef _GLPNG_H_ 24 #define _GLPNG_H_ 25 26 #include <stdio.h> 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #ifdef _MSC_VER 33 #ifdef _DEBUG 34 #pragma comment (lib, "glpngd.lib") 35 #else 36 #pragma comment (lib, "glpng.lib") 37 #endif 38 #endif 39 40 /* XXX This is from Win32's <windef.h> */ 41 #ifndef APIENTRY 42 #if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) 43 #define APIENTRY __stdcall 44 #else 45 #define APIENTRY 46 #endif 47 #endif 48 49 /* Mipmapping parameters */ 50 #define PNG_NOMIPMAPS 0 /* No mipmapping */ 51 #define PNG_BUILDMIPMAPS -1 /* Calls a clone of gluBuild2DMipmaps() */ 52 #define PNG_SIMPLEMIPMAPS -2 /* Generates mipmaps without filtering */ 53 54 /* Who needs an "S" anyway? */ 55 #define PNG_NOMIPMAP PNG_NOMIPMAPS 56 #define PNG_BUILDMIPMAP PNG_BUILDMIPMAPS 57 #define PNG_SIMPLEMIPMAP PNG_SIMPLEMIPMAPS 58 59 /* Transparency parameters */ 60 #define PNG_LUMINANCEALPHA -4 61 #define PNG_CALLBACKT -3 /* Call the callback function to generate alpha */ 62 #define PNG_ALPHA -2 /* Use alpha channel in PNG file, if there is one */ 63 #define PNG_SOLID -1 /* No transparency */ 64 #define PNG_STENCIL 0 /* Sets alpha to 0 for r=g=b=0, 1 otherwise */ 65 #define PNG_BLEND1 1 /* a = r+g+b */ 66 #define PNG_BLEND2 2 /* a = (r+g+b)/2 */ 67 #define PNG_BLEND3 3 /* a = (r+g+b)/3 */ 68 #define PNG_BLEND4 4 /* a = r*r+g*g+b*b */ 69 #define PNG_BLEND5 5 /* a = (r*r+g*g+b*b)/2 */ 70 #define PNG_BLEND6 6 /* a = (r*r+g*g+b*b)/3 */ 71 #define PNG_BLEND7 7 /* a = (r*r+g*g+b*b)/4 */ 72 #define PNG_BLEND8 8 /* a = sqrt(r*r+g*g+b*b) */ 73 74 typedef struct { 75 unsigned int Width; 76 unsigned int Height; 77 unsigned int Depth; 78 unsigned int Alpha; 79 } pngInfo; 80 81 typedef struct { 82 unsigned int Width; 83 unsigned int Height; 84 unsigned int Depth; 85 unsigned int Alpha; 86 87 unsigned int Components; 88 unsigned char *Data; 89 unsigned char *Palette; 90 } pngRawInfo; 91 92 extern int APIENTRY pngLoadRaw(const char *filename, pngRawInfo *rawinfo); 93 extern int APIENTRY pngLoadRawF(FILE *file, pngRawInfo *rawinfo); 94 95 extern int APIENTRY pngLoad(const char *filename, int mipmap, int trans, pngInfo *info); 96 extern int APIENTRY pngLoadF(FILE *file, int mipmap, int trans, pngInfo *info); 97 extern int APIENTRY pngLoadMem(const char *mem, int size, int mipmap, int trans, pngInfo *info); 98 99 extern unsigned int APIENTRY pngBind(const char *filename, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter); 100 extern unsigned int APIENTRY pngBindF(FILE *file, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter); 101 extern unsigned int APIENTRY pngBindMem(const char *mem, int size, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter); 102 103 extern void APIENTRY pngSetStencil(unsigned char red, unsigned char green, unsigned char blue); 104 extern void APIENTRY pngSetAlphaCallback(unsigned char (*callback)(unsigned char red, unsigned char green, unsigned char blue)); 105 extern void APIENTRY pngSetViewingGamma(double viewingGamma); 106 extern void APIENTRY pngSetStandardOrientation(int standardorientation); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 #endif 113