claw  1.9.0
xbm.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/xbm.hpp>
31 
38 claw::graphic::xbm::xbm(unsigned int w, unsigned int h)
39  : image(w, h)
40  , m_hot(NULL)
41 {}
42 
48  : image(that)
49  , m_hot(NULL)
50 {}
51 
56 claw::graphic::xbm::xbm(std::istream& f)
57  : m_hot(NULL)
58 {
59  reader(*this, f);
60 }
61 
66 {
67  if(m_hot != NULL)
68  delete m_hot;
69 }
70 
75 void claw::graphic::xbm::save(std::ostream& f) const
76 {
77  writer(*this, f, writer::options(m_name, m_hot));
78 }
79 
84 void claw::graphic::xbm::set_name(const std::string& name)
85 {
86  m_name = name;
87 }
88 
94 {
95  if(m_hot != NULL)
96  delete m_hot;
97 
98  m_hot = new claw::math::coordinate_2d<int>(hot);
99 }
Parameters of the writing algorithm.
Definition: xbm.hpp:98
void set_name(const std::string &name)
Set the name of the image.
Definition: xbm.cpp:84
This class read data from a xbm file and store it in an image.
Definition: xbm.hpp:53
xbm(unsigned int w, unsigned int h)
Constructor. Creates an empty image.
Definition: xbm.cpp:38
void save(std::ostream &os) const
Save the image.
Definition: xbm.cpp:75
void set_hot(const claw::math::coordinate_2d< int > &hot)
Set the hot spot of the image.
Definition: xbm.cpp:93
This class write an image in a xbm file.
Definition: xbm.hpp:92
A class to deal with images.
Definition: image.hpp:50
~xbm()
Destructor.
Definition: xbm.cpp:65
A class for xbm pictures.