00001 /* 00002 CS Senior Project 2003 00003 Team : Leftfield 00004 Project : ModernWarfare 00005 Members : 00006 - Russ Christensen <rchriste@cs.utah.edu> 00007 - Todd Smith <tcsmith@cs.utah.edu> 00008 - Usit Duongsaa <duongsaa@cs.utah.edu> 00009 00010 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved. 00011 00012 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 00013 00014 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00015 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 00016 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 */ 00018 00024 00025 // Load TGA images, decode, and allow user to read values at pixel level 00027 00028 #if !defined(AFX_GRAPHICS_H__97DD8875_1535_40B5_9AC5_6396C9F6266F__INCLUDED_) 00029 #define AFX_GRAPHICS_H__97DD8875_1535_40B5_9AC5_6396C9F6266F__INCLUDED_ 00030 00031 #if _MSC_VER > 1000 00032 #pragma once 00033 #endif // _MSC_VER > 1000 00034 00035 #include "ExternalLibs.h" 00036 00037 typedef unsigned long DWORD; 00038 typedef unsigned int UINT; 00039 typedef unsigned short WORD; 00040 typedef unsigned char UBYTE; 00041 00043 struct tgaHeader 00044 { 00045 UBYTE IdLength; 00046 UBYTE ColourMapType; 00047 UBYTE DataTypeCode; 00048 WORD ColourMapOrigin; 00049 UBYTE ColourMapLength; 00050 UBYTE ColourMapDepth; 00051 WORD x_Origin; 00052 WORD y_Origin; 00053 WORD Width; 00054 WORD Height; 00055 UBYTE BitsPerPixel; 00056 UBYTE ImageDescriptor; 00057 }; 00058 00059 00060 class CImage 00061 { 00062 public: 00063 CImage(); 00064 virtual ~CImage(); 00065 00066 public: 00067 inline void DecodeT10Tga24(const tgaHeader& Header, int& nImageSize); 00068 inline void DecodeT2Tga24(const tgaHeader& Header, const int& nImageSize); 00069 inline void DecodeT10Tga16(const tgaHeader& Header, const int& nImageSize); 00070 inline void DecodeT2Tga16(const tgaHeader& Header, const int& nImageSize); 00072 // Load a bmp 00073 // 00074 // 00076 void LoadBmp(const string& strFileName); 00077 00079 // Load a tga file 00080 // 00081 // recieves: 00082 // strFileName - the name of the file to get 00083 // bAlpha - is there going to be an alpha channel only used for 24 bit pictures 00085 void LoadTga(const string& strFileName); 00086 00088 // Get the Image data 00090 UBYTE* GetImageData(); 00091 00093 // Return the bytes per pixel 00095 UBYTE GetBPP(); 00096 00098 // Return the Height of the image 00100 UINT GetHeight(); 00101 00103 // Return the Width of the image 00105 UINT GetWidth(); 00106 00107 void SetAlpha(UBYTE AlphaValue); 00108 void bAlphaChannel(bool bAlpha); 00109 00110 void LoadRaw(const string &strName, int nSize); 00111 00112 private: 00113 UBYTE * m_ubImageData; // The obj to hold the data. 00114 UINT m_dwHeight; // Height of graphic 00115 UINT m_dwWidth; // Width of graphic 00116 UBYTE m_ubBpp; // Bytes per pixel 4, 3, 2 00117 bool m_bAlpha; // Does the image include an alpha channel 00118 UBYTE m_ubAlphaValue; 00119 }; 00120 00121 #endif // !defined(AFX_GRAPHICS_H__97DD8875_1535_40B5_9AC5_6396C9F6266F__INCLUDED_)
1.3-rc2