Esempio n. 1
0
 /// <summary> 清除整个绘图面并以指定背景色填充
 /// </summary>
 /// <param name="color">System.Drawing.Color 结构,它表示绘图面的背景色</param>
 public void Clear(Color color)
 {
     //this.DxRenderInfos.Clear();
     if (color == Color.Transparent)
     {
         this.target.RenderTarget.Clear(DxConvert.ToColor4(color));
         if (this.target is DUIWindowRenderTarget dUIWindowRenderTarget)
         {
             Control control = Control.FromHandle(dUIWindowRenderTarget.Handle);
             if (control != null)
             {
                 using (Graphics ownerGraphics = Graphics.FromHwnd(dUIWindowRenderTarget.Handle))
                     using (DUIImage image = new DUIImage(control.ClientSize.Width, control.ClientSize.Height))
                         using (Graphics targetGraphics = Graphics.FromImage(image))
                         {
                             IntPtr ownerDC  = ownerGraphics.GetHdc();
                             IntPtr targetDC = targetGraphics.GetHdc();
                             DirectUI.Win32.NativeMethods.BitBlt(targetDC, 0, 0, control.ClientSize.Width, control.ClientSize.Height, ownerDC, 0, 0, 13369376);
                             ownerGraphics.ReleaseHdc(ownerDC);
                             targetGraphics.ReleaseHdc(targetDC);
                             image.RenderTarget = this.target;
                             this.target.RenderTarget.DrawBitmap(image, DxConvert.ToRectF(0, 0, control.ClientSize.Width, control.ClientSize.Height), 1, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor, DxConvert.ToRectF(0, 0, image.Width, image.Height));
                         }
             }
         }
     }
     else
     {
         this.target.RenderTarget.Clear(DxConvert.ToColor4(color));
     }
 }
Esempio n. 2
0
 public void DrawImage(DUIImage image, PointF[] polygon, GraphicsUnit srcUnit, float opacity)
 {
     if (image == null || polygon.Length < 3)
     {
         return;
     }
     this.iDUIGraphics.DrawImage(image, polygon, srcUnit, opacity);
 }
Esempio n. 3
0
 public void DrawImage(DUIImage image, PointF[] destTriangle, PointF[] srcTriangle, GraphicsUnit srcUnit, float opacity)
 {
     if (image == null || destTriangle.Length != 3 || srcTriangle.Length != 3)
     {
         return;
     }
     this.iDUIGraphics.DrawImage(image, destTriangle, srcTriangle, srcUnit, opacity);
 }
Esempio n. 4
0
 public void DrawImage(DUIImage image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, float opacity)
 {
     if (image == null || destRect.Width == 0 || destRect.Height == 0 || srcRect.Width == 0 || srcRect.Height == 0)
     {
         return;
     }
     this.iDUIGraphics.DrawImage(image, destRect, srcRect, srcUnit, opacity);
 }
Esempio n. 5
0
        public void DrawImage(DUIImage image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, float opacity)
        {
            ColorMatrix     clrMatrix     = new ColorMatrix(new float[][] { new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, (float)opacity, 0 }, new float[] { 0, 0, 0, 0, 1 } });
            ImageAttributes imgAttributes = new ImageAttributes();

            imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);//设置图像的颜色属性
            this.graphics.DrawImage(image, Rectangle.Ceiling(destRect), srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, GraphicsUnit.Pixel, imgAttributes);
            //this.graphics.DrawImage(image, destRect, srcRect, GraphicsUnit.Pixel);
        }
Esempio n. 6
0
        public void DrawImage(DUIImage image, PointF[] polygon, GraphicsUnit srcUnit, float opacity)
        {
            ColorMatrix     clrMatrix     = new ColorMatrix(new float[][] { new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, (float)opacity, 0 }, new float[] { 0, 0, 0, 0, 1 } });
            ImageAttributes imgAttributes = new ImageAttributes();

            imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);//设置图像的颜色属性
            using (TextureBrush tb = new TextureBrush(image, new Rectangle(0, 0, image.Width, image.Height), imgAttributes))
            {
                tb.WrapMode = WrapMode.Clamp;
                this.graphics.FillPolygon(tb, polygon);
            }
        }
Esempio n. 7
0
 public void DrawImage(DUIImage image, PointF[] polygon, GraphicsUnit srcUnit, float opacity)
 {
     image.RenderTarget = this.target;
     using (DirectUI.Common.DUIBitmapBrush dbs = new DirectUI.Common.DUIBitmapBrush(image, DUIExtendMode.Clamp, opacity))
         using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
             using (SharpDX.Direct2D1.GeometrySink gs1 = pathGeometry.Open())
             {
                 dbs.RenderTarget = this.target;
                 gs1.SetFillMode(SharpDX.Direct2D1.FillMode.Alternate);
                 gs1.BeginFigure(DxConvert.ToVector2(polygon[0]), SharpDX.Direct2D1.FigureBegin.Filled);
                 for (int i = 1; i < polygon.Length; i++)
                 {
                     gs1.AddLine(DxConvert.ToVector2(polygon[i]));
                 }
                 gs1.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                 gs1.Close();
                 this.target.RenderTarget.FillGeometry(pathGeometry, dbs);
             }
 }
Esempio n. 8
0
        public void DrawImage(DUIImage image, PointF[] destTriangle, PointF[] srcTriangle, GraphicsUnit srcUnit, float opacity)
        {
            PointF t1 = destTriangle[0];
            PointF t2 = destTriangle[1];
            PointF t3 = destTriangle[2];

            image.RenderTarget = this.target;
            using (DirectUI.Common.DUIBitmapBrush dbs = new DirectUI.Common.DUIBitmapBrush(image, DUIExtendMode.Clamp, opacity))
                using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
                    using (SharpDX.Direct2D1.GeometrySink gs1 = pathGeometry.Open())
                    {
                        dbs.RenderTarget = this.target;
                        gs1.SetFillMode(SharpDX.Direct2D1.FillMode.Alternate);
                        gs1.BeginFigure(DxConvert.ToVector2(t1), SharpDX.Direct2D1.FigureBegin.Filled);
                        gs1.AddLine(DxConvert.ToVector2(t2));
                        gs1.AddLine(DxConvert.ToVector2(t3));
                        gs1.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                        gs1.Close();
                        dbs.Transform = MatrixTools.ThreePointsAffine(srcTriangle, destTriangle);
                        this.target.RenderTarget.FillGeometry(pathGeometry, dbs);
                    }
        }
Esempio n. 9
0
 public void DrawImage(DUIImage image, float x, float y)
 {
     this.DrawImage(image, x, y, 1);
 }
Esempio n. 10
0
 public void DrawImage(DUIImage image, PointF point)
 {
     this.DrawImage(image, point.X, point.Y);
 }
Esempio n. 11
0
 public void DrawImage(DUIImage image, PointF point, float opacity)
 {
     this.DrawImage(image, point.X, point.Y, opacity);
 }
Esempio n. 12
0
 public void DrawImage(DUIImage image, Point[] polygon, GraphicsUnit srcUnit, float opacity)
 {
     this.DrawImage(image, polygon.Select(p => (PointF)p).ToArray(), srcUnit, opacity);
 }
Esempio n. 13
0
 public void DrawImage(DUIImage image, Point[] polygon, float opacity)
 {
     this.DrawImage(image, polygon, GraphicsUnit.Pixel, opacity);
 }
Esempio n. 14
0
 public void DrawImage(DUIImage image, Point[] polygon)
 {
     this.DrawImage(image, polygon, GraphicsUnit.Pixel, 1);
 }
Esempio n. 15
0
 public void DrawImage(DUIImage image, RectangleF rect)
 {
     this.DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
 }
Esempio n. 16
0
 public void DrawImage(DUIImage image, PointF[] destTriangle, PointF[] srcTriangle)
 {
     this.DrawImage(image, destTriangle, srcTriangle, GraphicsUnit.Pixel, 1);
 }
Esempio n. 17
0
 public DUIBitmapBrush(Image image, DUIExtendMode dUIExtendMode = DUIExtendMode.Wrap, float opacity = 1F)
     : this(DUIImage.FromImage(image), dUIExtendMode, opacity)
 {
 }
Esempio n. 18
0
 public void DrawImage(DUIImage image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, float opacity)
 {
     this.DrawImage(image, (RectangleF)destRect, (RectangleF)srcRect, srcUnit, opacity);
 }
Esempio n. 19
0
 public void DrawImage(DUIImage image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
 {
     this.DrawImage(image, destRect, srcRect, srcUnit, 1);
 }
Esempio n. 20
0
 public void DrawImage(DUIImage image, RectangleF rect, float opacity)
 {
     this.DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height, opacity);
 }
Esempio n. 21
0
 public void DrawImage(DUIImage image, int x, int y, float opacity)
 {
     this.DrawImage(image, (float)x, (float)y, opacity);
 }
Esempio n. 22
0
 public void DrawImage(DUIImage image, int x, int y, int width, int height, float opacity)
 {
     this.DrawImage(image, (float)x, (float)y, (float)width, (float)height, opacity);
 }
Esempio n. 23
0
 public void DrawImage(DUIImage image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, float opacity)
 {
     image.RenderTarget = this.target;
     this.target.RenderTarget.DrawBitmap(image, DxConvert.ToRectF(destRect), opacity, SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor, DxConvert.ToRectF(srcRect));
 }
Esempio n. 24
0
 public void DrawImage(DUIImage image, float x, float y, float width, float height, float opacity)
 {
     this.DrawImage(image, new RectangleF(x, y, width, height), new RectangleF(0, 0, image.Width, image.Height), GraphicsUnit.Pixel, opacity);
 }
Esempio n. 25
0
 public void DrawImage(DUIImage image, Point[] destTriangle, Point[] srcTriangle, GraphicsUnit srcUnit, float opacity)
 {
     this.DrawImage(image, destTriangle.Select(p => (PointF)p).ToArray(), srcTriangle.Select(p => (PointF)p).ToArray(), srcUnit, opacity);
 }
Esempio n. 26
0
 public DUIBitmapBrush(DUIImage image, DUIExtendMode dUIExtendMode = DUIExtendMode.Wrap, float opacity = 1F)
 {
     this.image         = image;
     this.dUIExtendMode = dUIExtendMode;
     this.opacity       = opacity;
 }