GEL  2
GEL is a library for Geometry and Linear Algebra
/Users/jab/Documents/Teaching/02585/GEL2_and_demos/GEL/src/GLGraphics/image_DXT.h
00001 /*
00002         Jonathan Dummer
00003         2007-07-31-10.32
00004 
00005         simple DXT compression / decompression code
00006 
00007         public domain
00008 */
00009 
00010 #ifndef HEADER_IMAGE_DXT
00011 #define HEADER_IMAGE_DXT
00012 
00018 int
00019 save_image_as_DDS
00020 (
00021     const char *filename,
00022     int width, int height, int channels,
00023     const unsigned char *const data
00024 );
00025 
00029 unsigned char*
00030 convert_image_to_DXT1
00031 (
00032     const unsigned char *const uncompressed,
00033     int width, int height, int channels,
00034     int *out_size
00035 );
00036 
00040 unsigned char*
00041 convert_image_to_DXT5
00042 (
00043     const unsigned char *const uncompressed,
00044     int width, int height, int channels,
00045     int *out_size
00046 );
00047 
00049 typedef struct
00050 {
00051     unsigned int    dwMagic;
00052     unsigned int    dwSize;
00053     unsigned int    dwFlags;
00054     unsigned int    dwHeight;
00055     unsigned int    dwWidth;
00056     unsigned int    dwPitchOrLinearSize;
00057     unsigned int    dwDepth;
00058     unsigned int    dwMipMapCount;
00059     unsigned int    dwReserved1[ 11 ];
00060 
00061     /*  DDPIXELFORMAT   */
00062     struct
00063     {
00064         unsigned int    dwSize;
00065         unsigned int    dwFlags;
00066         unsigned int    dwFourCC;
00067         unsigned int    dwRGBBitCount;
00068         unsigned int    dwRBitMask;
00069         unsigned int    dwGBitMask;
00070         unsigned int    dwBBitMask;
00071         unsigned int    dwAlphaBitMask;
00072     }
00073     sPixelFormat;
00074 
00075     /*  DDCAPS2 */
00076     struct
00077     {
00078         unsigned int    dwCaps1;
00079         unsigned int    dwCaps2;
00080         unsigned int    dwDDSX;
00081         unsigned int    dwReserved;
00082     }
00083     sCaps;
00084     unsigned int    dwReserved2;
00085 }
00086 DDS_header ;
00087 
00088 /*      the following constants were copied directly off the MSDN website       */
00089 
00090 /*      The dwFlags member of the original DDSURFACEDESC2 structure
00091         can be set to one or more of the following values.      */
00092 #define DDSD_CAPS       0x00000001
00093 #define DDSD_HEIGHT     0x00000002
00094 #define DDSD_WIDTH      0x00000004
00095 #define DDSD_PITCH      0x00000008
00096 #define DDSD_PIXELFORMAT        0x00001000
00097 #define DDSD_MIPMAPCOUNT        0x00020000
00098 #define DDSD_LINEARSIZE 0x00080000
00099 #define DDSD_DEPTH      0x00800000
00100 
00101 /*      DirectDraw Pixel Format */
00102 #define DDPF_ALPHAPIXELS        0x00000001
00103 #define DDPF_FOURCC     0x00000004
00104 #define DDPF_RGB        0x00000040
00105 
00106 /*      The dwCaps1 member of the DDSCAPS2 structure can be
00107         set to one or more of the following values.     */
00108 #define DDSCAPS_COMPLEX 0x00000008
00109 #define DDSCAPS_TEXTURE 0x00001000
00110 #define DDSCAPS_MIPMAP  0x00400000
00111 
00112 /*      The dwCaps2 member of the DDSCAPS2 structure can be
00113         set to one or more of the following values.             */
00114 #define DDSCAPS2_CUBEMAP        0x00000200
00115 #define DDSCAPS2_CUBEMAP_POSITIVEX      0x00000400
00116 #define DDSCAPS2_CUBEMAP_NEGATIVEX      0x00000800
00117 #define DDSCAPS2_CUBEMAP_POSITIVEY      0x00001000
00118 #define DDSCAPS2_CUBEMAP_NEGATIVEY      0x00002000
00119 #define DDSCAPS2_CUBEMAP_POSITIVEZ      0x00004000
00120 #define DDSCAPS2_CUBEMAP_NEGATIVEZ      0x00008000
00121 #define DDSCAPS2_VOLUME 0x00200000
00122 
00123 #endif /* HEADER_IMAGE_DXT      */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations