claw 1.9.0
 
Loading...
Searching...
No Matches
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
39bool claw::graphic::gif::screen_descriptor::has_global_color_table() const
40{
41 return (packed & 0x80) != 0;
42}
43
47unsigned 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
58claw::graphic::gif::graphic_control_extension::disposal_method
59claw::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
79bool claw::graphic::gif::graphic_control_extension::has_transparent_color()
80 const
81{
82 return (packed & 0x01) != 0;
83}
84
88bool claw::graphic::gif::image_descriptor::has_color_table() const
89{
90 return (packed & 0x80) != 0;
91}
92
96bool claw::graphic::gif::image_descriptor::is_interlaced() const
97{
98 return (packed & 0x40) != 0;
99}
100
104unsigned 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
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
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
178
186
192{
193 return const_frame_iterator(m_frame.begin());
194}
195
203
210{
211 a.swap(b);
212}
Function object that deletes a pointer.
One frame in the animation.
Definition gif.hpp:56
This class reads data from a gif file. The image is resized to the size of the screen (as defined in ...
Definition gif.hpp:277
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:182
~gif()
Destructor.
Definition gif.cpp:143
void swap(gif &that)
Swap the content of two gifs.
Definition gif.cpp:165
gif & operator=(const gif &that)
Assignment.
Definition gif.cpp:154
wrapped_iterator< frame, frame_list::iterator, claw::dereference< frame > >::iterator_type frame_iterator
Iterator on the content of the gif.
Definition gif.hpp:86
wrapped_iterator< constframe, frame_list::const_iterator, claw::const_dereference< frame > >::iterator_type const_frame_iterator
Iterator on the content of the gif.
Definition gif.hpp:91
gif()
Constructor.
Definition gif.cpp:115
frame_iterator frame_begin()
Get an iterator on the beginning of the frame sequence.
Definition gif.cpp:174
void swap(image &that)
Swap the content of two images.
Definition image.cpp:122
image()
Constructor. Creates an image without datas.
Definition image.cpp:95
Some function object classes.
Image class for gif files.
void swap(claw::graphic::gif &a, claw::graphic::gif &b)
Swap the content of two gifs.
Definition gif.cpp:209