Exemplo n.º 1
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            if (!_resInit)
            {
                _msdf_bmp = DemoHelper.LoadTexture(_fontAtlas.MainBitmap);
                _resInit  = true;
            }

            _painter.Clear(PixelFarm.Drawing.Color.White);


            _fontAtlas.TryGetItem(_glyphIndex_0, out AtlasItem glyphData);
            PixelFarm.Drawing.Rectangle r =
                new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                glyphData.Top,
                                                glyphData.Width,
                                                glyphData.Height);

            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r, 100, 40);

            _fontAtlas.TryGetItem(_glyphIndex_1, out glyphData);
            PixelFarm.Drawing.Rectangle r2 = new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                                             glyphData.Top,
                                                                             glyphData.Width,
                                                                             glyphData.Height);
            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r2, 100 + r.Width, 40);

            //full image
            _pcx.DrawImage(_msdf_bmp, 0, 100);
            SwapBuffers();
        }
Exemplo n.º 2
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            if (!_resInit)
            {
                _msdf_bmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\msdf_75.png");
                _resInit  = true;
            }
            _pcx.Clear(PixelFarm.Drawing.Color.White);

            //canvas2d.DrawImageWithMsdf(msdf_bmp, 0, 400, 6);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 500, 0.5f);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 520, 0.4f);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 550, 0.3f);
            //canvas2d.DrawImage(msdf_bmp, 150, 400);

            //_pcx.draw(_msdf_bmp, 200, 500, 15f, );
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 500, 0.5f);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 520, 0.4f);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 550, 0.3f);

            _pcx.DrawImageWithMsdf(_msdf_bmp, 300, 500, 0.5f, PixelFarm.Drawing.Color.Black);
            ////
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 400, 6);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 500, 0.5f);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 520, 0.4f);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 550, 0.3f);
            _pcx.DrawImage(_msdf_bmp, 100, 300);

            SwapBuffers();
        }
Exemplo n.º 3
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = ConvertFromBGRA_To_RGBA(DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg"));
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOrientation prevOrgKind = _pcx.OriginKind; //save
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
            //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);
            for (int i = 0; i < 1; ++i)
            {
                _pcx.DrawImage(_glbmp, 100 + (i * 30), 200 + (i * 30));
            }

            //-------------------------------
            _pcx.OriginKind = prevOrgKind;//restore
        }
Exemplo n.º 4
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            _painter.FillColor = PixelFarm.Drawing.Color.Black;
            _painter.FillRect(0, 0, 150, 150);
            GLBitmap glBmp        = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
            var      textureBrush = new TextureBrush(glBmp);

            _painter.FillRenderVx(textureBrush, _polygon1);
            //-------------------------------------------------------------------------
            var linearGrBrush2 = new LinearGradientBrush(
                new PointF(0, 50), new PointF(0, 100),
                Color.Red, Color.White);

            //fill polygon with gradient brush
            _painter.FillColor = Color.Yellow;
            _painter.FillRect(200, 0, 150, 150);
            _painter.FillRenderVx(linearGrBrush2, _polygon2);
            _painter.FillColor = Color.Black;
            _painter.FillRect(400, 0, 150, 150);
            //-------------------------------------------------------------------------
            //another  ...
            _painter.FillRenderVx(linearGrBrush2, _polygon3);
            //-------------------------------------------------------------------------


            SwapBuffers();
        }
Exemplo n.º 5
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White);
            _pcx.ClearColorBuffer();
            //-------------------------------
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.png");
                _isInit = true;
            }
            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                    _pcx.AttachToRenderSurface(_surface1);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Red);
                    _pcx.DrawImageWithBlurX(_glbmp, 0, 0);
                    _pcx.AttachToRenderSurface(null);//switch to primary render surface
                    //------------------------------------------------------------------------------------
                    //framebuffer2

                    _pcx.AttachToRenderSurface(_surface2);
                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

                    //GLBitmap bmp2 = new GLBitmap(_frameBuffer.TextureId, _frameBuffer.Width, _frameBuffer.Height);
                    //bmp2.IsYFlipped = true;
                    //bmp2.IsBigEndianPixel = true;

                    _pcx.DrawImageWithBlurY(_surface1.GetGLBitmap(), 0, 0);
                    _pcx.AttachToRenderSurface(null);
                    //------------------------------------------------------------------------------------
                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                _pcx.DrawImage(_surface2.GetGLBitmap(), 0, 0);

                //_pcx.DrawFrameBuffer(_frameBuffer2, 0, 0, true);
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
Exemplo n.º 6
0
        protected override void OnGLPainterReady(GLPainter painter)
        {
            _pcx     = painter.Core;
            _painter = painter;
            _glBmp   = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
            _glBmp2  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\lion1_v2.png");

            _textureBrush  = new TextureBrush(_glBmp);
            _textureBrush2 = new TextureBrush(_glBmp2);

            _linearGradient = new LinearGradientBrush(
                new PointF(10, 50), new PointF(10, 100),
                Color.Red, Color.White);
        }
