Anti-Grain Geometry - AGG (libagg)  2.5
agg-2.5/include/agg_span_pattern_rgb.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_RGB_INCLUDED
00035 #define AGG_SPAN_PATTERN_RGB_INCLUDED
00036 
00037 #include "agg_basics.h"
00038 
00039 namespace agg
00040 {
00041 
00042     //========================================================span_pattern_rgb
00043     template<class Source> class span_pattern_rgb
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_rgb() {}
00054         span_pattern_rgb(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             m_alpha(color_type::base_mask)
00060         {}
00061 
00062         //--------------------------------------------------------------------
00063         void   attach(source_type& v)      { m_src = &v; }
00064                source_type& source()       { return *m_src; }
00065         const  source_type& source() const { return *m_src; }
00066 
00067         //--------------------------------------------------------------------
00068         void       offset_x(unsigned v) { m_offset_x = v; }
00069         void       offset_y(unsigned v) { m_offset_y = v; }
00070         unsigned   offset_x() const { return m_offset_x; }
00071         unsigned   offset_y() const { return m_offset_y; }
00072         void       alpha(value_type v) { m_alpha = v; }
00073         value_type alpha() const { return m_alpha; }
00074 
00075         //--------------------------------------------------------------------
00076         void prepare() {}
00077         void generate(color_type* span, int x, int y, unsigned len)
00078         {   
00079             x += m_offset_x;
00080             y += m_offset_y;
00081             const value_type* p = (const value_type*)m_src->span(x, y, len);
00082             do
00083             {
00084                 span->r = p[order_type::R];
00085                 span->g = p[order_type::G];
00086                 span->b = p[order_type::B];
00087                 span->a = m_alpha;
00088                 p = m_src->next_x();
00089                 ++span;
00090             }
00091             while(--len);
00092         }
00093 
00094     private:
00095         source_type* m_src;
00096         unsigned     m_offset_x;
00097         unsigned     m_offset_y;
00098         value_type   m_alpha;
00099 
00100     };
00101 
00102 }
00103 
00104 #endif
00105 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines