當前位置: 首頁>>代碼示例>>C#>>正文


C# Drawing.TextureBrush類代碼示例

本文整理匯總了C#中System.Drawing.TextureBrush的典型用法代碼示例。如果您正苦於以下問題:C# TextureBrush類的具體用法?C# TextureBrush怎麽用?C# TextureBrush使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextureBrush類屬於System.Drawing命名空間,在下文中一共展示了TextureBrush類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Bumper

        public Bumper()
        {
            InitializeComponent();
            Kontroli = Resources.kontrolii;
            flag = false;
            zvukON = Resources.soundON;
            zvukOFF = Resources.soundOFF;
            CarsDoc = new CarsDoc();
            LentiDoc = new LentiDoc();
            DupkiDoc = new DupkiDoc();
            generirajKola = 0;
            poeni = 0;
            level = 1;
            sekundi = 0;
            //asvalt
            img = Properties.Resources.Road2;
            biImg = new Bitmap(img);
            tba = new TextureBrush(biImg);
            clicked = true;

            sounds = new Sounds();

            DoubleBuffered = true;
            random = new Random();
            zgolemiLvl = false;
            bestScore = 0;
            eksplozija = Properties.Resources.explosion_;
            TextReader tr = new StreamReader("highscores.txt");
            lbHighScore.Text = tr.ReadLine() + "pts";
        }
開發者ID:sanjatas,項目名稱:Bumper,代碼行數:30,代碼來源:Form1.cs

示例2: BrushesExampleMethod

        public static void BrushesExampleMethod(Graphics g)
        {
            Color pink = Color.FromArgb(241, 105, 190);
            SolidBrush sldBrush = new SolidBrush(pink);
            g.FillRectangle(sldBrush, 300, 150, 70, 70);

            HatchBrush hBrush = new HatchBrush(HatchStyle.NarrowVertical, Color.Pink, Color.Blue);
            g.FillRectangle(hBrush, 370, 150, 70, 70);

            sldBrush = new SolidBrush(Color.Orchid);
            g.FillRectangle(sldBrush, 440, 150, 70, 70);

            LinearGradientBrush lgBrush = new LinearGradientBrush(new Rectangle(0, 0, 20, 20), Color.Violet, Color.LightSteelBlue, LinearGradientMode.Vertical);
            g.FillRectangle(lgBrush, 300, 220, 70, 70);

            g.FillRectangle(Brushes.Indigo, 370, 220, 70, 70);

            sldBrush = new SolidBrush(Color.Orange);
            g.FillRectangle(sldBrush, 440, 220, 70, 70);

            lgBrush = new LinearGradientBrush(new RectangleF(0, 0, 90, 90), Color.BlueViolet, Color.LightPink, LinearGradientMode.BackwardDiagonal);

            g.FillRectangle(lgBrush, 300, 290, 70, 70);

            TextureBrush tBrush = new TextureBrush(Image.FromFile(@"Images\csharp.jpg"));
            g.FillRectangle(tBrush, 370, 290, 70, 70);

            tBrush = new TextureBrush(Image.FromFile(@"Images\003.jpg"));
            g.FillRectangle(tBrush, 440, 290, 70, 70);
        }
開發者ID:xs2ranjeet,項目名稱:13ns9-1spr,代碼行數:30,代碼來源:Cub.cs

示例3: DrawBackgroundImage

 public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (backgroundImageLayout == ImageLayout.Tile)
     {
         using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
         {
             if (scrollOffset != Point.Empty)
             {
                 Matrix transform = brush.Transform;
                 transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
                 brush.Transform = transform;
             }
             g.FillRectangle(brush, clipRect);
             return;
         }
     }
     Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
     if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
     {
         rect.X += clipRect.Width - rect.Width;
     }
     using (SolidBrush brush2 = new SolidBrush(backColor))
     {
         g.FillRectangle(brush2, clipRect);
     }
     if (!clipRect.Contains(rect))
     {
         if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
         {
             rect.Intersect(clipRect);
             g.DrawImage(backgroundImage, rect);
         }
         else if (backgroundImageLayout == ImageLayout.None)
         {
             rect.Offset(clipRect.Location);
             Rectangle destRect = rect;
             destRect.Intersect(clipRect);
             Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
             g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
         }
         else
         {
             Rectangle rectangle4 = rect;
             rectangle4.Intersect(clipRect);
             Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
             g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
         }
     }
     else
     {
         ImageAttributes imageAttr = new ImageAttributes();
         imageAttr.SetWrapMode(WrapMode.TileFlipXY);
         g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
         imageAttr.Dispose();
     }
 }
