コード例 #1
0
ファイル: Util.cs プロジェクト: KoalaHuman/EloBuddy-2
        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;
        }
コード例 #2
0
ファイル: DecalGenerator.cs プロジェクト: alexwnovak/TF2Maps
      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;
      }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: erbuka/andrea
        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);
        }
コード例 #5
0
ファイル: Cub.cs プロジェクト: xs2ranjeet/13ns9-1spr
        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);
        }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
        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();                                //释放画刷
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: sanjatas/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";
        }
コード例 #9
0
        /// <summary>
        /// Creates a new StatusBarProgressPanel
        /// </summary>
        public StatusBarProgressPanel()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _drawEventRegistered = false;

            _animationStyle = ProgressDisplayStyle.Infinite;

            _currentPosition = 0;
            _stepSize        = 10;
            _startPoint      = 0;
            _endPoint        = 100;

            _showText  = true;
            _textFont  = new Font("Arial", 8);
            _textBrush = SystemBrushes.ControlText;

            //_progressBrush = SystemBrushes.Highlight;
            //_progressBrush =  new System.Drawing.Drawing2D.LinearGradientBrush(
            //	new Rectangle(new Point(0,0), new Size(20, 10)), Color.Red, Color.Yellow, LinearGradientMode.Vertical);
            //System.IO.Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Prometheus.bomb.png");
            System.IO.Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Prometheus.progress_bar.gif");
            Image            img         = new Bitmap(imageStream);

            _progressBrush = new System.Drawing.TextureBrush(img);
            _increasing    = true;

            _animationTick = TimeSpan.FromSeconds(0.5);
            InitializeAnimationThread();

            _refreshDelegate = new RefreshDelegate(this.Refresh);
        }
コード例 #10
0
ファイル: drawTable.cs プロジェクト: K-4U/ese_project4y5
        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));
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: michael1995/C-Sharp-Projects
        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);
        }
コード例 #12
0
ファイル: ColorHelper.cs プロジェクト: rahulbishnoi/LabM
        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;
        }
コード例 #13
0
        //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;
                }
            }
        }
コード例 #14
0
 private void OnHtmlLabelHostingPanelPaint(object sender, PaintEventArgs e)
 {
     using (var b = new TextureBrush(_background, WrapMode.Tile))
     {
         e.Graphics.FillRectangle(b, _htmlLabelHostingPanel.ClientRectangle);
     }
 }
コード例 #15
0
 public EdgeDisplay(LedEdge edge, LedSubarea pSub)
 {
     this.ledEdge       = edge;
     this.ledSub        = pSub;
     this.subSize       = pSub.Size;
     this.circular      = (this.subSize.Width + this.subSize.Height) * 2;
     this.circularCount = 0m;
     lock (LedGlobal.LedEdgeList[edge.Index])
     {
         if (this.ledEdge.Enabled)
         {
             this.AlphaBitmap = new System.Drawing.Bitmap((this.subSize.Width + this.subSize.Height) * 2, edge.Height);
             this.EdgeBitmap  = new System.Drawing.Bitmap((this.subSize.Width + this.subSize.Height) * 2, edge.Height);
             System.Drawing.Graphics     graphics = System.Drawing.Graphics.FromImage(this.EdgeBitmap);
             System.Drawing.TextureBrush brush    = new System.Drawing.TextureBrush(LedGlobal.LedEdgeList[edge.Index]);
             graphics.FillRectangle(brush, new System.Drawing.Rectangle(0, 0, this.EdgeBitmap.Width, this.EdgeBitmap.Height));
             if (this.ledEdge.Mode != LedEdgeMode.Clockwise && this.ledEdge.Mode == LedEdgeMode.CounterClockwise)
             {
                 this.EdgeBitmap = this.SetCornerAlpha(this.EdgeBitmap);
             }
             this.StaticBitmap = new System.Drawing.Bitmap(this.subSize.Width, this.subSize.Height);
             System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(this.StaticBitmap);
             graphics2.DrawImage(this.EdgeBitmap, new System.Drawing.Point(0, 0));
             graphics2.TranslateTransform(0f, 0f);
             graphics2.RotateTransform(90f);
             graphics2.DrawImage(this.EdgeBitmap, new System.Drawing.Rectangle(0, -this.subSize.Width, this.subSize.Height, this.ledEdge.Height), new System.Drawing.Rectangle(this.subSize.Width, -1, this.subSize.Height, this.ledEdge.Height), System.Drawing.GraphicsUnit.Pixel);
             graphics2.DrawImage(this.EdgeBitmap, new System.Drawing.Rectangle(0, -this.subSize.Width, this.subSize.Height, this.ledEdge.Height), new System.Drawing.Rectangle(this.subSize.Width, 0, this.subSize.Height, this.ledEdge.Height), System.Drawing.GraphicsUnit.Pixel);
             graphics2.RotateTransform(90f);
             graphics2.DrawImage(this.EdgeBitmap, new System.Drawing.Rectangle(-this.subSize.Width, -this.subSize.Height, this.subSize.Width, this.ledEdge.Height), new System.Drawing.Rectangle(this.subSize.Width + this.subSize.Height, -1, this.subSize.Width, this.ledEdge.Height), System.Drawing.GraphicsUnit.Pixel);
             graphics2.RotateTransform(90f);
             graphics2.DrawImage(this.EdgeBitmap, new System.Drawing.Rectangle(-this.subSize.Height, 0, this.subSize.Height, this.ledEdge.Height), new System.Drawing.Rectangle(this.subSize.Width * 2 + this.subSize.Height, 0, this.subSize.Height, this.ledEdge.Height), System.Drawing.GraphicsUnit.Pixel);
         }
     }
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     Image I = Image.FromFile("인형.jpg");
     TextureBrush B = new TextureBrush(I);
     B.Transform = new Matrix(1, 0, 0, 1, 50, 50);
     e.Graphics.FillRectangle(B, 50, 50,
         ClientRectangle.Right, ClientRectangle.Bottom);
 }
