claw
1.9.0
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
*/
30
#include <
claw/graphic/targa.hpp
>
31
32
//************************ targa::file_structure::header
33
//***********************
34
38
claw::graphic::targa::file_structure::header::header
()
39
{}
40
46
claw::graphic::targa::file_structure::header::header
(
unsigned
int
w,
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
75
bool
claw::graphic::targa::file_structure::header::specification::
76
up_down_oriented
()
const
77
{
78
return
descriptor
& 0x20;
79
}
80
84
bool
claw::graphic::targa::file_structure::header::specification::
85
left_right_oriented
()
const
86
{
87
return
!(
descriptor
& 0x10);
88
}
89
93
unsigned
char
94
claw::graphic::targa::file_structure::header::specification::alpha
()
const
95
{
96
return
descriptor
& 0x0F;
97
}
98
99
//********************* targa::file_structure::footer
100
//**************************
101
102
const
std::string claw::graphic::targa::file_structure::footer::s_signature(
103
"TRUEVISION-XFILE."
);
104
108
claw::graphic::targa::file_structure::footer::footer
()
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
119
bool
claw::graphic::targa::file_structure::footer::is_valid
()
const
120
{
121
return
std::equal(s_signature.begin(), s_signature.end(),
signature
)
122
&&
signature
[s_signature.length()] ==
'\0'
;
123
}
claw::graphic::targa::file_structure::footer::footer
footer()
Constructor.
Definition
targa_file_structure.cpp:108
claw::graphic::targa::file_structure::footer::signature
char signature[18]
Footer identier. Must be as long as std::string("TRUEVISION-XFILE.") + 1 (for the last '\0').
Definition
targa.hpp:165
claw::graphic::targa::file_structure::footer::is_valid
bool is_valid() const
Tell if the data of this footer is valid.
Definition
targa_file_structure.cpp:119
claw::graphic::targa::file_structure::footer::developer_offset
unsigned int developer_offset
Offset of the developer directory.
Definition
targa.hpp:161
claw::graphic::targa::file_structure::footer::extension_offset
unsigned int extension_offset
Offset of the extension area.
Definition
targa.hpp:158
claw::graphic::targa::file_structure::header::image_type
char image_type
Image type.
Definition
targa.hpp:88
claw::graphic::targa::file_structure::header::header
header()
Default constructor.
Definition
targa_file_structure.cpp:38
claw::graphic::targa::file_structure::header::image_specification
specification image_specification
The specification of the image.
Definition
targa.hpp:123
claw::graphic::targa::file_structure::header::color_map_specification
struct claw::graphic::targa::file_structure::header::@244140121240111107105021326247270144031175023050 color_map_specification
Color map specification.
claw::graphic::targa::file_structure::header::id_length
char id_length
Image identifier length.
Definition
targa.hpp:84
claw::graphic::targa::file_structure::header::color_map
char color_map
1 if there is a color map, 0 otherwise.
Definition
targa.hpp:86
claw::graphic::targa::file_structure::header::specification::alpha
unsigned char alpha() const
Number of bits per pixel assigned to alpha chanel.
Definition
targa_file_structure.cpp:94
claw::graphic::targa::file_structure::header::specification::descriptor
unsigned char descriptor
descriptor.
Definition
targa.hpp:115
claw::graphic::targa::file_structure::header::specification::left_right_oriented
bool left_right_oriented() const
Is image stored left to right ?
Definition
targa_file_structure.cpp:85
claw::graphic::targa::file_structure::header::specification::up_down_oriented
bool up_down_oriented() const
Is image stored up to down ?
Definition
targa_file_structure.cpp:76
targa.hpp
A class for targa pictures.
lib
graphic
src
claw
graphic
targa_file_structure.cpp
Generated by
1.13.2