CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2010 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 contact: julien_jorge@yahoo.fr 00024 */ 00030 #include "claw/gif.hpp" 00031 00032 #include <algorithm> 00033 #include <claw/functional.hpp> 00034 00035 /*----------------------------------------------------------------------------*/ 00039 bool claw::graphic::gif::screen_descriptor::has_global_color_table() const 00040 { 00041 return (packed & 0x80) != 0; 00042 } // gif::screen_descriptor::has_global_color_table() 00043 00044 /*----------------------------------------------------------------------------*/ 00048 unsigned int claw::graphic::gif::screen_descriptor::color_palette_size() const 00049 { 00050 if ( !has_global_color_table() ) 00051 return 0; 00052 else 00053 return 1 << ((packed & 0x07) + 1); 00054 } // gif::screen_descriptor::color_palette_size() 00055 00056 00057 00058 00059 /*----------------------------------------------------------------------------*/ 00063 claw::graphic::gif::graphic_control_extension::disposal_method 00064 claw::graphic::gif::graphic_control_extension::get_disposal_method() const 00065 { 00066 switch( (packed & 0x1C) >> 2 ) 00067 { 00068 case 0: return dispose_none; 00069 case 1: return dispose_do_not_dispose; 00070 case 2: return dispose_background; 00071 case 3: return dispose_previous; 00072 default: 00073 return dispose_previous; 00074 } 00075 } // gif::graphic_control_extension::get_disposal_method() 00076 00077 /*----------------------------------------------------------------------------*/ 00081 bool 00082 claw::graphic::gif::graphic_control_extension::has_transparent_color() const 00083 { 00084 return (packed & 0x01) != 0; 00085 } // gif::graphic_control_extension::has_transparent_color() 00086 00087 00088 00089 00090 /*----------------------------------------------------------------------------*/ 00094 bool claw::graphic::gif::image_descriptor::has_color_table() const 00095 { 00096 return (packed & 0x80) != 0; 00097 } // gif::image_descriptor::has_color_table() 00098 00099 /*----------------------------------------------------------------------------*/ 00103 bool claw::graphic::gif::image_descriptor::is_interlaced() const 00104 { 00105 return (packed & 0x40) != 0; 00106 } // gif::image_descriptor::is_interlaced() 00107 00108 /*----------------------------------------------------------------------------*/ 00112 unsigned int claw::graphic::gif::image_descriptor::color_palette_size() const 00113 { 00114 if ( !has_color_table() ) 00115 return 0; 00116 else 00117 return 1 << ((packed & 0x07) + 1); 00118 } // gif::image_descriptor::color_palette_size() 00119 00120 00121 00122 00123 /*----------------------------------------------------------------------------*/ 00127 claw::graphic::gif::gif() 00128 { 00129 00130 } // gif::gif() [copy constructor] 00131 00132 /*----------------------------------------------------------------------------*/ 00137 claw::graphic::gif::gif( const gif& that ) 00138 : image(that) 00139 { 00140 frame_list::const_iterator it; 00141 00142 for (it=that.m_frame.begin(); it!=that.m_frame.end(); ++it) 00143 m_frame.push_back( new frame(**it) ); 00144 } // gif::gif() [copy constructor] 00145 00146 /*----------------------------------------------------------------------------*/ 00151 claw::graphic::gif::gif( std::istream& f ) 00152 { 00153 reader(*this, m_frame, f); 00154 } // gif::gif() [constructor, from file] 00155 00156 /*----------------------------------------------------------------------------*/ 00160 claw::graphic::gif::~gif() 00161 { 00162 std::for_each 00163 ( m_frame.begin(), m_frame.end(), claw::delete_function<frame*>() ); 00164 m_frame.clear(); 00165 } // gif::~gif() 00166 00167 /*----------------------------------------------------------------------------*/ 00172 claw::graphic::gif& claw::graphic::gif::operator=( const gif& that ) 00173 { 00174 gif tmp(that); 00175 std::swap(tmp, *this); 00176 return *this; 00177 } // gif::operator=() 00178 00179 /*----------------------------------------------------------------------------*/ 00184 void claw::graphic::gif::swap( gif& that ) 00185 { 00186 super::swap(that); 00187 std::swap(m_frame, that.m_frame); 00188 } // gif::swap() 00189 00190 /*----------------------------------------------------------------------------*/ 00194 claw::graphic::gif::frame_iterator claw::graphic::gif::frame_begin() 00195 { 00196 return frame_iterator(m_frame.begin()); 00197 } // gif::begin() 00198 00199 /*----------------------------------------------------------------------------*/ 00203 claw::graphic::gif::frame_iterator claw::graphic::gif::frame_end() 00204 { 00205 return frame_iterator(m_frame.end()); 00206 } // gif::end() 00207 00208 /*----------------------------------------------------------------------------*/ 00212 claw::graphic::gif::const_frame_iterator claw::graphic::gif::frame_begin() const 00213 { 00214 return const_frame_iterator(m_frame.begin()); 00215 } // gif::begin() 00216 00217 /*----------------------------------------------------------------------------*/ 00221 claw::graphic::gif::const_frame_iterator claw::graphic::gif::frame_end() const 00222 { 00223 return const_frame_iterator(m_frame.end()); 00224 } // gif::end() 00225 00226 00227 00228 00229 /*----------------------------------------------------------------------------*/ 00235 void std::swap( claw::graphic::gif& a, claw::graphic::gif& b ) 00236 { 00237 a.swap(b); 00238 } // swap()