Anti-Grain Geometry - AGG (libagg)  2.5
agg-2.5/include/agg_span_pattern_gray.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_GRAY_INCLUDED
00035 #define AGG_SPAN_PATTERN_GRAY_INCLUDED
00036 
00037 #include "agg_basics.h"
00038 
00039 namespace agg
00040 {
00041 
00042     //=======================================================span_pattern_gray
00043     template<class Source> class span_pattern_gray
00044     {
00045     public:
00046         typedef Source source_type;
00047         typedef typename source_type::color_type color_type;
00048         typedef typename color_type::value_type value_type;
00049         typedef typename color_type::calc_type calc_type;
00050 
00051         //--------------------------------------------------------------------
00052         span_pattern_gray() {}
00053         span_pattern_gray(source_type& src, 
00054                           unsigned offset_x, unsigned offset_y) :
00055             m_src(&src),
00056             m_offset_x(offset_x),
00057             m_offset_y(offset_y),
00058             m_alpha(color_type::base_mask)
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 v) { m_alpha = v; }
00072         value_type alpha() const { return m_alpha; }
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->v = *p;
00084                 span->a = m_alpha;
00085                 p = m_src->next_x();
00086                 ++span;
00087             }
00088             while(--len);
00089         }
00090 
00091     private:
00092         source_type* m_src;
00093         unsigned     m_offset_x;
00094         unsigned     m_offset_y;
00095         value_type   m_alpha;
00096 
00097     };
00098 
00099 }
00100 
00101 #endif
00102 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines