unsafe private void BlendInFilterPixel(uint *fg, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer pSourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            unchecked
            {
                byte *fg_ptr;
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    fg[OrderA] += back_a * weight;
                }
            }
        }
示例#2
0
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
            RasterBuffer      pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer;
            ISpanInterpolator spanInterpolator       = base.interpolator();

            spanInterpolator.Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);
            do
            {
                int x_hr;
                int y_hr;
                spanInterpolator.Coordinates(out x_hr, out y_hr);
                int   x_lr   = x_hr >> (int)image_subpixel_scale_e.Shift;
                int   y_lr   = y_hr >> (int)image_subpixel_scale_e.Shift;
                byte *fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);
                //byte* fg_ptr = spanInterpolator.Span(x_lr, y_lr, 1);
                (*span).m_R = fg_ptr[OrderR];
                (*span).m_G = fg_ptr[OrderG];
                (*span).m_B = fg_ptr[OrderB];
                (*span).m_A = fg_ptr[OrderA];
                ++span;
                spanInterpolator.Next();
            } while(--len != 0);
        }
        unsafe private void BlendInFilterPixel(uint *fg, ref uint src_alpha, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer SourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            byte *fg_ptr;

            unchecked
            {
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lr * 3;

                    fg[0]     += weight * fg_ptr[0];
                    fg[1]     += weight * fg_ptr[1];
                    fg[2]     += weight * fg_ptr[2];
                    src_alpha += weight * base_mask;
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    src_alpha  += back_a * weight;
                }
            }
        }
示例#4
0
        private unsafe void BlendInFilterPixel(uint* fg, ref uint src_alpha, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer SourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            byte* fg_ptr;
            unchecked
            {
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lr * 3;

                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    src_alpha += weight * base_mask;
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    src_alpha += back_a * weight;
                }
            }
        }
        public unsafe void Generate(out RGBA_Bytes destPixel, int x, int y)
        {
            base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), 1);

            uint *fg = stackalloc uint[4];

            byte *fg_ptr;

            RasterBuffer      pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer;
            int               maxx             = (int)pSourceRenderingBuffer.Width() - 1;
            int               maxy             = (int)pSourceRenderingBuffer.Height() - 1;
            ISpanInterpolator spanInterpolator = base.interpolator();

            unchecked
            {
                int x_hr;
                int y_hr;

                spanInterpolator.Coordinates(out x_hr, out y_hr);

                x_hr -= base.filter_dx_int();
                y_hr -= base.filter_dy_int();

                int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                uint weight;

                fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                x_hr &= (int)image_subpixel_scale_e.Mask;
                y_hr &= (int)image_subpixel_scale_e.Mask;

                fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                ((int)image_subpixel_scale_e.Scale - y_hr));
                fg[0] += weight * fg_ptr[0];
                fg[1] += weight * fg_ptr[1];
                fg[2] += weight * fg_ptr[2];
                fg[3] += weight * fg_ptr[3];

                weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                fg[0] += weight * fg_ptr[4];
                fg[1] += weight * fg_ptr[5];
                fg[2] += weight * fg_ptr[6];
                fg[3] += weight * fg_ptr[7];

                ++y_lr;
                fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                fg[0] += weight * fg_ptr[0];
                fg[1] += weight * fg_ptr[1];
                fg[2] += weight * fg_ptr[2];
                fg[3] += weight * fg_ptr[3];

                weight = (uint)(x_hr * y_hr);
                fg[0] += weight * fg_ptr[4];
                fg[1] += weight * fg_ptr[5];
                fg[2] += weight * fg_ptr[6];
                fg[3] += weight * fg_ptr[7];

                fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;

                destPixel.m_R = (byte)fg[OrderR];
                destPixel.m_G = (byte)fg[OrderG];
                destPixel.m_B = (byte)fg[OrderB];
                destPixel.m_A = (byte)fg[OrderA];
            }
        }
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
#if use_timers
            Generate_Span.Start();
