|
Blender V2.27
|
00001 00025 /* 00026 * This file is based on a similar file from the NVIDIA texture tools 00027 * (http://nvidia-texture-tools.googlecode.com/) 00028 * 00029 * Original license from NVIDIA follows. 00030 */ 00031 00032 // This code is in the public domain -- castanyo@yahoo.es 00033 00034 #ifndef _DDS_IMAGE_H 00035 #define _DDS_IMAGE_H 00036 00037 #include <Common.h> 00038 #include <Color.h> 00039 00041 class Image 00042 { 00043 public: 00044 00045 enum Format 00046 { 00047 Format_RGB, 00048 Format_ARGB, 00049 }; 00050 00051 Image(); 00052 ~Image(); 00053 00054 void allocate(uint w, uint h); 00055 /* 00056 bool load(const char * name); 00057 00058 void wrap(void * data, uint w, uint h); 00059 void unwrap(); 00060 */ 00061 00062 uint width() const; 00063 uint height() const; 00064 00065 const Color32 * scanline(uint h) const; 00066 Color32 * scanline(uint h); 00067 00068 const Color32 * pixels() const; 00069 Color32 * pixels(); 00070 00071 const Color32 & pixel(uint idx) const; 00072 Color32 & pixel(uint idx); 00073 00074 const Color32 & pixel(uint x, uint y) const; 00075 Color32 & pixel(uint x, uint y); 00076 00077 Format format() const; 00078 void setFormat(Format f); 00079 00080 private: 00081 void free(); 00082 00083 private: 00084 uint m_width; 00085 uint m_height; 00086 Format m_format; 00087 Color32 * m_data; 00088 }; 00089 00090 00091 inline const Color32 & Image::pixel(uint x, uint y) const 00092 { 00093 return pixel(y * width() + x); 00094 } 00095 00096 inline Color32 & Image::pixel(uint x, uint y) 00097 { 00098 return pixel(y * width() + x); 00099 } 00100 00101 #endif // _DDS_IMAGE_H
1.7.3