claw 1.8.2
Loading...
Searching...
No Matches
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@stuff-o-matic.com
24*/
31
32//************************ targa::file_structure::header
33//***********************
34
40
47 unsigned int h)
48{
49 id_length = 0;
50 color_map = 0;
51
52 image_type = true_color;
53
54 color_map_specification.first_entry_index = 0;
55 color_map_specification.length = 0;
56 color_map_specification.entry_size = 0;
57
58 image_specification.x_origin = 0;
59 image_specification.y_origin = 0;
60 image_specification.width = w;
61 image_specification.height = h;
62
63 image_specification.bpp = 32; // pixel32
64
65 image_specification.descriptor = 8; // unsigned char
66 image_specification.descriptor |= 0x20; // origin is top-left
67}
68
69//************** targa::file_structure::header::specification
70//******************
71
77{
78 return descriptor & 0x20;
79}
80
86{
87 return !(descriptor & 0x10);
88}
89
93unsigned char
95{
96 return descriptor & 0x0F;
97}
98
99//********************* targa::file_structure::footer
100//**************************
101
102const std::string claw::graphic::targa::file_structure::footer::s_signature(
103 "TRUEVISION-XFILE.");
104
109 : extension_offset(0)
110 , developer_offset(0)
111{
112 std::copy(s_signature.begin(), s_signature.end(), signature);
113 signature[s_signature.length()] = '\0';
114}
115
120{
121 return std::equal(s_signature.begin(), s_signature.end(), signature)
122 && signature[s_signature.length()] == '\0';
123}
char signature[18]
Footer identier. Must be as long as std::string("TRUEVISION-XFILE.") + 1 (for the last '\0').
Definition targa.hpp:165
bool is_valid() const
Tell if the data of this footer is valid.
unsigned char alpha() const
Number of bits per pixel assigned to alpha chanel.
bool left_right_oriented() const
Is image stored left to right ?
A class for targa pictures.