hls_color_texture.h
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_HLS_COLOR_TEXTURE_H
00025 #define NL_HLS_COLOR_TEXTURE_H
00026
00027 #include "nel/misc/types_nl.h"
00028 #include <vector>
00029 #include <string>
00030
00031
00032 namespace NLMISC
00033 {
00034 class CBitmap;
00035 class IStream;
00036 class CRGBA;
00037 }
00038
00039
00040 namespace NL3D
00041 {
00042
00043
00044 using NLMISC::CRGBA;
00045
00046
00047
00048 class CHLSColorDelta
00049 {
00050 public:
00051 uint8 DHue;
00052
00053 sint8 DLum;
00054
00055 sint8 DSat;
00056
00057 void serial(NLMISC::IStream &f);
00058 };
00059
00060
00061
00068 class CHLSColorTexture
00069 {
00070 public:
00071 CHLSColorTexture();
00072
00074 void reset();
00075
00079 void setBitmap(const NLMISC::CBitmap &bmp);
00080
00085 void addMask(const NLMISC::CBitmap &bmp, uint threshold= 15);
00086
00088 uint getNumMasks() const {return _Masks.size();}
00089
00094 void buildColorVersion(const CHLSColorDelta *colDeltaList, NLMISC::CBitmap &out);
00095
00096
00097 void serial(NLMISC::IStream &f);
00098
00099
00100
00101 private:
00102 struct CMask
00103 {
00104 uint32 FullBlockIndex;
00105 uint32 MixtBlockIndex;
00107 std::vector<uint8> Data;
00108
00109
00110 void setBit(uint bitId);
00111
00112 void serial(NLMISC::IStream &f);
00113 };
00114
00115
00116 struct CVectorInt
00117 {
00118 sint x,y,z;
00119 };
00120
00121
00122 private:
00123 uint32 _Width, _Height, _NumMipMap;
00124 uint32 _BlockToCompressIndex;
00125
00126 std::vector<uint8> _Texture;
00127
00128 std::vector<CMask> _Masks;
00129
00130
00131 private:
00133 static void uncompressBlockRGB(const uint8* srcDXTC, CRGBA *dstRGBA);
00134
00136 static void computeMinMax(sint *diffBlock, CVectorInt &v, sint mean[3], sint rgb0[3], sint rgb1[3]);
00137
00139 static void colorizeDXTCBlockRGB(const uint8 *srcPtr, uint8 *dstPtr, uint8 dHue, uint dLum, uint dSat);
00140
00141 public:
00143 static void compressBlockRGB(CRGBA *srcRGBA, uint8* dstDXTC);
00144
00145 };
00146
00147
00148
00149 }
00150
00151
00152 #endif // NL_HLS_COLOR_TEXTURE_H
00153
00154