|
Blender
V2.59
|
00001 /* 00002 * $Id: Image.h 36541 2011-05-07 20:53:49Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributors: Amorilia (amorilia@users.sourceforge.net) 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 /* 00031 * This file is based on a similar file from the NVIDIA texture tools 00032 * (http://nvidia-texture-tools.googlecode.com/) 00033 * 00034 * Original license from NVIDIA follows. 00035 */ 00036 00037 // This code is in the public domain -- castanyo@yahoo.es 00038 00039 #ifndef _DDS_IMAGE_H 00040 #define _DDS_IMAGE_H 00041 00042 #include <Common.h> 00043 #include <Color.h> 00044 00046 class Image 00047 { 00048 public: 00049 00050 enum Format 00051 { 00052 Format_RGB, 00053 Format_ARGB, 00054 }; 00055 00056 Image(); 00057 ~Image(); 00058 00059 void allocate(uint w, uint h); 00060 /* 00061 bool load(const char * name); 00062 00063 void wrap(void * data, uint w, uint h); 00064 void unwrap(); 00065 */ 00066 00067 uint width() const; 00068 uint height() const; 00069 00070 const Color32 * scanline(uint h) const; 00071 Color32 * scanline(uint h); 00072 00073 const Color32 * pixels() const; 00074 Color32 * pixels(); 00075 00076 const Color32 & pixel(uint idx) const; 00077 Color32 & pixel(uint idx); 00078 00079 const Color32 & pixel(uint x, uint y) const; 00080 Color32 & pixel(uint x, uint y); 00081 00082 Format format() const; 00083 void setFormat(Format f); 00084 00085 private: 00086 void free(); 00087 00088 private: 00089 uint m_width; 00090 uint m_height; 00091 Format m_format; 00092 Color32 * m_data; 00093 }; 00094 00095 00096 inline const Color32 & Image::pixel(uint x, uint y) const 00097 { 00098 return pixel(y * width() + x); 00099 } 00100 00101 inline Color32 & Image::pixel(uint x, uint y) 00102 { 00103 return pixel(y * width() + x); 00104 } 00105 00106 #endif // _DDS_IMAGE_H