コード例 #18
0
ファイル: texture.cs プロジェクト: nlhepler/mono
		public TextureForm (string[] args)
		{
			filename = args.Length > 0 ? args [1] : String.Empty;

			InitializeComponent ();

			tb = new TextureBrush (pictureBox1.Image);
		}
コード例 #19
0
ファイル: Tile.cs プロジェクト: CHK36/GovHack
        public void drawTile(Graphics paper, int x, int y, int width, int height)
        {
            paper.DrawRectangle(new Pen(Color.Black), x, y, width, height);

            TextureBrush b1 = new TextureBrush(image);

            paper.FillRectangle(b1, x, y, width, height);
        }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
 public static void DrawTiled(this Graphics g, int x, int y, int width, int height, Image image)
 {
     var r = new Rectangle(x, y, width, height);
     using (var b = new TextureBrush(image))
     {
         g.FillRectangle(b, r);
     }
 }
コード例 #22
0
        public static void GeneratePattern()
        {
            Bitmap bmpPattern = new Bitmap(20,20, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Graphics g = Graphics.FromImage(bmpPattern);
            g.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 255)), 0, 0, bmpPattern.Width / 2, bmpPattern.Height / 2);
            g.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 255)), bmpPattern.Width / 2, bmpPattern.Height / 2, bmpPattern.Width / 2, bmpPattern.Height / 2);

            _texture = new TextureBrush(bmpPattern);
        }
コード例 #23
0
ファイル: GdiPatternFill.cs プロジェクト: udayanroy/SvgSharp
        public override Brush GetBrush(RectangleF bounds)
        {
            Image image = GetImage(bounds);
            RectangleF destRect = GetDestRect(bounds);

            TextureBrush tb = new TextureBrush(image, destRect);
            tb.Transform = GetTransformMatrix(bounds);
            return tb;
        }
コード例 #24
0
ファイル: RgbaColorSlider.cs プロジェクト: jmcadams/vplus
 public RgbaColorSlider()
 {
     _cellBackground = new Bitmap(Resources.cellbackground);
     _cellBackgroundBrush = new TextureBrush(_cellBackground, WrapMode.Tile);
     //BarStyle = ColorBarStyle.Custom;
     Maximum = 255;
     Color = Color.Black;
     CreateScale();
 }
コード例 #25
0
        /// <summary>
        /// Acts as a drawing delegate for DrawObjectWithTransform
        /// After performing the necessary transformation (translate/rotate)
        /// DrawObjectWithTransform will invoke this method and draw a wall
        /// </summary>
        /// <param name="o">The object to draw</param>
        /// <param name="e">The PaintEventArgs to access the graphics</param>
        private void WallDrawer(object o, PaintEventArgs e)
        {
            Wall w = o as Wall;

            using (System.Drawing.TextureBrush wallBrush = new System.Drawing.TextureBrush(wall)) {
                Rectangle rect = new Rectangle(-(Constants.WALLWIDTH / 2), -(Constants.WALLWIDTH / 2), (int)(Math.Abs(w.firstPoint.GetX() - w.secondPoint.GetX()) + 50), (int)(Math.Abs(w.firstPoint.GetY() - w.secondPoint.GetY()) + 50));
                e.Graphics.FillRectangle(wallBrush, rect);
            }
        }
