Example #1
0
        //--------------------------------------------------------------------
        void generate(color_type* span, int x, int y, int len)
        {
            if(y < 1 || y >= int(m_source_image->height() - 1))
            {
                do
                {
                    *span++ = rgba8(0,0,0,0);
                }
                while(--len);
                return;
            }

            do
            {
                int color[4];
                color[0] = color[1] = color[2] = color[3] = 0;
                if(x > 0 && x < int(m_source_image->width()-1))
                {
                    int i = 3;
                    do
                    {
                        const int8u* ptr = m_source_image->row_ptr(y - i + 2) + (x - 1) * 3;

                        color[0] += *ptr++;
                        color[1] += *ptr++;
                        color[2] += *ptr++;
                        color[3] += 255;

                        color[0] += *ptr++;
                        color[1] += *ptr++;
                        color[2] += *ptr++;
                        color[3] += 255;

                        color[0] += *ptr++;
                        color[1] += *ptr++;
                        color[2] += *ptr++;
                        color[3] += 255;
                    }
                    while(--i);
                    color[0] /= 9;
                    color[1] /= 9;
                    color[2] /= 9;
                    color[3] /= 9;
                }
                *span++ = rgba8(color[Order::R], color[Order::G], color[Order::B], color[3]);
                ++x;
            }
            while(--len);
        }
Example #2
0
		void Pixmap::checkers(const rgba8& color) {
			//const int D = min(height(), width()) / 16;
			int mask;
			rgba8 colorMasked = rgba8(color.x ^ 255, color.y ^ 255, color.z ^ 255, color.w);
			for (int x = 0; x < width(); x++) {
				for (int y = 0; y < height(); y++) {
					mask = ((x & 16) == 0) ^ ((y & 16) == 0);
					if(mask)
						putPixel(x, y, colorMasked);
					else
						putPixel(x, y, color);
				}
			}
		}
Example #3
0
        //--------------------------------------------------------------------
        template<class Scanline> void render(const Scanline& sl)
        {
            int y = sl.y();

            unsigned num_spans = sl.num_spans();
            typename Scanline::const_iterator span = sl.begin();

            do
            {
                int x = span->x;
                const typename Scanline::cover_type* covers = span->covers;
                int num_pix = span->len;
                
                do 
                {
                    int a = (*covers++ * m_color.a) >> 8;
                    m_ren.color(rgba8(m_color.r, m_color.g, m_color.b, a));
                    m_square.draw(m_ras, m_sl, m_ren, x, y);
                    ++x;
                }
                while(--num_pix);
            }
            while(--num_spans);
        }