public void DrawGlyphImageWithSubPixelRenderingTechnique(
     ref PixelFarm.Drawing.Rectangle srcRect,
     float targetLeft,
     float targetTop,
     float scale)
 {
     //TODO: review performance here ***
     //1. B , cyan result
     GL.ColorMask(false, false, true, false);
     textureSubPixRendering.SetCompo(0);
     textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
     //float subpixel_shift = 1 / 9f;
     //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft - subpixel_shift, targetTop); //TODO: review this option
     //---------------------------------------------------
     //2. G , magenta result
     GL.ColorMask(false, true, false, false);
     textureSubPixRendering.SetCompo(1);
     textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
     //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop); //TODO: review this option
     //1. R , yellow result
     textureSubPixRendering.SetCompo(2);
     GL.ColorMask(true, false, false, false);//
     textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
     //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft + subpixel_shift, targetTop); //TODO: review this option
     //enable all color component
     GL.ColorMask(true, true, true, true);
 }
Example #2
0
 public void DrawSubImage(GLBitmap bmp, ref PixelFarm.Drawing.Rectangle r, float targetLeft, float targetTop, float scale)
 {
     if (bmp.IsBigEndianPixel)
     {
         glesTextureShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
     else
     {
         gdiImgTextureShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
 }
 public void DrawGlyphImageWithSubPixelRenderingTechnique2(
     ref PixelFarm.Drawing.Rectangle srcRect,
     float targetLeft,
     float targetTop,
     float scale)
 {
     textureSubPixRendering.NewDrawSubImage(srcRect.Left,
                                            srcRect.Top,
                                            srcRect.Width,
                                            srcRect.Height, targetLeft, targetTop);
 }
Example #4
0
 public void DrawSubImageWithMsdf(GLBitmap bmp, ref PixelFarm.Drawing.Rectangle r, float targetLeft, float targetTop, float scale)
 {
     if (bmp.IsBigEndianPixel)
     {
         msdfShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop, scale);
     }
     else
     {
         msdfShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop, scale);
     }
 }
 public void DrawGlyphImageWithStecil(GLBitmap bmp, ref PixelFarm.Drawing.Rectangle r, float targetLeft, float targetTop, float scale)
 {
     glyphStencilShader.SetColor(this.FontFillColor);
     if (bmp.IsBigEndianPixel)
     {
         glyphStencilShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
     else
     {
         glyphStencilShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
 }
        void UpdateInvalidateAccumArea(PlatformWinBoxForm winform)
        {
            winform.GetLocalBoundsIncludeShadow(out int x, out int y, out int w, out int h);
            if (_hasInvalidateAreaAccum)
            {
                _winBoxAccumInvalidateArea = PixelFarm.Drawing.Rectangle.Union(
                    new PixelFarm.Drawing.Rectangle(x, y, w, h),
                    _winBoxAccumInvalidateArea);
            }
            else
            {
                _winBoxAccumInvalidateArea =
                    new PixelFarm.Drawing.Rectangle(x, y, w, h);

                _hasInvalidateAreaAccum = true;
            }
        }
Example #7
0
        void UpdateVertices()
        {
            float xmin = float.MaxValue;
            float ymin = float.MaxValue;
            float xmax = float.MinValue;
            float ymax = float.MinValue;

            {
                //update 4 corners
                //--------------------------
                xmin = Math.Min(xmin, _p0.X);
                xmax = Math.Max(xmax, _p0.X);
                ymin = Math.Min(ymin, _p0.Y);
                ymax = Math.Max(ymax, _p0.Y);
                //--------------------------
                xmin = Math.Min(xmin, _p1.X);
                xmax = Math.Max(xmax, _p1.X);
                ymin = Math.Min(ymin, _p1.Y);
                ymax = Math.Max(ymax, _p1.Y);
                //--------------------------
                xmin = Math.Min(xmin, _p2.X);
                xmax = Math.Max(xmax, _p2.X);
                ymin = Math.Min(ymin, _p2.Y);
                ymax = Math.Max(ymax, _p2.Y);
                //--------------------------
                xmin = Math.Min(xmin, _p3.X);
                xmax = Math.Max(xmax, _p3.X);
                ymin = Math.Min(ymin, _p3.Y);
                ymax = Math.Max(ymax, _p3.Y);
            }


            _destBounds = new Drawing.Rectangle((int)xmin, (int)ymin, (int)(xmax - xmin), (int)(ymax - ymin));
            _AB         = MyVectorHelper.NewFromTwoPoints(_p0, _p1);
            _BC         = MyVectorHelper.NewFromTwoPoints(_p1, _p2);
            _CD         = MyVectorHelper.NewFromTwoPoints(_p2, _p3);
            _DA         = MyVectorHelper.NewFromTwoPoints(_p3, _p0);
            //-----------------------------------------------------------------------
            // get unit vector
            _AB /= _AB.Magnitude;
            _BC /= _BC.Magnitude;
            _CD /= _CD.Magnitude;
            _DA /= _DA.Magnitude;
            //-----------------------------------------------------------------------
        }
Example #8
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();
        }
        public void DrawGlyphImageWithSubPixelRenderingTechnique(
            GLBitmap bmp,
            ref PixelFarm.Drawing.Rectangle srcRect,
            float targetLeft,
            float targetTop,
            float scale)
        {
            if (bmp.IsBigEndianPixel)
            {
                throw new NotSupportedException();
            }
            else
            {
                textureSubPixRendering.LoadGLBitmap(bmp);
                textureSubPixRendering.IsBigEndian = bmp.IsBigEndianPixel;
                textureSubPixRendering.SetColor(this.FontFillColor);
                textureSubPixRendering.SetIntensity(1f);
                //-------------------------
                //draw a serie of image***
                //-------------------------

                //TODO: review performance here ***

                //1. B , cyan result
                GL.ColorMask(false, false, true, false);
                textureSubPixRendering.SetCompo(0);
                textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
                //float subpixel_shift = 1 / 9f;
                //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft - subpixel_shift, targetTop); //TODO: review this option
                //---------------------------------------------------
                //2. G , magenta result
                GL.ColorMask(false, true, false, false);
                textureSubPixRendering.SetCompo(1);
                textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
                //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop); //TODO: review this option
                //1. R , yellow result
                textureSubPixRendering.SetCompo(2);
                GL.ColorMask(true, false, false, false);//
                textureSubPixRendering.DrawSubImage(srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);
                //textureSubPixRendering.DrawSubImage(r.Left, r.Top, r.Width, r.Height, targetLeft + subpixel_shift, targetTop); //TODO: review this option
                //enable all color component
                GL.ColorMask(true, true, true, true);
            }
        }
Example #10
0
        public void WriteVboToList(
            System.Collections.Generic.List <float> buffer,
            System.Collections.Generic.List <ushort> indexList,
            ref PixelFarm.Drawing.Rectangle srcRect,
            float targetLeft,
            float targetTop,
            float scale)
        {
            // https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesforWorkingwithVertexData/TechniquesforWorkingwithVertexData.html

            ushort indexCount = (ushort)indexList.Count;

            if (indexCount > 0)
            {
                //add degenerative triangle
                float prev_5 = buffer[buffer.Count - 5];
                float prev_4 = buffer[buffer.Count - 4];
                float prev_3 = buffer[buffer.Count - 3];
                float prev_2 = buffer[buffer.Count - 2];
                float prev_1 = buffer[buffer.Count - 1];

                buffer.Add(prev_5); buffer.Add(prev_4); buffer.Add(prev_3);
                buffer.Add(prev_2); buffer.Add(prev_1);


                indexList.Add((ushort)(indexCount));
                indexList.Add((ushort)(indexCount + 1));

                indexCount += 2;
            }

            //version 3
            textureSubPixRendering.WriteVboStream(buffer, indexCount > 0, srcRect.Left, srcRect.Top, srcRect.Width, srcRect.Height, targetLeft, targetTop);

            indexList.Add(indexCount);
            indexList.Add((ushort)(indexCount + 1));
            indexList.Add((ushort)(indexCount + 2));
            indexList.Add((ushort)(indexCount + 3));
            //---
            //add degenerate rect
        }
Example #11
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                // msdf_bmp = LoadTexture(@"..\msdf_75.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1_66.png");
                msdf_bmp = LoadTexture(totalImg);
                //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.TextureFontGlyphData glyphData;

            byte[] codepoint = System.Text.Encoding.UTF8.GetBytes("AB");
            fontAtlas.GetRectByCodePoint(codepoint[0], out glyphData);
            PixelFarm.Drawing.Rectangle r = ConvToRect(glyphData.Rect);
            //canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);

            fontAtlas.GetRectByCodePoint(codepoint[1], out glyphData);
            PixelFarm.Drawing.Rectangle r2 = ConvToRect(glyphData.Rect);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r2, 100 + r.Width - 10, 500);

            //full image
            canvas2d.DrawImage(msdf_bmp, 100, 300);
            miniGLControl.SwapBuffers();
        }
Example #12
0
        /// <summary>
        /// find bounds
        /// </summary>
        public PixelFarm.Drawing.Rectangle GetBounds(bool exactBoundsFromSpan = false)
        {
            if (_evalBounds)
            {
                return(_cacheBounds);
            }

            if (exactBoundsFromSpan || Outline == null)
            {
                //calculate all bounds from HSpans again
                _evalBounds = true;
                return(_cacheBounds = FindTotalRectBoundsFromHSpans());
            }
            //
            //find bounds...
            if (Outline != null)
            {
                //get bounds from raw-outline (near
            }
            else
            {
            }
            return(new Drawing.Rectangle());
        }
Example #13
0
 //------------------------------------------------
 public static SkiaSharp.SKRectI ToRect(this PixelFarm.Drawing.Rectangle rect)
 {
     return(SkiaSharp.SKRectI.Create(rect.X, rect.Y, rect.Width, rect.Height));
 }
 public static SKRect ConvToRect(PixelFarm.Drawing.Rectangle r)
 {
     return(new SKRect(r.X, r.Y, r.Right, r.Bottom));
 }
Example #15
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
        }
Example #16
0
 public static void Rect(ref PixelFarm.Drawing.Rectangle rect)
 {
     GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
 }
Example #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.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
        }
Example #18
0
 //------------------------------------------------
 public static System.Drawing.Rectangle ToRect(this PixelFarm.Drawing.Rectangle rect)
 {
     return(new System.Drawing.Rectangle(rect.X, rect.Y, rect.Width, rect.Height));
 }
 public void InitSetup2d(PixelFarm.Drawing.Rectangle rect)
 {
 }
 public void SetClipRect(PixelFarm.Drawing.Rectangle r)
 {
     SetClipRect(r.Left, r.Top, r.Width, r.Height);
 }