Claw 1.7.3
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@gamned.org
24*/
30#include "claw/gif.hpp"
31
32#include <algorithm>
33#include <claw/functional.hpp>
34
35/*----------------------------------------------------------------------------*/
39bool claw::graphic::gif::screen_descriptor::has_global_color_table() const
40{
41 return (packed & 0x80) != 0;
42} // gif::screen_descriptor::has_global_color_table()
43
44/*----------------------------------------------------------------------------*/
48unsigned int claw::graphic::gif::screen_descriptor::color_palette_size() const
49{
50 if ( !has_global_color_table() )
51 return 0;
52 else
53 return 1 << ((packed & 0x07) + 1);
54} // gif::screen_descriptor::color_palette_size()
55
56
57
58
59/*----------------------------------------------------------------------------*/
63claw::graphic::gif::graphic_control_extension::disposal_method
64claw::graphic::gif::graphic_control_extension::get_disposal_method() const
65{
66 switch( (packed & 0x1C) >> 2 )
67 {
68 case 0: return dispose_none;
69 case 1: return dispose_do_not_dispose;
70 case 2: return dispose_background;
71 case 3: return dispose_previous;
72 default:
73 return dispose_previous;
74 }
75} // gif::graphic_control_extension::get_disposal_method()
76
77/*----------------------------------------------------------------------------*/
81bool
82claw::graphic::gif::graphic_control_extension::has_transparent_color() const
83{
84 return (packed & 0x01) != 0;
85} // gif::graphic_control_extension::has_transparent_color()
86
87
88
89
90/*----------------------------------------------------------------------------*/
94bool claw::graphic::gif::image_descriptor::has_color_table() const
95{
96 return (packed & 0x80) != 0;
97} // gif::image_descriptor::has_color_table()
98
99/*----------------------------------------------------------------------------*/
103bool claw::graphic::gif::image_descriptor::is_interlaced() const
104{
105 return (packed & 0x40) != 0;
106} // gif::image_descriptor::is_interlaced()
107
108/*----------------------------------------------------------------------------*/
112unsigned int claw::graphic::gif::image_descriptor::color_palette_size() const
113{
114 if ( !has_color_table() )
115 return 0;
116 else
117 return 1 << ((packed & 0x07) + 1);
118} // gif::image_descriptor::color_palette_size()
119
120
121
122
123/*----------------------------------------------------------------------------*/
128{
129
130} // gif::gif() [copy constructor]
131
132/*----------------------------------------------------------------------------*/
138 : image(that)
139{
140 frame_list::const_iterator it;
141
142 for (it=that.m_frame.begin(); it!=that.m_frame.end(); ++it)
143 m_frame.push_back( new frame(**it) );
144} // gif::gif() [copy constructor]
145
146/*----------------------------------------------------------------------------*/
151claw::graphic::gif::gif( std::istream& f )
152{
153 reader(*this, m_frame, f);
154} // gif::gif() [constructor, from file]
155
156/*----------------------------------------------------------------------------*/
161{
162 std::for_each
163 ( m_frame.begin(), m_frame.end(), claw::delete_function<frame*>() );
164 m_frame.clear();
165} // gif::~gif()
166
167/*----------------------------------------------------------------------------*/
173{
174 gif tmp(that);
175 std::swap(tmp, *this);
176 return *this;
177} // gif::operator=()
178
179/*----------------------------------------------------------------------------*/
185{
186 super::swap(that);
187 std::swap(m_frame, that.m_frame);
188} // gif::swap()
189
190/*----------------------------------------------------------------------------*/
195{
196 return frame_iterator(m_frame.begin());
197} // gif::begin()
198
199/*----------------------------------------------------------------------------*/
204{
205 return frame_iterator(m_frame.end());
206} // gif::end()
207
208/*----------------------------------------------------------------------------*/
213{
214 return const_frame_iterator(m_frame.begin());
215} // gif::begin()
216
217/*----------------------------------------------------------------------------*/
222{
223 return const_frame_iterator(m_frame.end());
224} // gif::end()
225
226
227
228
229/*----------------------------------------------------------------------------*/
235void std::swap( claw::graphic::gif& a, claw::graphic::gif& b )
236{
237 a.swap(b);
238} // swap()
Function object that deletes a pointer.
One frame in the animation.
Definition gif.hpp:57
This class reads data from a gif file. The image is resized to the size of the screen (as defined in ...
Definition gif.hpp:280
A class for gif pictures.
Definition gif.hpp:52
frame_iterator frame_end()
Get an iterator on the end of the frame sequence.
Definition gif.cpp:203
~gif()
Destructor.
Definition gif.cpp:160
void swap(gif &that)
Swap the content of two gifs.
Definition gif.cpp:184
gif & operator=(const gif &that)
Assignment.
Definition gif.cpp:172
gif()
Constructor.
Definition gif.cpp:127
frame_iterator frame_begin()
Get an iterator on the beginning of the frame sequence.
Definition gif.cpp:194
A class to deal with images.
Definition image.hpp:50
Base class for wrapped iterators.
Definition iterator.hpp:46
Some function object classes.
Image class for gif files.