hls_color_texture.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000-2002 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
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     // -128..+127. to be extended to -255..+255
00053     sint8   DLum;
00054     // -128..+127. to be extended to -255..+255
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         // set the Data bit to 1
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     // The DXTC5 data. Also contains bits from _BlockToCompressIndex to end (rounded to uint32)
00126     std::vector<uint8>      _Texture;
00127     // Masks
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 } // NL3D
00150 
00151 
00152 #endif // NL_HLS_COLOR_TEXTURE_H
00153 
00154 /* End of hls_color_texture.h */

Generated on Thu Jan 7 08:26:18 2010 for NeL by  doxygen 1.6.1