コード例 #26
0
 public RgbaColorSlider()
 {
   _cellBackground = new Bitmap(this.GetType().Assembly.GetManifestResourceStream(string.Concat(this.GetType().Namespace, ".Resources.cellbackground.png")));
   _cellBackgroundBrush = new TextureBrush(_cellBackground, WrapMode.Tile);
   this.BarStyle = ColorBarStyle.Custom;
   this.Maximum = 255;
   this.Color = Color.Black;
   this.CreateScale();
 }
コード例 #27
0
ファイル: TextureBrushTest.cs プロジェクト: nlhepler/mono
		private void Common (TextureBrush t, WrapMode wm)
		{
			using (Image img = t.Image) {
				Assert.IsNotNull (img, "Image");
			}
			Assert.IsFalse (Object.ReferenceEquals (image, t.Image), "Image-Equals");
			Assert.IsTrue (t.Transform.IsIdentity, "Transform.IsIdentity");
			Assert.AreEqual (wm, t.WrapMode, "WrapMode");
		}
コード例 #28
0
ファイル: Cub.cs プロジェクト: xs2ranjeet/13ns9-1spr
        public static void Draw(Graphics g)
        {
            Point[] p = { new Point(240, 110), new Point(440, 110), new Point(510, 150), new Point(300, 150) };
            TextureBrush tBrush = new TextureBrush(Image.FromFile(@"Images\0073.jpg"));
            g.FillPolygon(tBrush, p);

            Point[] p1 = { new Point(240, 110), new Point(300, 150), new Point(300, 360), new Point(240, 310) };
            HatchBrush hBrush = new HatchBrush(HatchStyle.DashedDownwardDiagonal, Color.Violet, Color.White);
            g.FillPolygon(hBrush, p1);
        }
コード例 #29
0
ファイル: Effects.cs プロジェクト: xuchuansheng/GenXSource
 private static void RoundImageTransparent(Image bitmap, int roundedDia)
 {
     Brush brush = new TextureBrush(bitmap);
     Graphics g = Graphics.FromImage(bitmap);
     g.Clear(Color.Transparent);
     Genetibase.UI.Drawing.Grpahics.FillRoundedRectangle(g, brush, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 30);
     g.Dispose();
     brush.Dispose();
     Rounded = true;
 }
コード例 #30
0
ファイル: AYTEditBox.cs プロジェクト: madhon/NetSpell
        static AYTTextBox()
        {
            Bitmap bmp=new Bitmap(4,2);
            bmp.SetPixel(0,0,Color.Red);
            bmp.SetPixel(1,1,Color.Red);
            bmp.SetPixel(2,1,Color.Red);
            bmp.SetPixel(3,0,Color.Red);

            _spellBrush=new TextureBrush(bmp);
        }
コード例 #31
0
	// Constructor.
	public DrawingTextureBrush(TextureBrush properties,
							   DrawingImage image,
							   RectangleF dstRect,
							   ImageAttributes imageAttr)
			{
				this.properties = properties;
				this.image = image;
				this.dstRect = dstRect;
				this.imageAttr = imageAttr;
			}