開發者ID:zhushengwen,項目名稱:example-zhushengwen,代碼行數:60,代碼來源:CmbControlPaintEx.cs

示例4: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            //利用位圖作為紋理創建紋理畫刷
            TextureBrush textureBrush1 = new TextureBrush(Properties.Resources.test);
            G.FillRectangle(textureBrush1, 40, 0, 40, 120);
            G.FillRectangle(textureBrush1, 0, 40, 120, 40);
            //利用位置的指定區域作為紋理創建紋理畫刷
            TextureBrush textureBrush2 = new TextureBrush(Properties.Resources.test, new Rectangle(10, 10, 28, 28));
            G.FillRectangle(textureBrush2, 180, 0, 40, 120);
            G.FillRectangle(textureBrush2, 140, 40, 120, 40);
            TextureBrush textureBrush3 = new TextureBrush(Properties.Resources.test, new Rectangle(10, 10, 28, 28));
            textureBrush3.WrapMode = WrapMode.TileFlipXY;           //設置紋理圖像的漸變方式
            G.FillRectangle(textureBrush3, 30, 140, 60, 120);
            G.FillRectangle(textureBrush3, 0, 170, 120, 60);
            float[][] newColorMatrix = new float[][]{               //顏色變換矩形
            new float[]{0.2f,0,0,0,0},                          //紅色分量
            new float[]{0,0.6f,0,0,0},                          //綠色分量
            new float[]{0,0,0.2f,0,0},                          //藍色分量
            new float[]{0,0,0,0.5f,0},                          //透明度分量
            new float[]{0,0,0,0,1}};                            //始終為1
            ColorMatrix colorMatrix = new ColorMatrix(newColorMatrix);
            ImageAttributes imageAttributes = new ImageAttributes();
            imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            TextureBrush textureBrush4 = new TextureBrush(Properties.Resources.test, new Rectangle(0, 0, 48, 48), imageAttributes);
            textureBrush4.WrapMode = WrapMode.TileFlipXY;
            G.FillRectangle(textureBrush4, 170, 140, 60, 120);
            G.FillRectangle(textureBrush4, 140, 170, 120, 60);
            textureBrush1.Dispose();                                //釋放畫刷
            textureBrush2.Dispose();                                //釋放畫刷
            textureBrush3.Dispose();                                //釋放畫刷
            textureBrush4.Dispose();                                //釋放畫刷
        }
開發者ID:dalinhuang,項目名稱:wdeqawes-efrwserd-rgtedrtf,代碼行數:35,代碼來源:FormTextureBrush.cs

示例5: OnHtmlLabelHostingPanelPaint

 private void OnHtmlLabelHostingPanelPaint(object sender, PaintEventArgs e)
 {
     using (var b = new TextureBrush(_background, WrapMode.Tile))
     {
         e.Graphics.FillRectangle(b, _htmlLabelHostingPanel.ClientRectangle);
     }
 }
開發者ID:CapitalCoder,項目名稱:HTML-Renderer,代碼行數:7,代碼來源:SampleForm.cs

示例6: cropAtRect

        public static Bitmap cropAtRect(Bitmap bi, int size)
        {
            Bitmap btm = new Bitmap(bi.Width + 4, bi.Height + 4);
            Bitmap btm2 = new Bitmap(size + 5, size + 5);

            using (Graphics grf = Graphics.FromImage(bi))
            {
                using (Brush brsh = new SolidBrush(Color.FromArgb(120, 0, 0, 0)))
                {
                    grf.FillRectangle(brsh, new System.Drawing.Rectangle(0, 0, bi.Width, bi.Height));
                }
            }
            using (Graphics grf = Graphics.FromImage(btm))
            {
                using (Brush brsh = new SolidBrush(Color.Red))
                {
                    grf.FillEllipse(brsh, 2, 2, bi.Width - 4, bi.Height - 4);
                }
                using (Brush brsh = new TextureBrush(bi))
                {

                    grf.FillEllipse(brsh, 6, 6, bi.Width - 12, bi.Height - 12);
                }
            }
            using (Graphics grf = Graphics.FromImage(btm2))
            {
                grf.InterpolationMode = InterpolationMode.High;
                grf.CompositingQuality = CompositingQuality.HighQuality;
                grf.SmoothingMode = SmoothingMode.AntiAlias;
                grf.DrawImage(btm, new System.Drawing.Rectangle(0, 0, size, size));
            }

            return btm2;
        }
