16 #ifndef AGG_IMAGE_ACCESSORS_INCLUDED    17 #define AGG_IMAGE_ACCESSORS_INCLUDED    19 #include "agg_basics.h"    28         typedef PixFmt   pixfmt_type;
    29         typedef typename pixfmt_type::color_type color_type;
    30         typedef typename pixfmt_type::order_type order_type;
    31         typedef typename pixfmt_type::value_type value_type;
    32         enum pix_width_e { pix_width = pixfmt_type::pix_width };
    36                                      const color_type& bk) : 
    39             pixfmt_type::make_pix(m_bk_buf, bk);
    42         void attach(pixfmt_type& pixf)
    47         void background_color(
const color_type& bk)
    49             pixfmt_type::make_pix(m_bk_buf, bk);
    53         AGG_INLINE 
const int8u* pixel()
 const    55             if(m_y >= 0 && m_y < (
int)m_pixf->height() &&
    56                m_x >= 0 && m_x < (int)m_pixf->width())
    58                 return m_pixf->pix_ptr(m_x, m_y);
    64         AGG_INLINE 
const int8u* span(
int x, 
int y, 
unsigned len)
    68             if(y >= 0 && y < (
int)m_pixf->height() &&
    69                x >= 0 && x+(int)len <= (
int)m_pixf->width())
    71                 return m_pix_ptr = m_pixf->pix_ptr(x, y);
    77         AGG_INLINE 
const int8u* next_x()
    79             if(m_pix_ptr) 
return m_pix_ptr += pix_width;
    84         AGG_INLINE 
const int8u* next_y()
    89                m_y >= 0 && m_y < (
int)m_pixf->height())
    91                 return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y);
    98         const pixfmt_type* m_pixf;
    99         int8u              m_bk_buf[pix_width];
   101         const int8u*       m_pix_ptr;
   111         typedef PixFmt   pixfmt_type;
   112         typedef typename pixfmt_type::color_type color_type;
   113         typedef typename pixfmt_type::order_type order_type;
   114         typedef typename pixfmt_type::value_type value_type;
   115         enum pix_width_e { pix_width = pixfmt_type::pix_width };
   122         void attach(pixfmt_type& pixf)
   127         AGG_INLINE 
const int8u* span(
int x, 
int y, 
unsigned)
   131             return m_pix_ptr = m_pixf->pix_ptr(x, y);
   134         AGG_INLINE 
const int8u* next_x()
   136             return m_pix_ptr += pix_width;
   139         AGG_INLINE 
const int8u* next_y()
   142             return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y);
   146         const pixfmt_type* m_pixf;
   148         const int8u*       m_pix_ptr;
   158         typedef PixFmt   pixfmt_type;
   159         typedef typename pixfmt_type::color_type color_type;
   160         typedef typename pixfmt_type::order_type order_type;
   161         typedef typename pixfmt_type::value_type value_type;
   162         enum pix_width_e { pix_width = pixfmt_type::pix_width };
   169         void attach(pixfmt_type& pixf)
   175         AGG_INLINE 
const int8u* pixel()
 const   181             if(x >= (
int)m_pixf->width())  x = m_pixf->width() - 1;
   182             if(y >= (
int)m_pixf->height()) y = m_pixf->height() - 1;
   183             return m_pixf->pix_ptr(x, y);
   187         AGG_INLINE 
const int8u* span(
int x, 
int y, 
unsigned len)
   191             if(y >= 0 && y < (
int)m_pixf->height() &&
   192                x >= 0 && x+len <= (int)m_pixf->width())
   194                 return m_pix_ptr = m_pixf->pix_ptr(x, y);
   200         AGG_INLINE 
const int8u* next_x()
   202             if(m_pix_ptr) 
return m_pix_ptr += pix_width;
   207         AGG_INLINE 