コード例 #32
0
        public frmMain()
        {
            InitializeComponent();

            panStatus.Tag = Color.FromArgb(30, 144, 255);
            panWarning.Tag = Color.FromArgb(178, 34, 34);

            ZoomInCursor = new Cursor(new MemoryStream(Properties.Resources.zoomin_cur));
            checker = new TextureBrush(Properties.Resources.Checker_16x16, System.Drawing.Drawing2D.WrapMode.Tile);

            // load language file, if any
            Localization.Init();

            lblOriginalFilename.Text = Localization.GetString("OriginalFileName_TextBox");
            btnGo.Text = Localization.GetString("Go_Button");
            btnRandomFile.Text = Localization.GetString("RandomFile_Button");
            optOther.Text = Localization.GetString("OtherSource_Option");
            btnSettings.Text = Localization.GetString("Settings_Button");
            lblCommonsFileDesc.Text = Localization.GetString("FilePageOnCommons_TextBox");
            lnkLinkify.Text = Localization.GetString("MakeSelectedTextIntoWikilink_Hyperlink");
            btnPastRevisions.Text = Localization.GetString("SelectVersion_Button");
            lblViewExif.Text = Localization.GetString("ContainsExifMetadata_Label");
            btnViewExif.Text = Localization.GetString("ViewMetadata_Button");
            lblFileLinks.Text = Localization.GetString("ImageUsage_Label");
            lnkGoToFileLink.Text = Localization.GetString("Go_Button") + " →";
            lblNormName.Text = Localization.GetString("NewFilenameOnCommons_TextBox");
            chkIgnoreWarnings.Text = Localization.GetString("IgnoreWarnings_CheckBox");
            chkDeleteAfter.Text = Localization.GetString("TagLocalFileWithNowCommons_Label");
            btnTransfer.Text = Localization.GetString("Transfer_Button");
            lnkCommonsFile.Text = Localization.GetString("ViewFilePageOnWikimediaCommons_Hyperlink");
            //lblCategoryHint.Text = Localization.GetString("DontForgetToCategorize_Label") + " " + Localization.GetString("HotcatHint_Label");
            lnkGoogleImageSearch.Text = Localization.GetString("GoogleCheck_Hyperlink");
            lblDeclineTransfer.Text = Localization.GetString("IfIneligibleEditManually_Label");
            lblExifNotice.Text = Localization.GetString("NoExifRotation_Label");
            lblStatus.Text = Localization.GetString("Loading");

            // time to load settings
            if (File.Exists("ForTheCommonGood.cfg"))
            {
                Settings.ReadSettings();
                if (Settings.SaveCreds == false)
                {
                    frmSettings set = new frmSettings(Settings.LocalUserName != "");
                    set.ShowDialog(this);
                }
            }
            else
            {
                MessageBox.Show(Localization.GetString("Welcome1") + "\n\n" + Localization.GetString("Welcome2"),
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnSettings_Click(this, null);
            }

            InitSettings();
        }
コード例 #33
0
ファイル: ShadeBorder.cs プロジェクト: hongnba/PdfViewer
        public void Dispose()
        {
            if (!_disposed)
            {
                if (_n != null)
                {
                    _n.Dispose();
                    _n = null;
                }

                if (_ne != null)
                {
                    _ne.Dispose();
                    _ne = null;
                }

                if (_e != null)
                {
                    _e.Dispose();
                    _e = null;
                }

                if (_se != null)
                {
                    _se.Dispose();
                    _se = null;
                }

                if (_s != null)
                {
                    _s.Dispose();
                    _s = null;
                }

                if (_sw != null)
                {
                    _sw.Dispose();
                    _sw = null;
                }

                if (_w != null)
                {
                    _w.Dispose();
                    _w = null;
                }

                if (_nw != null)
                {
                    _nw.Dispose();
                    _nw = null;
                }

                _disposed = true;
            }
        }
コード例 #34
0
        static AYTTextBox()
        {
            Bitmap bmp = new Bitmap(4, 2);

            bmp.SetPixel(0, 0, Color.Red);
            bmp.SetPixel(1, 1, Color.Red);
            bmp.SetPixel(2, 1, Color.Red);
            bmp.SetPixel(3, 0, Color.Red);

            _spellBrush = new TextureBrush(bmp);
        }
コード例 #35
0
        public override System.Drawing.Brush CreateGDIBrush(RectangleF rc, float dx, float dy)
        {
            RectangleF rct = new RectangleF(0, 0, _image.Width, _image.Height);

            System.Drawing.TextureBrush brush =
                new System.Drawing.TextureBrush(_image, _wrapMode, rct);

            brush.TranslateTransform(dx, dy);
            brush.ScaleTransform(24.0f / 80, 24.0f / 80, MatrixOrder.Append);
            return(brush);
        }
コード例 #36
0
    /// <summary>
    /// 转圆形图片
    /// </summary>
    /// <param name="img"></param>
    /// <param name="rec"></param>
    /// <param name="size"></param>
    /// <returns></returns>
    private System.Drawing.Image CutEllipse(System.Drawing.Image img, Rectangle rec, Size size)
    {
        Bitmap bitmap = new Bitmap(size.Width, size.Height);

        using (Graphics g = Graphics.FromImage(bitmap))
        {
            using (TextureBrush br = new System.Drawing.TextureBrush(img, System.Drawing.Drawing2D.WrapMode.Clamp, rec))
            {
                br.ScaleTransform(bitmap.Width / (float)rec.Width, bitmap.Height / (float)rec.Height);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.FillEllipse(br, new Rectangle(Point.Empty, size));
            }
        }
        return(bitmap);
    }
コード例 #37
0
        public override Image ExecuteFilter(Image inputImage)
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(inputImage.Width, inputImage.Height);
            bitmap.MakeTransparent();

            Graphics g = Graphics.FromImage(bitmap);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.Clear(BackGroundColor);

            Brush brush = new System.Drawing.TextureBrush(inputImage);

            g.FillCutRectangle(brush, 0, 0, inputImage.Width, inputImage.Height, CornerRadius, Corner);
            //FillRoundedRectangle(g, new Rectangle(0, 0, inputImage.Width, inputImage.Height), (int)CornerRadius, brush);

            return(bitmap);
        }
