00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2008 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 contact: julien_jorge@yahoo.fr 00024 */ 00030 #include <claw/targa.hpp> 00031 00032 00033 //************************ targa::file_structure::header *********************** 00034 00035 00036 00037 /*----------------------------------------------------------------------------*/ 00041 claw::graphic::targa::file_structure::header::header() 00042 { 00043 00044 } // targa::file_structure::header::header() 00045 00046 /*----------------------------------------------------------------------------*/ 00052 claw::graphic::targa::file_structure::header::header 00053 ( unsigned int w, unsigned int h ) 00054 { 00055 id_length = 0; 00056 color_map = 0; 00057 00058 image_type = true_color; 00059 00060 color_map_specification.first_entry_index = 0; 00061 color_map_specification.length = 0; 00062 color_map_specification.entry_size = 0; 00063 00064 image_specification.x_origin = 0; 00065 image_specification.y_origin = 0; 00066 image_specification.width = w; 00067 image_specification.height = h; 00068 00069 image_specification.bpp = 32; // pixel32 00070 00071 image_specification.descriptor = 8; // unsigned char 00072 image_specification.descriptor |= 0x20; // origin is top-left 00073 } // targa::file_structure::header::header() 00074 00075 00076 00077 00078 //************** targa::file_structure::header::specification ****************** 00079 00080 00081 00082 00083 /*----------------------------------------------------------------------------*/ 00087 bool 00088 claw::graphic::targa::file_structure::header::specification:: 00089 up_down_oriented() const 00090 { 00091 return descriptor & 0x20; 00092 } // targa::file_structure::header::specification::up_down_oriented() 00093 00094 /*----------------------------------------------------------------------------*/ 00098 bool 00099 claw::graphic::targa::file_structure::header::specification:: 00100 left_right_oriented() const 00101 { 00102 return !(descriptor & 0x10); 00103 } // targa::file_structure::header::specification::left_right_oriented() 00104 00105 /*----------------------------------------------------------------------------*/ 00109 unsigned char 00110 claw::graphic::targa::file_structure::header::specification::alpha() const 00111 { 00112 return descriptor & 0x0F; 00113 } // targa::file_structure::header::specification::alpha() 00114 00115 00116 00117 00118 //********************* targa::file_structure::footer ************************** 00119 00120 00121 00122 00123 /*----------------------------------------------------------------------------*/ 00124 const std::string 00125 claw::graphic::targa::file_structure::footer::s_signature("TRUEVISION-XFILE."); 00126 00127 /*----------------------------------------------------------------------------*/ 00131 claw::graphic::targa::file_structure::footer::footer() 00132 : extension_offset(0), developer_offset(0) 00133 { 00134 std::copy( s_signature.begin(), s_signature.end(), signature ); 00135 signature[s_signature.length()] = '\0'; 00136 } // targa::file_structure::footer::footer() 00137 00138 /*----------------------------------------------------------------------------*/ 00142 bool claw::graphic::targa::file_structure::footer::is_valid() const 00143 { 00144 return std::equal( s_signature.begin(), s_signature.end(), signature ) 00145 && signature[s_signature.length()] == '\0'; 00146 } // targa::file_structure::footer::is_valid()