示例#1
0
 //---------------------------------------------------------------------
 public OutlineRenderer(PixelProcessing.IBitmapBlender destImage, PixelProcessing.PixelBlender32 destPixelBlender, LineProfileAnitAlias profile)
 {
     destImageSurface      = destImage;
     lineProfile           = profile;
     clippingRectangle     = new RectInt(0, 0, 0, 0);
     doClipping            = false;
     this.destPixelBlender = destPixelBlender;
 }
示例#2
0
        //---------------------------------------------------------------------
        //typedef renderer_outline_image<BaseRenderer, ImagePattern> self_type;

        //---------------------------------------------------------------------
        public ImageLineRenderer(PixelProcessing.IBitmapBlender ren, LineImagePattern patt)
        {
            _ren      = ren;
            _pattern  = patt;
            _start    = (0);
            _scale_x  = (1.0);
            _clip_box = new Q1Rect(0, 0, 0, 0);
            _clipping = (false);
        }
示例#3
0
文件: Square.cs 项目: BiDuc/PixelFarm
 public void Draw(
     DestBitmapRasterizer bmpRast,
     ScanlineRasterizer ras,
     Scanline sl,
     PixelProcessing.IBitmapBlender destImage, Color color,
     double x, double y)
 {
     ras.Reset();
     ras.MoveTo(x * _size, y * _size);
     ras.LineTo(x * _size + _size, y * _size);
     ras.LineTo(x * _size + _size, y * _size + _size);
     ras.LineTo(x * _size, y * _size + _size);
     bmpRast.RenderWithColor(destImage, ras, sl, color);
 }
示例#4
0
        public void Draw(
            DestBitmapRasterizer bmpRast,
            ScanlineRasterizer ras,
            Scanline sl,
            PixelProcessing.IBitmapBlender destImage, Color color,
            double x, double y)
        {
#if DEBUG
            //low-level scanline rasterizer example
            ras.Reset();
            ras.dbugDevMoveTo(x * _size, y * _size);
            ras.dbugDevLineTo(x * _size + _size, y * _size);
            ras.dbugDevLineTo(x * _size + _size, y * _size + _size);
            ras.dbugDevLineTo(x * _size, y * _size + _size);
            bmpRast.RenderWithColor(destImage, ras, sl, color);
#endif
        }
 public FormatTransposer(PixelProcessing.IBitmapBlender pixelFormat)
     : base(pixelFormat)
 {
 }
示例#6
0
 public void Attach(PixelProcessing.IBitmapBlender ren)
 {
     _ren = ren;
 }