開發者ID:KoalaHuman,項目名稱:EloBuddy-2,代碼行數:34,代碼來源:Util.cs

示例7: MainForm

        public MainForm()
        {
            InitializeComponent();

            this.currentFileData = new GameData(32, 32);
            this.currentFileName = null;

            this.toolImages = new TextureBrush[7];

            for (int i = 0; i < this.toolImages.Length; i++)
            {
                this.toolImages[i] = new TextureBrush(Image.FromFile("images/" + i + ".png"));
            }

            this.backgroundImage = new TextureBrush(Image.FromFile("images/checkerboard.png"));

            this.selectedTool = 1;

            this.graphicsContext = BufferedGraphicsManager.Current;
            this.graphics = graphicsContext.Allocate(this.StageEditBoard.CreateGraphics(),
                new Rectangle(0, 0, 32 * (int)EDIT_BOARD_SCALING, 32 * (int)EDIT_BOARD_SCALING));

            for(int i = 0; i < MainForm.DIRECTIONS.Length; i++)
                this.StartDirection.Items.Add(DIRECTIONS[i]);

            this.LoadTextureFiles();

            this.FileNew(null, null);
        }
開發者ID:erbuka,項目名稱:andrea,代碼行數:29,代碼來源:MainForm.cs

示例8: GetCircleBitmap

        public Image GetCircleBitmap(Size size, Color col)
        {
            Bitmap bmp2 = new Bitmap(size.Width, size.Height);

            using (Bitmap bmp = new Bitmap(size.Width, size.Height))
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.Clear(col);
                }

                using (TextureBrush t = new TextureBrush(bmp))
                {
                    using (Graphics g = Graphics.FromImage(bmp2))
                    {
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                        g.FillEllipse(t, 0, 0, bmp2.Width, bmp2.Height);
                    }
                }
            }

            return bmp2;
        }
開發者ID:rahulbishnoi,項目名稱:LabM,代碼行數:25,代碼來源:ColorHelper.cs

示例9: CopyIrregularAreaFromBitmap

        //Other methods to copy, color fill or filter found objects
        public Bitmap CopyIrregularAreaFromBitmap(Bitmap source, List<Point> points, Color bg_color)
        {
            Bitmap copiedImg = new Bitmap(source);
            using (Graphics gr = Graphics.FromImage(copiedImg))
            {
                // Set the background color.
                gr.Clear(bg_color);

                // Make a brush out of the original image.
                using (Brush br = new TextureBrush(source))
                {
                    // Fill the selected area with the brush.
                    gr.FillPolygon(br, points.ToArray());

                    // Find the bounds of the selected area.
                    Rectangle source_rect = GetPointListBounds(points);

                    // Make a bitmap that only holds the selected area.
                    Bitmap result = new Bitmap(
                        source_rect.Width, source_rect.Height);

                    // Copy the selected area to the result bitmap.
                    using (Graphics result_gr = Graphics.FromImage(result))
                    {
                        Rectangle dest_rect = new Rectangle(0, 0,
                            source_rect.Width, source_rect.Height);
                        result_gr.DrawImage(copiedImg, dest_rect,
                            source_rect, GraphicsUnit.Pixel);
                    }

                    // Return the result.
                    return result;
                }
            }
        }
開發者ID:AndriiGro,項目名稱:imageRecognitionDiploma,代碼行數:36,代碼來源:Form1.cs

示例10: GetBrush

 public TextureBrush GetBrush(Matrix matrix)
 {
     Bitmap bmp;
     if (_context2D != null)
     {
         bmp = _context2D.GetBitmap();
     }
     else
     {
         bmp = new Bitmap(_imagePath);
     }
     WrapMode wm = WrapMode.Tile;
     switch (_repetition)
     {
         case "repeat":
             wm = WrapMode.Tile;
             break;
         case "no-repeat":
             wm = WrapMode.Clamp;
             break;
         case "repeat-x":
             wm = WrapMode.TileFlipX;
             break;
         case "repeat-y":
             wm = WrapMode.TileFlipY;
             break;
     }
     var brush = new TextureBrush(bmp, wm);
     brush.MultiplyTransform(matrix);
     return brush;
 }
