⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agg_pixfmt_rgb.h

📁 这是VCF框架的代码
💻 H
📖 第 1 页 / 共 2 页
字号:
                        p = (value_type*)                            m_rbuf->row_ptr(x, y++, 1) + x + x + x;                        p[order_type::R] = c.r;                         p[order_type::G] = c.g;                         p[order_type::B] = c.b;                    }                    while(--len);                }                else                {                    do                    {                        p = (value_type*)                            m_rbuf->row_ptr(x, y++, 1) + x + x + x;                        m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover);                    }                    while(--len);                }            }        }        //--------------------------------------------------------------------        void blend_solid_hspan(int x, int y,                               unsigned len,                                const color_type& c,                               const int8u* covers)        {            if (c.a)            {                value_type* p = (value_type*)                    m_rbuf->row_ptr(x, y, len) + x + x + x;                do                 {                    calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;                    if(alpha == base_mask)                    {                        p[order_type::R] = c.r;                        p[order_type::G] = c.g;                        p[order_type::B] = c.b;                    }                    else                    {                        m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers);                    }                    p += 3;                    ++covers;                }                while(--len);            }        }        //--------------------------------------------------------------------        void blend_solid_vspan(int x, int y,                               unsigned len,                                const color_type& c,                               const int8u* covers)        {            if (c.a)            {                do                 {                    value_type* p = (value_type*)                        m_rbuf->row_ptr(x, y++, 1) + x + x + x;                    calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;                    if(alpha == base_mask)                    {                        p[order_type::R] = c.r;                        p[order_type::G] = c.g;                        p[order_type::B] = c.b;                    }                    else                    {                        m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers);                    }                    ++covers;                }                while(--len);            }        }        //--------------------------------------------------------------------        void copy_color_hspan(int x, int y,                              unsigned len,                               const color_type* colors)        {            value_type* p = (value_type*)                m_rbuf->row_ptr(x, y, len) + x + x + x;            do             {                p[order_type::R] = colors->r;                p[order_type::G] = colors->g;                p[order_type::B] = colors->b;                ++colors;                p += 3;            }            while(--len);        }        //--------------------------------------------------------------------        void blend_color_hspan(int x, int y,                               unsigned len,                                const color_type* colors,                               const int8u* covers,                               int8u cover)        {            value_type* p = (value_type*)                m_rbuf->row_ptr(x, y, len) + x + x + x;            if(covers)            {                do                 {                    copy_or_blend_pix(p, *colors++, *covers++);                    p += 3;                }                while(--len);            }            else            {                if(cover == 255)                {                    do                     {                        copy_or_blend_pix(p, *colors++);                        p += 3;                    }                    while(--len);                }                else                {                    do                     {                        copy_or_blend_pix(p, *colors++, cover);                        p += 3;                    }                    while(--len);                }            }        }        //--------------------------------------------------------------------        void blend_color_vspan(int x, int y,                               unsigned len,                                const color_type* colors,                               const int8u* covers,                               int8u cover)        {            value_type* p;            if(covers)            {                do                 {                    p = (value_type*)                        m_rbuf->row_ptr(x, y++, 1) + x + x + x;                    copy_or_blend_pix(p, *colors++, *covers++);                }                while(--len);            }            else            {                if(cover == 255)                {                    do                     {                        p = (value_type*)                            m_rbuf->row_ptr(x, y++, 1) + x + x + x;                        copy_or_blend_pix(p, *colors++);                    }                    while(--len);                }                else                {                    do                     {                        p = (value_type*)                            m_rbuf->row_ptr(x, y++, 1) + x + x + x;                        copy_or_blend_pix(p, *colors++, cover);                    }                    while(--len);                }            }        }        //--------------------------------------------------------------------        template<class Function> void for_each_pixel(Function f)        {            unsigned y;            for(y = 0; y < height(); ++y)            {                row_data r = m_rbuf->row(y);                if(r.ptr)                {                    unsigned len = r.x2 - r.x1 + 1;                    value_type* p = (value_type*)                        m_rbuf->row_ptr(r.x1, y, len) + r.x1 * 3;                    do                    {                        f(p);                        p += 3;                    }                    while(--len);                }            }        }        //--------------------------------------------------------------------        template<class GammaLut> void apply_gamma_dir(const GammaLut& g)        {            for_each_pixel(apply_gamma_dir_rgb<color_type, order_type, GammaLut>(g));        }        //--------------------------------------------------------------------        template<class GammaLut> void apply_gamma_inv(const GammaLut& g)        {            for_each_pixel(apply_gamma_inv_rgb<color_type, order_type, GammaLut>(g));        }        //--------------------------------------------------------------------        template<class RenBuf2>        void copy_from(const RenBuf2& from,                        int xdst, int ydst,                       int xsrc, int ysrc,                       unsigned len)        {            const int8u* p = from.row_ptr(ysrc);            if(p)            {                memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,                         p + xsrc * pix_width,                         len * pix_width);            }        }        //--------------------------------------------------------------------        template<class SrcPixelFormatRenderer>        void blend_from(const SrcPixelFormatRenderer& from,                         int xdst, int ydst,                        int xsrc, int ysrc,                        unsigned len,                        int8u cover)        {            typedef typename SrcPixelFormatRenderer::order_type src_order;            const value_type* psrc = (const value_type*)from.row_ptr(ysrc);            if(psrc)            {                psrc += xsrc * 4;                value_type* pdst =                     (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;                   if(cover == 255)                {                    do                     {                        value_type alpha = psrc[src_order::A];                        if(alpha)                        {                            if(alpha == base_mask)                            {                                pdst[order_type::R] = psrc[src_order::R];                                pdst[order_type::G] = psrc[src_order::G];                                pdst[order_type::B] = psrc[src_order::B];                            }                            else                            {                                m_blender.blend_pix(pdst,                                                     psrc[src_order::R],                                                    psrc[src_order::G],                                                    psrc[src_order::B],                                                    alpha);                            }                        }                        psrc += 4;                        pdst += 3;                    }                    while(--len);                }                else                {                    color_type color;                    do                     {                        color.r = psrc[src_order::R];                        color.g = psrc[src_order::G];                        color.b = psrc[src_order::B];                        color.a = psrc[src_order::A];                        copy_or_blend_pix(pdst, color, cover);                        psrc += 4;                        pdst += 3;                    }                    while(--len);                }            }        }    private:        rbuf_type* m_rbuf;        Blender    m_blender;    };    typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba8,  order_rgb>, rendering_buffer> pixfmt_rgb24;    //----pixfmt_rgb24    typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba8,  order_bgr>, rendering_buffer> pixfmt_bgr24;    //----pixfmt_bgr24    typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba16, order_rgb>, rendering_buffer> pixfmt_rgb48;    //----pixfmt_rgb48    typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba16, order_bgr>, rendering_buffer> pixfmt_bgr48;    //----pixfmt_bgr48    typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8,  order_rgb>, rendering_buffer> pixfmt_rgb24_pre; //----pixfmt_rgb24_pre    typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8,  order_bgr>, rendering_buffer> pixfmt_bgr24_pre; //----pixfmt_bgr24_pre    typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_rgb>, rendering_buffer> pixfmt_rgb48_pre; //----pixfmt_rgb48_pre    typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_bgr>, rendering_buffer> pixfmt_bgr48_pre; //----pixfmt_bgr48_pre    //-----------------------------------------------------pixfmt_rgb24_gamma    template<class Gamma> class pixfmt_rgb24_gamma :     public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>    {    public:        pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) :            pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>(rb)         {            this->blender().gamma(g);        }    };            //-----------------------------------------------------pixfmt_bgr24_gamma    template<class Gamma> class pixfmt_bgr24_gamma :     public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>    {    public:        pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) :            pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>(rb)         {            this->blender().gamma(g);        }    };    //-----------------------------------------------------pixfmt_rgb48_gamma    template<class Gamma> class pixfmt_rgb48_gamma :     public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>    {    public:        pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) :            pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>(rb)         {            this->blender().gamma(g);        }    };            //-----------------------------------------------------pixfmt_bgr48_gamma    template<class Gamma> class pixfmt_bgr48_gamma :     public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>    {    public:        pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) :            pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>(rb)         {            this->blender().gamma(g);        }    };}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -