claw
1.9.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xbm.hpp
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
#ifndef __CLAW_XBM_HPP__
31
#define __CLAW_XBM_HPP__
32
33
#include <
claw/graphic/image.hpp
>
34
35
#include <iostream>
36
#include <string>
37
38
namespace
claw
39
{
40
namespace
graphic
41
{
46
class
xbm
:
public
image
47
{
48
public
:
53
class
reader
54
{
55
public
:
56
reader
(
image
& img);
57
reader
(
image
& img, std::istream& f);
58
reader
(
xbm
& img, std::istream& f);
59
~reader
();
60
61
void
load
(std::istream& f);
62
63
private
:
64
void
read_from_file(std::istream& f);
65
66
void
read_size(std::istream& f);
67
unsigned
int
read_dim(
const
std::string& line)
const
;
68
unsigned
int
read_bits_per_entry(std::istream& f)
const
;
69
void
read_name(std::istream& f);
70
void
read_pixels(std::istream& f,
unsigned
int
bpe)
const
;
71
72
void
read_line(std::istream& f, std::string& line,
char
endchar)
const
;
73
void
remove_comments(std::istream& f, std::string& line,
74
char
endchar)
const
;
75
76
private
:
78
image
& m_image;
79
81
std::string m_name;
82
84
claw::math::coordinate_2d<int>
* m_hot;
85
86
};
// class reader
87
92
class
writer
93
{
94
public
:
98
struct
options
99
{
100
public
:
101
options
();
102
103
options
(
const
std::string& n,
104
const
claw::math::coordinate_2d<int>
* h);
105
106
public
:
108
std::string
name
;
109
111
const
claw::math::coordinate_2d<int>
*
hot
;
112
113
};
// options
114
115
public
:
116
writer
(
const
image
& img);
117
writer
(
const
image
& img, std::ostream& f,
118
const
options
& opt =
options
());
119
120
void
save
(std::ostream& f,
const
options
& opt =
options
())
const
;
121
122
private
:
123
void
save_bits(std::ostream& f)
const
;
124
125
private
:
127
const
image
& m_image;
128
129
};
// class writer
130
131
public
:
132
xbm
(
unsigned
int
w,
unsigned
int
h);
133
xbm
(
const
image
& that);
134
xbm
(std::istream& f);
135
~xbm
();
136
137
void
save
(std::ostream& os)
const
;
138
139
void
set_name
(
const
std::string& name);
140
void
set_hot
(
const
claw::math::coordinate_2d<int>
& hot);
141
142
private
:
144
std::string m_name;
145
147
claw::math::coordinate_2d<int>
* m_hot;
148
149
};
// class xbm
150
}
151
}
152
153
#endif
// __CLAW_XBM_HPP__
claw::graphic::image::image
image()
Constructor. Creates an image without datas.
Definition
image.cpp:95
claw::graphic::xbm::reader::reader
reader(image &img)
Constructor.
Definition
xbm_reader.cpp:40
claw::graphic::xbm::reader::load
void load(std::istream &f)
Load an image from a xbm file.
Definition
xbm_reader.cpp:91
claw::graphic::xbm::reader::~reader
~reader()
Destructor.
Definition
xbm_reader.cpp:78
claw::graphic::xbm::writer::save
void save(std::ostream &f, const options &opt=options()) const
Save the image in a XBM file.
Definition
xbm_writer.cpp:79
claw::graphic::xbm::writer::writer
writer(const image &img)
Constructor.
Definition
xbm_writer.cpp:57
claw::graphic::xbm::save
void save(std::ostream &os) const
Save the image.
Definition
xbm.cpp:75
claw::graphic::xbm::xbm
xbm(unsigned int w, unsigned int h)
Constructor. Creates an empty image.
Definition
xbm.cpp:38
claw::graphic::xbm::~xbm
~xbm()
Destructor.
Definition
xbm.cpp:65
claw::graphic::xbm::set_hot
void set_hot(const claw::math::coordinate_2d< int > &hot)
Set the hot spot of the image.
Definition
xbm.cpp:93
claw::graphic::xbm::set_name
void set_name(const std::string &name)
Set the name of the image.
Definition
xbm.cpp:84
claw::math::coordinate_2d
Coordinates in a two dimensional space.
Definition
coordinate_2d.hpp:43
image.hpp
A class to deal with images.
claw::graphic
Everything about image structures and processing.
Definition
claw.hpp:58
claw
This is the main namespace.
Definition
application.hpp:50
claw::graphic::xbm::writer::options
Parameters of the writing algorithm.
Definition
xbm.hpp:99
claw::graphic::xbm::writer::options::options
options()
Default constructor.
Definition
xbm_writer.cpp:37
claw::graphic::xbm::writer::options::hot
const claw::math::coordinate_2d< int > * hot
The position of the hot spot in the image.
Definition
xbm.hpp:111
claw::graphic::xbm::writer::options::name
std::string name
The name of the image structure in the file.
Definition
xbm.hpp:108
lib
graphic
include
claw
graphic
xbm.hpp
Generated by
1.17.0