開發者ID:podlipensky,項目名稱:sharpcanvas,代碼行數:31,代碼來源:CanvasPattern.cs

示例11: Create

      public Image Create( string text )
      {
         var bitmap = (Bitmap) Image.FromFile( "Stone08Small.png" );

         using ( var g = Graphics.FromImage( bitmap ) )
         {
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

            using ( var textureBitmap = Image.FromFile( "Stone11Small.png" ) )
            {
               var textureBrush = new TextureBrush( textureBitmap );

               using ( var font = new Font( "Book Antiqua", 84 ) )
               {
                  var textSize = g.MeasureString( text, font );

                  float x = ( _decalSize - textSize.Width ) / 2;
                  float y = ( _decalSize - textSize.Height ) / 2;

                  g.DrawString( text, font, textureBrush, x, y );
               }
            }
         }

         return bitmap;
      }
開發者ID:alexwnovak,項目名稱:TF2Maps,代碼行數:27,代碼來源:DecalGenerator.cs

示例12: draw

        public override void draw(Graphics g)
        {
            TextureBrush texture = new TextureBrush(image1);
            texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;

            g.FillEllipse(texture, Rectangle.Round(base.loc));
        }
開發者ID:K-4U,項目名稱:ese_project4y5,代碼行數:7,代碼來源:drawTable.cs

示例13: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {

            LinearGradientBrush linearBrush = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Yellow, Color.Yellow, LinearGradientMode.ForwardDiagonal);
            graphicsObject(e).FillEllipse(linearBrush, this.Width / 4, 10, 300, 300);

            LinearGradientBrush linearBrush2 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Black, Color.Black, LinearGradientMode.Horizontal);
            graphicsObject(e).FillEllipse(linearBrush2, 190, 60, 100, 100);

            LinearGradientBrush linearBrush3 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Black, Color.Black, LinearGradientMode.BackwardDiagonal);
            graphicsObject(e).FillEllipse(linearBrush3, 330, 60, 100, 100);

            LinearGradientBrush linearBrush4 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Yellow, Color.Yellow, LinearGradientMode.BackwardDiagonal);
            graphicsObject(e).FillEllipse(linearBrush4, 460, 400, 100, 100);

            Bitmap textureBitmap = new Bitmap(10, 10);
            Graphics graphicsObject2 = Graphics.FromImage(textureBitmap);

            SolidBrush solidColorBrush = new SolidBrush(Color.Red);
            Pen coloredPen = new Pen(solidColorBrush);

            TextureBrush texturedBrush = new TextureBrush(textureBitmap);
            graphicsObject(e).FillRectangle(texturedBrush, 155, 30, 75, 100);

            coloredPen.Color = Color.Black;
            coloredPen.Width = 6;
            graphicsObject(e).DrawPie(coloredPen, 205, 220, 205, 10, 100, 100);
        }
開發者ID:michael1995,項目名稱:C-Sharp-Projects,代碼行數:28,代碼來源:Form1.cs

示例14: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     using (var brush = new TextureBrush(gradient, WrapMode.TileFlipX))
     {
         e.Graphics.FillRectangle(brush, 0, 0, Width, gradient.Height);
     }
 }
開發者ID:nitrocaster,項目名稱:ListPlayers,代碼行數:8,代碼來源:HorizontalPanel.cs

示例15: Form1_Paint

 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     Image I = Image.FromFile("클로버.jpg");
     TextureBrush B = new TextureBrush(I);
     //TextureBrush B = new TextureBrush(I, WrapMode.TileFlipX);
     //TextureBrush B = new TextureBrush(I, WrapMode.TileFlipY);
     e.Graphics.FillRectangle(B, ClientRectangle);
 }
開發者ID:gawallsibya,項目名稱:BIT_MFC-CShap-DotNet,代碼行數:8,代碼來源:Form1.cs


注:本文中的System.Drawing.TextureBrush類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。