Anti-Grain Geometry - AGG (libagg)  2.5
agg-2.5/include/agg_span_pattern_rgba.h
Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 // Anti-Grain Geometry (AGG) - Version 2.5
00003 // A high quality rendering engine for C++
00004 // Copyright (C) 2002-2006 Maxim Shemanarev
00005 // Contact: mcseem@antigrain.com
00006 //          mcseemagg@yahoo.com
00007 //          http://antigrain.com
00008 // 
00009 // AGG is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 // 
00014 // AGG 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
00017 // GNU General Public License for more details.
00018 // 
00019 // You should have received a copy of the GNU General Public License
00020 // along with AGG; if not, write to the Free Software
00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00022 // MA 02110-1301, USA.
00023 //----------------------------------------------------------------------------
00024 //
00025 // Adaptation for high precision colors has been sponsored by 
00026 // Liberty Technology Systems, Inc., visit http://lib-sys.com
00027 //
00028 // Liberty Technology Systems, Inc. is the provider of
00029 // PostScript and PDF technology for software developers.
00030 // 
00031 //----------------------------------------------------------------------------
00032 
00033 
00034 #ifndef AGG_SPAN_PATTERN_RGBA_INCLUDED
00035 #define AGG_SPAN_PATTERN_RGBA_INCLUDED
00036 
00037 #include "agg_basics.h"
00038 
00039 namespace agg
00040 {
00041 
00042     //======================================================span_pattern_rgba
00043     template<class Source> class span_pattern_rgba
00044     {
00045     public:
00046         typedef Source source_type;
00047         typedef typename source_type::color_type color_type;
00048         typedef typename source_type::order_type order_type;
00049         typedef typename color_type::value_type value_type;
00050         typedef typename color_type::calc_type calc_type;
00051 
00052         //--------------------------------------------------------------------
00053         span_pattern_rgba() {}
00054         span_pattern_rgba(source_type& src, 
00055                           unsigned offset_x, unsigned offset_y) :
00056             m_src(&src),
00057             m_offset_x(offset_x),
00058             m_offset_y(offset_y)
00059         {}
00060 
00061         //--------------------------------------------------------------------
00062         void   attach(source_type& v)      { m_src = &v; }
00063                source_type& source()       { return *m_src; }
00064         const  source_type& source() const { return *m_src; }
00065 
00066         //--------------------------------------------------------------------
00067         void       offset_x(unsigned v) { m_offset_x = v; }
00068         void       offset_y(unsigned v) { m_offset_y = v; }
00069         unsigned   offset_x() const { return m_offset_x; }
00070         unsigned   offset_y() const { return m_offset_y; }
00071         void       alpha(value_type) {}
00072         value_type alpha() const { return 0; }
00073 
00074         //--------------------------------------------------------------------
00075         void prepare() {}
00076         void generate(color_type* span, int x, int y, unsigned len)
00077         {   
00078             x += m_offset_x;
00079             y += m_offset_y;
00080             const value_type* p = (const value_type*)m_src->span(x, y, len);
00081             do
00082             {
00083                 span->r = p[order_type::R];
00084                 span->g = p[order_type::G];
00085                 span->b = p[order_type::B];
00086                 span->a = p[order_type::A];
00087                 p = (const value_type*)m_src->next_x();
00088                 ++span;
00089             }
00090             while(--len);
00091         }
00092 
00093     private:
00094         source_type* m_src;
00095         unsigned     m_offset_x;
00096         unsigned     m_offset_y;
00097 
00098     };
00099 
00100 }
00101 
00102 #endif
00103 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines