claw  1.9.0
gif.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/gif.hpp>
31 
32 #include <claw/functional.hpp>
33 
34 #include <algorithm>
35 
39 bool claw::graphic::gif::screen_descriptor::has_global_color_table() const
40 {
41  return (packed & 0x80) != 0;
42 }
43 
47 unsigned int claw::graphic::gif::screen_descriptor::color_palette_size() const
48 {
49  if(!has_global_color_table())
50  return 0;
51  else
52  return 1 << ((packed & 0x07) + 1);
53 }
54 
58 claw::graphic::gif::graphic_control_extension::disposal_method
59 claw::graphic::gif::graphic_control_extension::get_disposal_method() const
60 {
61  switch((packed & 0x1C) >> 2)
62  {
63  case 0:
64  return dispose_none;
65  case 1:
66  return dispose_do_not_dispose;
67  case 2:
68  return dispose_background;
69  case 3:
70  return dispose_previous;
71  default:
72  return dispose_previous;
73  }
74 }
75 
79 bool claw::graphic::gif::graphic_control_extension::has_transparent_color()
80  const
81 {
82  return (packed & 0x01) != 0;
83 }
84 
88 bool claw::graphic::gif::image_descriptor::has_color_table() const
89 {
90  return (packed & 0x80) != 0;
91 }
92 
96 bool claw::graphic::gif::image_descriptor::is_interlaced() const
97 {
98  return (packed & 0x40) != 0;
99 }
100 
104 unsigned int claw::graphic::gif::image_descriptor::color_palette_size() const
105 {
106  if(!has_color_table())
107  return 0;
108  else
109  return 1 << ((packed & 0x07) + 1);
110 }
111 
116 {}
117 
123  : image(that)
124 {
125  frame_list::const_iterator it;
126 
127  for(it = that.m_frame.begin(); it != that.m_frame.end(); ++it)
128  m_frame.push_back(new frame(**it));
129 }
130 
135 claw::graphic::gif::gif(std::istream& f)
136 {
137  reader(*this, m_frame, f);
138 }
139 
144 {
145  std::for_each(m_frame.begin(), m_frame.end(),
147  m_frame.clear();
148 }
149 
155 {
156  gif tmp(that);
157  std::swap(tmp, *this);
158  return *this;
159 }
160 
166 {
167  super::swap(that);
168  std::swap(m_frame, that.m_frame);
169 }
170 
175 {
176  return frame_iterator(m_frame.begin());
177 }
178 
183 {
184  return frame_iterator(m_frame.end());
185 }
186 
192 {
193  return const_frame_iterator(m_frame.begin());
194 }
195 
200 {
201  return const_frame_iterator(m_frame.end());
202 }
203 
210 {
211  a.swap(b);
212 }
Function object that deletes a pointer.
Definition: functional.hpp:273
This class reads data from a gif file. The image is resized to the size of the screen (as defined in ...
Definition: gif.hpp:276
gif & operator=(const gif &that)
Assignment.
Definition: gif.cpp:154
One frame in the animation.
Definition: gif.hpp:55
~gif()
Destructor.
Definition: gif.cpp:143
frame_iterator frame_begin()
Get an iterator on the beginning of the frame sequence.
Definition: gif.cpp:174
frame_iterator frame_end()
Get an iterator on the end of the frame sequence.
Definition: gif.cpp:182
Image class for gif files.
Base class for wrapped iterators.
Definition: iterator.hpp:43
void swap(claw::tween::tweener &a, claw::tween::tweener &b)
Swap two tweeners.
Definition: tweener.cpp:122
A class for gif pictures.
Definition: gif.hpp:51
gif()
Constructor.
Definition: gif.cpp:115
A class to deal with images.
Definition: image.hpp:50
void swap(gif &that)
Swap the content of two gifs.
Definition: gif.cpp:165
Some function object classes.