コード例 #38
0
ファイル: ImageUtils.cs プロジェクト: hungud/HtmlOptimization
        /// <summary>
        /// Returns image from base64 string
        /// </summary>
        /// <param name="SourceBitmap">Bitmap on which you want to apply rounded corners</param>
        /// <param name="Radius">Radius of bitmap corners</param>
        /// <returns>Rounded corner bitmap</returns>
        public static Bitmap RoundedCornerImage(this Bitmap SourceBitmap, int Radius)
        {
            Bitmap   _DestBitmap = new Bitmap(SourceBitmap.Width, SourceBitmap.Height);
            Graphics _Graph      = Graphics.FromImage(_DestBitmap);

            _Graph.Clear(Color.Transparent);
            _Graph.SmoothingMode = (System.Drawing.Drawing2D.SmoothingMode.AntiAlias);
            Brush     _brush    = new System.Drawing.TextureBrush(SourceBitmap);
            Rectangle _destRect = new Rectangle(0, 0, SourceBitmap.Width, SourceBitmap.Height);

            System.Drawing.Drawing2D.GraphicsPath _GraphPath = new System.Drawing.Drawing2D.GraphicsPath();
            _GraphPath.AddArc(_destRect.X, _destRect.Y, Radius, Radius, 180, 90);
            _GraphPath.AddArc(_destRect.X + _destRect.Width - Radius, _destRect.Y, Radius, Radius, 270, 90);
            _GraphPath.AddArc(_destRect.X + _destRect.Width - Radius, _destRect.Y + _destRect.Height - Radius, Radius, Radius, 0, 90);
            _GraphPath.AddArc(_destRect.X, _destRect.Y + _destRect.Height - Radius, Radius, Radius, 90, 90);
            _Graph.FillPath(_brush, _GraphPath);
            _Graph.Dispose();
            return(_DestBitmap);
        }
コード例 #39
0
 public EdgeDisplay(LedEdge edge, LedItem pItem)
 {
     this.ledEdge       = edge;
     this.ledItem       = pItem;
     this.subSize       = new System.Drawing.Size(pItem.ParentPanel.Width, pItem.ParentPanel.Height);
     this.circular      = (this.subSize.Width + this.subSize.Height) * 2;
     this.circularCount = 0m;
     if (this.ledEdge.Enabled)
     {
         this.AlphaBitmap = new System.Drawing.Bitmap((this.subSize.Width + this.subSize.Height) * 2, edge.Height);
         this.EdgeBitmap  = new System.Drawing.Bitmap((this.subSize.Width + this.subSize.Height) * 2, edge.Height);
         System.Drawing.Graphics     graphics = System.Drawing.Graphics.FromImage(this.EdgeBitmap);
         System.Drawing.TextureBrush brush    = new System.Drawing.TextureBrush(LedGlobal.LedEdgeList[edge.Index]);
         graphics.FillRectangle(brush, new System.Drawing.Rectangle(0, 0, this.EdgeBitmap.Width, this.EdgeBitmap.Height));
         if (this.ledEdge.Mode == LedEdgeMode.Static | this.ledEdge.Mode == LedEdgeMode.Blink)
         {
             this.EdgeBitmap = this.SetCornerAlpha(this.EdgeBitmap);
             this.SplitBitmapToItemEdge(this.EdgeBitmap);
         }
     }
 }