#endif
            base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);

            //uint[] fg = new uint[4];
            uint *fg = stackalloc uint[4];

            uint back_r = m_back_color.m_R;
            uint back_g = m_back_color.m_G;
            uint back_b = m_back_color.m_B;
            uint back_a = m_back_color.m_A;

            byte *fg_ptr;

            RasterBuffer      pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer;
            int               maxx             = (int)pSourceRenderingBuffer.Width() - 1;
            int               maxy             = (int)pSourceRenderingBuffer.Height() - 1;
            ISpanInterpolator spanInterpolator = base.interpolator();

            unchecked
            {
                do
                {
                    int x_hr;
                    int y_hr;

                    spanInterpolator.Coordinates(out x_hr, out y_hr);

                    x_hr -= base.filter_dx_int();
                    y_hr -= base.filter_dy_int();

                    int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                    int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                    uint weight;

                    if (x_lr >= 0 && y_lr >= 0 &&
                        x_lr < maxx && y_lr < maxy)
                    {
                        fg[0]             =
                            fg[1]         =
                                fg[2]     =
                                    fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                        x_hr &= (int)image_subpixel_scale_e.Mask;
                        y_hr &= (int)image_subpixel_scale_e.Mask;

                        fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                        weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                        ((int)image_subpixel_scale_e.Scale - y_hr));
                        fg[0] += weight * fg_ptr[0];
                        fg[1] += weight * fg_ptr[1];
                        fg[2] += weight * fg_ptr[2];
                        fg[3] += weight * fg_ptr[3];

                        weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                        fg[0] += weight * fg_ptr[4];
                        fg[1] += weight * fg_ptr[5];
                        fg[2] += weight * fg_ptr[6];
                        fg[3] += weight * fg_ptr[7];

                        ++y_lr;
                        fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                        weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                        fg[0] += weight * fg_ptr[0];
                        fg[1] += weight * fg_ptr[1];
                        fg[2] += weight * fg_ptr[2];
                        fg[3] += weight * fg_ptr[3];

                        weight = (uint)(x_hr * y_hr);
                        fg[0] += weight * fg_ptr[4];
                        fg[1] += weight * fg_ptr[5];
                        fg[2] += weight * fg_ptr[6];
                        fg[3] += weight * fg_ptr[7];

                        fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;
                    }
                    else
                    {
                        if (x_lr < -1 || y_lr < -1 ||
                            x_lr > maxx || y_lr > maxy)
                        {
                            fg[OrderR] = back_r;
                            fg[OrderG] = back_g;
                            fg[OrderB] = back_b;
                            fg[OrderA] = back_a;
                        }
                        else
                        {
                            fg[0]             =
                                fg[1]         =
                                    fg[2]     =
                                        fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                            x_hr &= (int)image_subpixel_scale_e.Mask;
                            y_hr &= (int)image_subpixel_scale_e.Mask;

                            weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                            ((int)image_subpixel_scale_e.Scale - y_hr));
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr--;
                            y_lr++;

                            weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (uint)(x_hr * y_hr);
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;
                        }
                    }

                    (*span).m_R = (byte)fg[0];
                    (*span).m_G = (byte)fg[1];
                    (*span).m_B = (byte)fg[2];
                    (*span).m_A = (byte)fg[3];
                    ++span;
                    spanInterpolator.Next();
                } while (--len != 0);
            }
#if use_timers
            Generate_Span.Stop();
#endif
        }
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
#if use_timers
            Generate_Span.Start();
#endif
            base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);

            uint *fg = stackalloc uint[4];

            byte *fg_ptr;

            RasterBuffer      pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer;
            int               maxx             = (int)pSourceRenderingBuffer.Width() - 1;
            int               maxy             = (int)pSourceRenderingBuffer.Height() - 1;
            ISpanInterpolator spanInterpolator = base.interpolator();

            unchecked
            {
                do
                {
                    int x_hr;
                    int y_hr;

                    spanInterpolator.Coordinates(out x_hr, out y_hr);

                    x_hr -= base.filter_dx_int();
                    y_hr -= base.filter_dy_int();

                    int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                    int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                    uint weight;

                    fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                    x_hr &= (int)image_subpixel_scale_e.Mask;
                    y_hr &= (int)image_subpixel_scale_e.Mask;

                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                    ((int)image_subpixel_scale_e.Scale - y_hr));
                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];

                    weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                    fg[0] += weight * fg_ptr[4];
                    fg[1] += weight * fg_ptr[5];
                    fg[2] += weight * fg_ptr[6];
                    fg[3] += weight * fg_ptr[7];

                    ++y_lr;
                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];

                    weight = (uint)(x_hr * y_hr);
                    fg[0] += weight * fg_ptr[4];
                    fg[1] += weight * fg_ptr[5];
                    fg[2] += weight * fg_ptr[6];
                    fg[3] += weight * fg_ptr[7];

                    fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;

                    (*span).m_R = (byte)fg[OrderR];
                    (*span).m_G = (byte)fg[OrderG];
                    (*span).m_B = (byte)fg[OrderB];
                    (*span).m_A = (byte)fg[OrderA];
                    ++span;
                    spanInterpolator.Next();
                } while (--len != 0);
            }
#if use_timers
            Generate_Span.Stop();
#endif
        }
        private unsafe void BlendInFilterPixel(uint* fg, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer pSourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            unchecked
            {
                byte* fg_ptr;
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    fg[OrderA] += back_a * weight;
                }
            }
        }
示例#9
0
文件: RgbA.cs 项目: hj1980/Mosa
 public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     unsafe
     {
         Basics.memmove(&m_rbuf.GetPixelPointer(ydst)[xdst * 4],
                 &sourceBuffer.GetPixelPointer(ysrc)[xsrc * 4],
                 (int)len * 4);
     }
 }
示例#10
0
文件: Gray.cs 项目: hj1980/Mosa
 public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     unsafe
     {
         byte* pSource = sourceBuffer.GetPixelPointer(ysrc);
         if (pSource != null)
         {
             int BytesPerScanLine = Stride;
             Basics.memmove(m_rbuf.GetPixelPointer(ydst) + xdst * BytesPerScanLine,
                     pSource + xsrc * BytesPerScanLine,
                     (int)len * BytesPerScanLine);
         }
     }
 }