Exemplo n.º 7
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOrientation prevOrgKind = _pcx.OriginKind; //save
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    _pcx.AttachToRenderSurface(_surface1);

                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                    //------------------------------------------------------------------------------------
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Black);
                    _pcx.DrawImage(_glbmp, 5, 5);
                    //------------------------------------------------------------------------------------
                    _pcx.AttachToRenderSurface(null);
                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);

                for (int i = 0; i < 1; ++i)
                {
                    _pcx.DrawImage(_surface1.GetGLBitmap(), 100 + (i * 30), 200 + (i * 30));
                }
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            _pcx.OriginKind = prevOrgKind;//restore
        }
Exemplo n.º 8
0
        protected override void OnReadyForInitGLShaderProgram()
        {
            PaintLab.Svg.VgVisualDoc vgVisualDoc = PaintLab.Svg.VgVisualDocHelper.CreateVgVisualDocFromFile("Samples/lion.svg");
            _lionShape = new SpriteShape(vgVisualDoc.VgRootElem);

            var lionBounds = _lionShape.Bounds;

            //-------------
            _memBmp     = new MemBitmap((int)lionBounds.Width, (int)lionBounds.Height);
            _aggPainter = AggPainter.Create(_memBmp);


            DrawLion(_aggPainter, _lionShape);
            //convert affImage to texture
            _glBmp = DemoHelper.LoadTexture(_memBmp);
        }
        protected override void OnReadyForInitGLShaderProgram()
        {
            lionShape = new SpriteShape();
            lionShape.ParseLion();
            RectD lionBounds = lionShape.Bounds;

            //-------------
            aggImage   = new ActualImage((int)lionBounds.Width, (int)lionBounds.Height, PixelFarm.Agg.PixelFormat.ARGB32);
            _aggsx     = new AggRenderSurface(aggImage);
            aggPainter = new AggPainter(_aggsx);


            DrawLion(aggPainter, lionShape, lionShape.Vxs);
            //convert affImage to texture
            glBmp = DemoHelper.LoadTexture(aggImage);
        }
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _glsx.SmoothMode  = SmoothMode.Smooth;
     _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _glsx.Clear(PixelFarm.Drawing.Color.White);
     _glsx.ClearColorBuffer();
     //-------------------------------
     if (!isInit)
     {
         glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.png");
         isInit = true;
     }
     if (frameBuffer.FrameBufferId > 0)
     {
         if (frameBufferNeedUpdate)
         {
             //------------------------------------------------------------------------------------
             //framebuffer
             _glsx.AttachFrameBuffer(frameBuffer);
             //after make the frameBuffer current
             //then all drawing command will apply to frameBuffer
             //do draw to frame buffer here
             _glsx.Clear(PixelFarm.Drawing.Color.Red);
             _glsx.DrawImageWithBlurX(glbmp, 0, 300);
             _glsx.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //framebuffer2
             _glsx.AttachFrameBuffer(frameBuffer2);
             GLBitmap bmp2 = new GLBitmap(frameBuffer.TextureId, frameBuffer.Width, frameBuffer.Height);
             bmp2.IsBigEndianPixel = true;
             _glsx.DrawImageWithBlurY(bmp2, 0, 300);
             _glsx.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //after release current, we move back to default frame buffer again***
             frameBufferNeedUpdate = false;
         }
         _glsx.DrawFrameBuffer(frameBuffer2, 15, 300);
     }
     else
     {
         _glsx.Clear(PixelFarm.Drawing.Color.Blue);
     }
     //-------------------------------
     SwapBuffers();
 }
        protected override void OnReadyForInitGLShaderProgram()
        {
            var _svgRenderVx = PixelFarm.Agg.SvgRenderVxLoader.CreateSvgRenderVxFromFile("Samples/lion.svg");

            lionShape = new SpriteShape(_svgRenderVx);

            RectD lionBounds = lionShape.Bounds;

            //-------------
            aggImage   = new ActualImage((int)lionBounds.Width, (int)lionBounds.Height);
            _aggsx     = new AggRenderSurface(aggImage);
            aggPainter = new AggPainter(_aggsx);


            DrawLion(aggPainter, lionShape);
            //convert affImage to texture
            glBmp = DemoHelper.LoadTexture(aggImage);
        }
