Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributors: Amorilia (amorilia@users.sourceforge.net) 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00028 /* 00029 * This file is based on a similar file from the NVIDIA texture tools 00030 * (http://nvidia-texture-tools.googlecode.com/) 00031 * 00032 * Original license from NVIDIA follows. 00033 */ 00034 00035 // This code is in the public domain -- castanyo@yahoo.es 00036 00037 #ifndef _DDS_COLORBLOCK_H 00038 #define _DDS_COLORBLOCK_H 00039 00040 #include <Color.h> 00041 #include <Image.h> 00042 00044 struct ColorBlock 00045 { 00046 ColorBlock(); 00047 ColorBlock(const uint * linearImage); 00048 ColorBlock(const ColorBlock & block); 00049 ColorBlock(const Image * img, uint x, uint y); 00050 00051 void init(const Image * img, uint x, uint y); 00052 void init(uint w, uint h, const uint * data, uint x, uint y); 00053 void init(uint w, uint h, const float * data, uint x, uint y); 00054 00055 void swizzle(uint x, uint y, uint z, uint w); // 0=r, 1=g, 2=b, 3=a, 4=0xFF, 5=0 00056 00057 bool isSingleColor(Color32 mask = Color32(0xFF, 0xFF, 0xFF, 0x00)) const; 00058 bool hasAlpha() const; 00059 00060 00061 // Accessors 00062 const Color32 * colors() const; 00063 00064 Color32 color(uint i) const; 00065 Color32 & color(uint i); 00066 00067 Color32 color(uint x, uint y) const; 00068 Color32 & color(uint x, uint y); 00069 00070 private: 00071 00072 Color32 m_color[4*4]; 00073 00074 }; 00075 00076 00078 inline const Color32 * ColorBlock::colors() const 00079 { 00080 return m_color; 00081 } 00082 00084 inline Color32 ColorBlock::color(uint i) const 00085 { 00086 return m_color[i]; 00087 } 00088 00090 inline Color32 & ColorBlock::color(uint i) 00091 { 00092 return m_color[i]; 00093 } 00094 00096 inline Color32 ColorBlock::color(uint x, uint y) const 00097 { 00098 return m_color[y * 4 + x]; 00099 } 00100 00102 inline Color32 & ColorBlock::color(uint x, uint y) 00103 { 00104 return m_color[y * 4 + x]; 00105 } 00106 00107 #endif // _DDS_COLORBLOCK_H