コード例 #40
0
        /// <summary>
        /// Executes this curved corners
        /// filter on the input image and returns the result
        /// Make sure you set the BackGroundColor property before running this filter.
        /// </summary>
        /// <param name="inputImage">input image</param>
        /// <returns>
        /// Curved Corner Image
        /// </returns>
        /// <example>
        ///   <code>
        /// Image transformed;
        /// RoundedCornersFilter rounded = new RoundedCornersFilter();
        /// rounded.BackGroundColor = Color.FromArgb(255, 255, 255, 255);
        /// rounded.CornerRadius = 15;
        /// transformed = rounded.ExecuteFilter(myImg);
        ///   </code>
        ///   </example>
        public override Image ExecuteFilter(Image inputImage)
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(inputImage.Width, inputImage.Height);
            bitmap.MakeTransparent();

            Graphics g = Graphics.FromImage(bitmap);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.Clear(BackGroundColor);

            Brush brush = new System.Drawing.TextureBrush(inputImage);

            //��ȸ߶ȼ�1��������ͼƬ�Ҳ���²಻������
            //�����ſ�������ߺ��ϲ�Գ�
            //��Ϊ���Ч����Ӱ�죬GDI+���ͼƬ������һ�����ؽ��а�͸���������˴�-1,-1��ʼ��ȥ���͸����
            g.FillRoundedRectangle(brush, -1, -1, inputImage.Width + 1, inputImage.Height + 1, CornerRadius, Corner);
            //FillRoundedRectangle(g, new Rectangle(0, 0, inputImage.Width, inputImage.Height), (int)CornerRadius, brush);

            return(bitmap);
        }
コード例 #41
0
ファイル: RoundedCornersFilter.cs プロジェクト: Epitomy/CMS
        /// <summary>
        /// Executes this curved corners
        /// filter on the input image and returns the result
        /// Make sure you set the BackGroundColor property before running this filter.
        /// </summary>
        /// <param name="inputImage">input image</param>
        /// <returns>Curved Corner Image</returns>
        /// <example>
        /// <code>
        /// Image transformed;
        /// RoundedCornersFilter rounded = new RoundedCornersFilter();
        /// rounded.BackGroundColor = Color.FromArgb(255, 255, 255, 255);
        /// rounded.CornerRadius = 15;
        /// transformed = rounded.ExecuteFilter(myImg);
        /// </code>
        /// </example>
        public override Image ExecuteFilter(Image inputImage)
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(inputImage.Width, inputImage.Height);
            bitmap.MakeTransparent();

            Graphics g = Graphics.FromImage(bitmap);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.Clear(BackGroundColor);

            Brush brush = new System.Drawing.TextureBrush(inputImage);

            //宽度高度减1,可以让图片右侧和下侧不会贴边
            //这样才可以与左边和上侧对称
            //因为锯齿效果的影响,GDI+会对图片的最外一个像素进行半透明处理,因此从-1,-1开始,去掉半透明边
            g.FillRoundedRectangle(brush, -1, -1, inputImage.Width + 1, inputImage.Height + 1, CornerRadius, Corner);
            //FillRoundedRectangle(g, new Rectangle(0, 0, inputImage.Width, inputImage.Height), (int)CornerRadius, brush);

            return(bitmap);
        }
コード例 #42
0
    private void Page_Init(Object sender, EventArgs e)
    {
        //Instantiate sql params object
        Blogic myBL = new Blogic();

        int    ID       = (int)Util.Val(Request.QueryString["id"]);
        string FileName = "";

        try
        {
            IDataReader dr = myBL.GetRecipeImageFileNameForUpdate(ID);

            dr.Read();

            if (dr["RecipeImage"] != DBNull.Value)
            {
                FileName = (string)dr["RecipeImage"];
            }

            dr.Close();
        }
        catch
        {
            //Redirect to image not found.
            //1 = pagenotfound.aspx
            Util.PageRedirect(1);
        }

        string Directory = Server.MapPath("~/RecipeImageUpload/");
        string path      = Directory + FileName;

        int roundedDia = 30;

        using (System.Drawing.Image imgin = System.Drawing.Image.FromFile(path))
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(imgin.Width, imgin.Height);
            Graphics g = Graphics.FromImage(bitmap);
            g.Clear(Color.White);
            Brush brush = new System.Drawing.TextureBrush(imgin);

            FillRoundedRectangle(g, new Rectangle(0, 0, imgin.Width, imgin.Height), roundedDia, brush);

            // done with drawing dispose graphics object.

            g.Dispose();

            // Stream Image to client.
            Response.Clear();

            Response.ContentType = "image/pjpeg";

            bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

            Response.End();

            //dispose bitmap object.

            bitmap.Dispose();

            //Release allocated memory
            myBL = null;
            Util = null;
        }
    }