Exemplo n.º 12
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.ClearColorBuffer();
            if (!resInit)
            {
                //glbmp = LoadTexture(@"..\logo-dark.jpg");
                glbmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");

                resInit = true;
            }

            _glsx.DrawSubImage(glbmp, 10, 10, 100, 100, 200, 400);
            _glsx.DrawImage(glbmp, 0, 300);
            _glsx.DrawImageWithBlurX(glbmp, 0, 600);
            SwapBuffers();
        }
Exemplo n.º 13
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            if (!_resInit)
            {
                // msdf_bmp = LoadTexture(@"..\msdf_75.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1_66.png");
                _msdf_bmp = DemoHelper.LoadTexture(_totalBmp);
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\msdf_65.png");
                _resInit = true;
            }

            _painter.Clear(PixelFarm.Drawing.Color.White);
            //var f = painter.CurrentFont;

            //painter.DrawString("hello!", 0, 20);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 200, 500, 15f);

            Typography.Rendering.TextureGlyphMapData glyphData;

            byte[] codepoint = System.Text.Encoding.UTF8.GetBytes("AB");
            _fontAtlas.TryGetGlyphMapData(codepoint[0], out glyphData);
            PixelFarm.Drawing.Rectangle r =
                new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                glyphData.Top,
                                                glyphData.Width,
                                                glyphData.Height);
            //canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);
            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r, 100, 500);

            _fontAtlas.TryGetGlyphMapData(codepoint[1], out glyphData);
            PixelFarm.Drawing.Rectangle r2 = new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                                             glyphData.Top,
                                                                             glyphData.Width,
                                                                             glyphData.Height);
            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r2, 100 + r.Width - 10, 500);

            //full image
            _pcx.DrawImage(_msdf_bmp, 100, 300);
            SwapBuffers();
        }
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White);
            _pcx.ClearColorBuffer();
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\leaves.jpg");
                _isInit = true;
            }
            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _pcx.AttachToRenderSurface(_surface1);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Red);
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, 0, 0);
                    _pcx.AttachToRenderSurface(null);

                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);
                _pcx.DrawImage(_surface1.GetGLBitmap(), 0, 0);
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
Exemplo n.º 15
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.Clear(PixelFarm.Drawing.Color.White);
            _glsx.ClearColorBuffer();
            //-------------------------------
            if (!isInit)
            {
                glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\leaves.jpg");
                isInit = true;
            }
            if (frameBuffer.FrameBufferId > 0)
            {
                if (frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _glsx.AttachFrameBuffer(frameBuffer);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _glsx.Clear(PixelFarm.Drawing.Color.Red);
                    _glsx.DrawImageWithConv3x3(glbmp, Mat3x3ConvGen.emboss, 0, 300);
                    _glsx.DetachFrameBuffer();

                    //after release current, we move back to default frame buffer again***
                    frameBufferNeedUpdate = false;
                }
                _glsx.DrawFrameBuffer(frameBuffer, 15, 300);
            }
            else
            {
                _glsx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
Exemplo n.º 16
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOrientation prevOrgKind = _pcx.OriginKind; //save
            switch (DrawSet)
            {
            default:
            case T107_1_DrawImageSet.Full:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.Half:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToRect:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageToQuad(_glbmp,
                                         new PixelFarm.Drawing.PointF(i, i),
                                         new PixelFarm.Drawing.PointF(i + _glbmp.Width / 2, i),
                                         new PixelFarm.Drawing.PointF(i + _glbmp.Width / 2, i + _glbmp.Height / 2),
                                         new PixelFarm.Drawing.PointF(i, i + _glbmp.Height / 2));

                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageToQuad(_glbmp,
                                         new PixelFarm.Drawing.PointF(i, i),
                                         new PixelFarm.Drawing.PointF(i + _glbmp.Width / 2, i),
                                         new PixelFarm.Drawing.PointF(i + _glbmp.Width / 2, i + _glbmp.Height / 2),
                                         new PixelFarm.Drawing.PointF(i, i + _glbmp.Height / 2));

                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

                float rotateDegree = 20;

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    float[] quad = new float[]
                    {
                        0, 0,                        //left-top
                        _glbmp.Width, 0,             //right-top
                        _glbmp.Width, _glbmp.Height, //right-bottom
                        0, _glbmp.Height             //left bottom
                    };

                    PixelFarm.CpuBlit.VertexProcessing.Affine aff =
                        PixelFarm.CpuBlit.VertexProcessing.Affine.NewMatix2(
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.RotateDeg(rotateDegree),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2));


                    aff.Transform(ref quad[0], ref quad[1]);
                    aff.Transform(ref quad[2], ref quad[3]);
                    aff.Transform(ref quad[4], ref quad[5]);
                    aff.Transform(ref quad[6], ref quad[7]);


                    _pcx.DrawImageToQuad(_glbmp,
                                         new PixelFarm.Drawing.PointF(quad[0], quad[1]),
                                         new PixelFarm.Drawing.PointF(quad[2], quad[3]),
                                         new PixelFarm.Drawing.PointF(quad[4], quad[5]),
                                         new PixelFarm.Drawing.PointF(quad[6], quad[7]));

                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    float[] quad = new float[]
                    {
                        0, 0,                         //left-top
                        _glbmp.Width, 0,              //right-top
                        _glbmp.Width, -_glbmp.Height, //right-bottom
                        0, -_glbmp.Height             //left bottom
                    };

                    PixelFarm.CpuBlit.VertexProcessing.Affine aff =
                        PixelFarm.CpuBlit.VertexProcessing.Affine.NewMatix2(
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.RotateDeg(rotateDegree),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2));


                    aff.Transform(ref quad[0], ref quad[1]);
                    aff.Transform(ref quad[2], ref quad[3]);
                    aff.Transform(ref quad[4], ref quad[5]);
                    aff.Transform(ref quad[6], ref quad[7]);


                    _pcx.DrawImageToQuad(_glbmp,
                                         new PixelFarm.Drawing.PointF(quad[0], quad[1]),
                                         new PixelFarm.Drawing.PointF(quad[2], quad[3]),
                                         new PixelFarm.Drawing.PointF(quad[4], quad[5]),
                                         new PixelFarm.Drawing.PointF(quad[6], quad[7]));


                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

                float rotateDegree = 60;

                for (int i = 0; i < 400;)
                {
                    PixelFarm.CpuBlit.VertexProcessing.Affine aff =
                        PixelFarm.CpuBlit.VertexProcessing.Affine.NewMatix2(
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.RotateDeg(rotateDegree),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2));

                    _pcx.DrawImageToQuad(_glbmp, aff);


                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    PixelFarm.CpuBlit.VertexProcessing.Affine aff =
                        PixelFarm.CpuBlit.VertexProcessing.Affine.NewMatix2(
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.RotateDeg(rotateDegree),
                            PixelFarm.CpuBlit.VertexProcessing.AffinePlan.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2));

                    _pcx.DrawImageToQuad(_glbmp, aff);


                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages0:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImagesWithScale:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i, 2f);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);
                    _pcx.DrawSubImage(_glbmp, ref srcRect, i, i, 2f);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurX:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurY:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }

                //
            }
            break;

            case T107_1_DrawImageSet.DrawWithConv3x3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.sobelHorizontal, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, i, i);
                    i += 50;
                }
            }
            break;
            }
            _pcx.OriginKind = prevOrgKind;//restore
        }