示例#7
0
        void SubPixRender(PixelProcessing.IBitmapBlender destImage, Scanline scanline, Color color)
        {
            int y         = scanline.Y;
            int num_spans = scanline.SpanCount;

            byte[]             covers = scanline.GetCovers();
            ScanlineRasterizer ras    = _gfx.ScanlineRasterizer;
            var rasToBmp = _gfx.BitmapRasterizer;
            //------------------------------------------
            Color bgColor = Color.White;
            float cb_R    = bgColor.R / 255f;
            float cb_G    = bgColor.G / 255f;
            float cb_B    = bgColor.B / 255f;
            float cf_R    = color.R / 255f;
            float cf_G    = color.G / 255f;
            float cf_B    = color.B / 255f;

            //------------------------------------------

            for (int i = 0; i <= num_spans; ++i)
            {
                //render span by span
                ScanlineSpan span       = scanline.GetSpan(i);
                int          x          = span.x;
                int          num_pix    = span.len;
                int          coverIndex = span.cover_index;
                //test subpixel rendering concept
                //----------------------------------------------------

                int prev_cover = 0;
                while (num_pix > 0)
                {
                    byte coverageValue = covers[coverIndex++];
                    if (coverageValue >= 255)
                    {
                        //100% cover
                        int a = (coverageValue * color.A) >> 8;
                        _square.Draw(rasToBmp,
                                     ras, _sl, destImage,
                                     Color.FromArgb(a, Color.FromArgb(color.R, color.G, color.B)),
                                     x, y);
                        prev_cover = 255;//full
                    }
                    else
                    {
                        //check direction :
                        bool isUpHill = (coverageValue % 2) > 0;
                        //--------------------------------------------------------------------
                        //TODO: review here
                        //in somecase, demo3, isUpHill2 != isUpHill
                        //but we skip it, because we don't want context color around the point
                        //so when we use in fragment shader we can pick up a single color
                        //and determine what color it should be
                        bool isUpHill2 = coverageValue > prev_cover;
                        if (isUpHill != isUpHill2)
                        {
                        }
                        //--------------------------------------------------------------------
                        prev_cover = coverageValue;
                        byte  c_r, c_g, c_b;
                        float subpix_percent = ((float)(coverageValue) / 256f);
                        if (coverageValue < _cover_1_3)
                        {
                            //assume LCD color arrangement is RGB
                            if (isUpHill)
                            {
                                c_r = bgColor.R;
                                c_g = bgColor.G;
                                c_b = (byte)(mix(cb_B, cf_B, subpix_percent) * 255);
                            }
                            else
                            {
                                c_r = (byte)(mix(cb_R, cf_R, subpix_percent) * 255);
                                c_g = bgColor.G;
                                c_b = bgColor.B;
                            }


                            int a = (coverageValue * color.A) >> 8;
                            _square.Draw(rasToBmp,
                                         ras, _sl, destImage,
                                         Color.FromArgb(a, Color.FromArgb(c_r, c_g, c_b)),
                                         x, y);
                        }
                        else if (coverageValue < _cover_2_3)
                        {
                            if (isUpHill)
                            {
                                c_r = bgColor.R;
                                c_g = (byte)(mix(cb_G, cf_G, subpix_percent) * 255);
                                c_b = (byte)(mix(cb_B, cf_B, 1) * 255);
                            }
                            else
                            {
                                c_r = (byte)(mix(cb_R, cf_R, 1) * 255);
                                c_g = (byte)(mix(cb_G, cf_G, subpix_percent) * 255);
                                c_b = bgColor.B;
                            }



                            int a = (coverageValue * color.A) >> 8;
                            _square.Draw(rasToBmp,
                                         ras, _sl, destImage,
                                         Color.FromArgb(a, Color.FromArgb(c_r, c_g, c_b)),
                                         x, y);
                        }
                        else
                        {
                            //cover > 2/3 but not full
                            if (isUpHill)
                            {
                                c_r = (byte)(mix(cb_R, cf_R, subpix_percent) * 255);
                                c_g = (byte)(mix(cb_G, cf_G, 1) * 255);
                                c_b = (byte)(mix(cb_B, cf_B, 1) * 255);
                            }
                            else
                            {
                                c_r = (byte)(mix(cb_R, cf_R, 1) * 255);
                                c_g = (byte)(mix(cb_G, cf_G, 1) * 255);
                                c_b = (byte)(mix(cb_B, cf_B, subpix_percent) * 255);
                            }


                            int a = (coverageValue * color.A) >> 8;
                            _square.Draw(rasToBmp,
                                         ras, _sl, destImage,
                                         Color.FromArgb(a, Color.FromArgb(c_r, c_g, c_b)),
                                         x, y);
                        }
                    }


                    ++x;
                    --num_pix;
                }
            }
        }
示例#8
0
 protected override void CustomRenderSingleScanLine(PixelProcessing.IBitmapBlender destImage, Scanline scanline, Color color)
 {
     SubPixRender(destImage, scanline, color);
 }
示例#9
0
 public ClipProxyImage(PixelProcessing.IBitmapBlender refImage)
     : base(refImage)
 {
     _clippingRect = new RectInt(0, 0, (int)refImage.Width - 1, (int)refImage.Height - 1);
 }