Claw  1.7.3
targa_file_structure.cpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
30 #include <claw/targa.hpp>
31 
32 
33 //************************ targa::file_structure::header ***********************
34 
35 
36 
37 /*----------------------------------------------------------------------------*/
42 {
43 
44 } // targa::file_structure::header::header()
45 
46 /*----------------------------------------------------------------------------*/
53 ( unsigned int w, unsigned int h )
54 {
55  id_length = 0;
56  color_map = 0;
57 
58  image_type = true_color;
59 
60  color_map_specification.first_entry_index = 0;
61  color_map_specification.length = 0;
62  color_map_specification.entry_size = 0;
63 
64  image_specification.x_origin = 0;
65  image_specification.y_origin = 0;
66  image_specification.width = w;
67  image_specification.height = h;
68 
69  image_specification.bpp = 32; // pixel32
70 
71  image_specification.descriptor = 8; // unsigned char
72  image_specification.descriptor |= 0x20; // origin is top-left
73 } // targa::file_structure::header::header()
74 
75 
76 
77 
78 //************** targa::file_structure::header::specification ******************
79 
80 
81 
82 
83 /*----------------------------------------------------------------------------*/
87 bool
90 {
91  return descriptor & 0x20;
92 } // targa::file_structure::header::specification::up_down_oriented()
93 
94 /*----------------------------------------------------------------------------*/
98 bool
101 {
102  return !(descriptor & 0x10);
103 } // targa::file_structure::header::specification::left_right_oriented()
104 
105 /*----------------------------------------------------------------------------*/
109 unsigned char
111 {
112  return descriptor & 0x0F;
113 } // targa::file_structure::header::specification::alpha()
114 
115 
116 
117 
118 //********************* targa::file_structure::footer **************************
119 
120 
121 
122 
123 /*----------------------------------------------------------------------------*/
124 const std::string
125 claw::graphic::targa::file_structure::footer::s_signature("TRUEVISION-XFILE.");
126 
127 /*----------------------------------------------------------------------------*/
132  : extension_offset(0), developer_offset(0)
133 {
134  std::copy( s_signature.begin(), s_signature.end(), signature );
135  signature[s_signature.length()] = '\0';
136 } // targa::file_structure::footer::footer()
137 
138 /*----------------------------------------------------------------------------*/
143 {
144  return std::equal( s_signature.begin(), s_signature.end(), signature )
145  && signature[s_signature.length()] == '\0';
146 } // targa::file_structure::footer::is_valid()