Exemplo n.º 17
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save
            switch (DrawSet)
            {
            default:
            case T107_1_DrawImageSet.Full:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.Half:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToRect:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                Quad2f quad = new Quad2f();
                quad.SetCornersFromRect(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);        //half size

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    quad.Offset(50, 50);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                quad.SetCornersFromRect(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);        //half size
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageToQuad(_glbmp, quad);
                    quad.Offset(50, 50);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                float rotateDegree = 20;

                //float[] quad = new float[8];

                Quad2f quad = new Quad2f();

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    quad.SetCornersFromRect(0, 0, _glbmp.Width, _glbmp.Height);

                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    quad.Transform(aff);

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;


                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    quad.SetCornersFromRect(0, 0, _glbmp.Width, -_glbmp.Height);

                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    quad.Transform(aff);

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                float rotateDegree = 60;

                for (int i = 0; i < 400;)
                {
                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    _pcx.DrawImageToQuad(_glbmp, aff);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    _pcx.DrawImageToQuad(_glbmp, aff);


                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages0:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width, _glbmp.Height);
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImagesWithScale:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i, 2f);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i, 2f);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurX:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurY:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }

                //
            }
            break;

            case T107_1_DrawImageSet.DrawWithConv3x3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.sobelHorizontal, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, i, i);
                    i += 50;
                }
            }
            break;
            }
            _pcx.OriginKind = prevOrgKind;//restore
        }