Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_IMAGELOADER_DDS_H__
00009 #define __SP_IMAGELOADER_DDS_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_TEXLOADER_DDS
00015
00016
00017 #include "FileFormats/Image/spImageFormatInterfaces.hpp"
00018
00019
00020 namespace sp
00021 {
00022 namespace video
00023 {
00024
00025
00026 class SP_EXPORT ImageLoaderDDS : public ImageLoader
00027 {
00028
00029 public:
00030
00031 ImageLoaderDDS(io::File* File);
00032 ~ImageLoaderDDS();
00033
00034 SImageDataRead* loadImageData();
00035
00036 private:
00037
00038
00039
00040 enum EFourCCTypesDDS
00041 {
00042 FOURCC_NONE,
00043 FOURCC_DXT1,
00044 FOURCC_DXT2,
00045 FOURCC_DXT3,
00046 FOURCC_DXT4,
00047 FOURCC_DXT5,
00048 FOURCC_DX10,
00049 FOURCC_BC4U,
00050 FOURCC_BC4S,
00051 FOURCC_BC5S,
00052 FOURCC_ATI2,
00053 FOURCC_RGBG,
00054 FOURCC_GRGB,
00055 FOURCC_UYVY,
00056 FOURCC_YUY2,
00057 FOURCC_36,
00058 FOURCC_110,
00059 FOURCC_111,
00060 FOURCC_112,
00061 FOURCC_113,
00062 FOURCC_114,
00063 FOURCC_115,
00064 FOURCC_116,
00065 FOURCC_117,
00066 };
00067
00068 enum EImageFlagsDDS
00069 {
00070
00071 DDSFLAG_MIPMAPS = 0x00020000,
00072 DDSFLAG_DEPTH = 0x00800000,
00073
00074
00075 DDSFLAG_ALPHA = 0x00000001,
00076 DDSFLAG_COMPRESSED = 0x00000004,
00077
00078
00079 DDSFLAG_CUBEMAP = 0x00000200,
00080 };
00081
00082
00083
00084 #if defined(_MSC_VER)
00085 # pragma pack(push, packing)
00086 # pragma pack(1)
00087 # define SP_PACK_STRUCT
00088 #elif defined(__GNUC__)
00089 # define SP_PACK_STRUCT __attribute__((packed))
00090 #else
00091 # define SP_PACK_STRUCT
00092 #endif
00093
00094 struct SPixelFormatDDS
00095 {
00096 s32 StructSize;
00097 s32 Flags;
00098 s32 FourCC;
00099 s32 RGBBitCount;
00100 s32 RBitMask;
00101 s32 GBitMask;
00102 s32 BBitMask;
00103 s32 ABitMask;
00104 }
00105 SP_PACK_STRUCT;
00106
00107 struct SHeaderDDS
00108 {
00109 s32 StructSize;
00110 s32 Flags;
00111 s32 Height;
00112 s32 Width;
00113 s32 Pitch;
00114 s32 Depth;
00115 s32 MipMapCount;
00116 s32 Reserved1[11];
00117 SPixelFormatDDS Format;
00118 s32 SurfaceFlags;
00119 s32 CubeMapFlags;
00120 s32 Reserved2[3];
00121 }
00122 SP_PACK_STRUCT;
00123
00124 struct SHeaderDX10DDS
00125 {
00126 s32 Format;
00127 s32 Dimension;
00128 u32 MiscFlag;
00129 u32 ArraySize;
00130 u32 Reserved;
00131 }
00132 SP_PACK_STRUCT;
00133
00134 #ifdef _MSC_VER
00135 # pragma pack(pop, packing)
00136 #endif
00137
00138 #undef SP_PACK_STRUCT
00139
00140
00141
00142 bool readHeader();
00143 bool readBody();
00144
00145 bool updateFourCCType();
00146
00147 bool readUncompressed();
00148 bool readCompressed();
00149
00150 video::color get16BitColor(u16 Color) const;
00151 video::color getInterpolatedColor(const video::color &ColorA, const video::color &ColorB) const;
00152
00153 u8 calcColorProc1(s32 c0, s32 c1) const;
00154 u8 calcColorProc2(s32 c0, s32 c1) const;
00155
00156 u8 get4BitAlpha(u32 &BitAlpha) const;
00157
00158
00159
00160 SHeaderDDS MainHeader_;
00161 SHeaderDX10DDS MainHeaderEx_;
00162
00163 bool isHeaderDX10_;
00164 bool isMipMapped_;
00165 bool isDepth_;
00166 bool isAlpha_;
00167 bool isCompressed_;
00168 bool isCubeMap_;
00169
00170 EFourCCTypesDDS FourCC_;
00171 io::stringc FourCCName_;
00172
00173 SImageDataRead* TexData_;
00174 u32 ImageBufferSize_;
00175
00176 };
00177
00178
00179 }
00180
00181 }
00182
00183
00184 #endif
00185
00186 #endif
00187
00188
00189
00190