const int8u* next_y()
   212                m_y >= 0 && m_y < (
int)m_pixf->height())
   214                 return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y);
   221         const pixfmt_type* m_pixf;
   223         const int8u*       m_pix_ptr;
   234         typedef PixFmt   pixfmt_type;
   235         typedef typename pixfmt_type::color_type color_type;
   236         typedef typename pixfmt_type::order_type order_type;
   237         typedef typename pixfmt_type::value_type value_type;
   238         enum pix_width_e { pix_width = pixfmt_type::pix_width };
   243             m_wrap_x(pixf.width()), 
   244             m_wrap_y(pixf.height())
   247         void attach(pixfmt_type& pixf)
   252         AGG_INLINE 
const int8u* span(
int x, 
int y, 
unsigned)
   255             m_row_ptr = m_pixf->pix_ptr(0, m_wrap_y(y));
   256             return m_row_ptr + m_wrap_x(x) * pix_width;
   259         AGG_INLINE 
const int8u* next_x()
   262             return m_row_ptr + x * pix_width;
   265         AGG_INLINE 
const int8u* next_y()
   267             m_row_ptr = m_pixf->pix_ptr(0, ++m_wrap_y);
   268             return m_row_ptr + m_wrap_x(m_x) * pix_width;
   272         const pixfmt_type* m_pixf;
   273         const int8u*       m_row_ptr;
   289             m_add(size * (0x3FFFFFFF / size)),
   293         AGG_INLINE 
unsigned operator() (
int v)
   295             return m_value = (unsigned(v) + m_add) % m_size; 
   298         AGG_INLINE 
unsigned operator++ ()
   301             if(m_value >= m_size) m_value = 0;
   319             while(m_mask < size) m_mask = (m_mask << 1) | 1;
   322         AGG_INLINE 
unsigned operator() (
int v)
   324             return m_value = unsigned(v) & m_mask;
   326         AGG_INLINE 
unsigned operator++ ()
   329             if(m_value > m_mask) m_value = 0;
   345             m_add(size * (0x3FFFFFFF / size)),
   346             m_mask((m_size & (m_size-1)) ? 0 : m_size-1),
   350         AGG_INLINE 
unsigned operator() (
int v) 
   352             if(m_mask) 
return m_value = unsigned(v) & m_mask;
   353             return m_value = (unsigned(v) + m_add) % m_size;
   355         AGG_INLINE 
unsigned operator++ ()
   358             if(m_value >= m_size) m_value = 0;
   378             m_add(m_size2 * (0x3FFFFFFF / m_size2)),
   382         AGG_INLINE 
unsigned operator() (
int v)
   384             m_value = (unsigned(v) + m_add) % m_size2;
   385             if(m_value >= m_size) 
return m_size2 - m_value - 1;
   389         AGG_INLINE 
unsigned operator++ ()
   392             if(m_value >= m_size2) m_value = 0;
   393             if(m_value >= m_size) 
return m_size2 - m_value - 1;
   416                 m_mask = (m_mask << 1) | 1;
   420         AGG_INLINE 
unsigned operator() (
int v)
   422             m_value = unsigned(v) & m_mask;
   423             if(m_value >= m_size) 
return m_mask - m_value;
   426         AGG_INLINE 
unsigned operator++ ()
   430             if(m_value >= m_size) 
return m_mask - m_value;
   449             m_add(m_size2 * (0x3FFFFFFF / m_size2)),
   450             m_mask((m_size2 & (m_size2-1)) ? 0 : m_size2-1),
   454         AGG_INLINE 
unsigned operator() (
int v) 
   456             m_value = m_mask ? unsigned(v) & m_mask : 
   457                               (unsigned(v) + m_add) % m_size2;
   458             if(m_value >= m_size) 
return m_size2 - m_value - 1;
   461         AGG_INLINE 
unsigned operator++ ()
   464             if(m_value >= m_size2) m_value = 0;
   465             if(m_value >= m_size) 
return m_size2 - m_value - 1;