当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.DrawImage方法代码示例

本文整理汇总了C#中System.Drawing.Graphics.DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawImage方法的具体用法?C# Graphics.DrawImage怎么用?C# Graphics.DrawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Graphics的用法示例。


在下文中一共展示了Graphics.DrawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: draw

        public void draw(Graphics g)
        {
            Bitmap t = SpaceInvaders.Properties.Resources.titleMenu;

            g.DrawImage(t,Game.gameSize.Width/2-t.Width/2, 1,t.Width,t.Height);

            g.DrawImage(SpaceInvaders.Properties.Resources.ship1,new Point(200,200));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship2, new Point(500, 500));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship3, new Point(400, 50));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship4, new Point(100, 300));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship5, new Point(40, 40));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship6, new Point(50, 150));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship7, new Point(500, 400));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship8, new Point(100, 500));
            g.DrawImage(SpaceInvaders.Properties.Resources.ship9, new Point(300, 450));

            int x = Game.gameSize.Width / 2;
            int y = Game.gameSize.Height / 2 - (this.items.Count/2 * this.espace );
            int dy = 0;
            g.DrawString(">", Game.defaultFont, Game.blackBrush, x-50 , y + this.espace *this.currentChose );
            g.DrawString(items[this.currentChose].Info ,new  Font("Times New Roman", 12, FontStyle.Bold, GraphicsUnit.Pixel),Game.blackBrush, x - 50, y +30 + this.espace * this.currentChose);
            foreach (MenuItem mi in items) {
                g.DrawString(mi.Name, Game.defaultFont, Game.blackBrush,x,y + dy);

                dy += this.espace;

            }
        }
开发者ID:tiregram,项目名称:esiee_e3_csharp_SpaceInvader,代码行数:28,代码来源:MenuManager.cs

示例2: drawGame

 public void drawGame(Graphics boardGr)
 {
     for (int i = 0; i < board.Width; i += gridSize)
     {
         for (int j = 0; j < board.Width; j += gridSize)
         {
             boardGr.DrawImage(ImageProvider.getTileTexture(TileType.None), new Rectangle(j, i, gridSize, gridSize));
         }
     }
     foreach (Tile tile in town.tiles)
     {
         boardGr.DrawImage(ImageProvider.getTileTexture(tile.type), new Rectangle(tile.getLocation().x, tile.getLocation().y, gridSize, gridSize));
     }
     for (int i = 0; i < board.Width; i += gridSize)
     {
         for (int j = 0; j < board.Width; j += gridSize)
         {
             boardGr.DrawRectangle(new Pen(Color.Black), new Rectangle(j, i, gridSize, gridSize));
         }
     }
     foreach (Entity entity in town.entities)
     {
         entity.draw(boardGr);
     }
 }
开发者ID:Cristaling,项目名称:TownSimGame,代码行数:25,代码来源:GameManager.cs

示例3: Draw

 public override void Draw(Graphics g)
 {
     if (borntime < Borntime) {
         switch (borntime % 8)
         {
             case 0:
             case 1:
                 g.DrawImage(bornImages[0], this.X, this.Y);
                 break;
             case 2:
             case 3:
                 g.DrawImage(bornImages[1], this.X, this.Y);
                 break;
             case 4:
             case 5:
                 g.DrawImage(bornImages[2], this.X, this.Y);
                 break;
             case 6:
             case 7:
                 g.DrawImage(bornImages[3], this.X, this.Y);
                 break;
         }
         borntime++;
         return;
     }
     g.DrawImage(img, this.X, this.Y);
 }
开发者ID:zy691357966,项目名称:Tank,代码行数:27,代码来源:Star.cs

示例4: DrawCandy

        public void DrawCandy(Graphics g)
        {
            sliki[0] = new Bitmap(Resources.candy1);
            sliki[1] = new Bitmap(Resources.candy2);
            sliki[2] = new Bitmap(Resources.candy3);
            sliki[3] = new Bitmap(Resources.candy4);
            for (int i = 0; i < KockiRec.Length; i += 4)
            {
                g.DrawImage(sliki[0], KockiRec[i]);

            }
            for (int j = 1; j < KockiRec.Length; j += 4)
            {
                g.DrawImage(sliki[1], KockiRec[j]);

            }
            for (int m = 2; m < KockiRec.Length; m += 4)
            {
                g.DrawImage(sliki[2], KockiRec[m]);

            }
            for (int n = 3; n < KockiRec.Length; n += 4)
            {
                g.DrawImage(sliki[3], KockiRec[n]);

            }
        }
开发者ID:Bozijanov,项目名称:CatchTheThing,代码行数:27,代码来源:Kocki.cs

示例5: Draw

        public void Draw(Graphics g)
        {
            if (State == Constants.Empty || State == Constants.Undefined)
            {
                return;
            }

            Image tmp;

            if (State == Constants.Free)
            {
                if (Hovered)
                {
                    tmp = Resources.selected;
                }
                else
                {
                    tmp = Resources.free;
                }
            }
            else
            {
                tmp = Resources.filled;
            }

            g.DrawImage(tmp, Position.X, Position.Y, 50, 50);

            // If State is not Filled or Free, then it has a Bee in it. Draw the bee.
            if (HasBee())
            {
                g.DrawImage(Game.getResourceImage(State), Position.X + 10, Position.Y + 10, 30, 30);
            }
        }
开发者ID:KristijanLaskovski,项目名称:TheHive,代码行数:33,代码来源:Slot.cs

示例6: Paint

        /// <summary>
        /// 绘制图元自身
        /// </summary>
        /// <param name="g">图形对象</param>
        public override void Paint(Graphics g)
        {
            RefreshImages();

            Rectangle rectangle = new Rectangle(location, elementSize);
            Rectangle hoverRectangle = new Rectangle(new Point(location.X, location.Y - 1),
                new Size(elementSize.Width + 3, elementSize.Height + 2));
            Image image;

            if (selected) // 图元被选中
            {
                image = selectedImage;
                g.DrawImage(image, hoverRectangle);
            }
            else if (activated) // 图元被激活
            {
                image = activatedImage;
                g.DrawImage(image, hoverRectangle);
            }
            else // 图元没有被选中和激活
            {
                image = normalImage;
                g.DrawImage(image, rectangle);
            }
        }
开发者ID:viticm,项目名称:pap2,代码行数:29,代码来源:ConnectJumpButton.cs

示例7: DrawImage

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="image"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public void DrawImage(Graphics g, Rectangle bounds, NuGenControlState state, Image image)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (image == null)
			{
				throw new ArgumentNullException("image");
			}

			switch (state)
			{
				case NuGenControlState.Disabled:
				{
					g.DrawImage(
						image,
						bounds,
						0, 0, image.Width, image.Height,
						GraphicsUnit.Pixel,
						NuGenControlPaint.GetDesaturatedImageAttributes()
					);
					break;
				}
				default:
				{
					g.DrawImage(image, bounds);
					break;
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:43,代码来源:NuGenRenderer.cs

示例8: Draw

        public void Draw(Graphics g)
        {
            if (selected)
            {
                //If the hotspot is currently selected displaying the active image
                g.DrawImage(activeImage, hotspotRect);
            }
            else
            {
                //If the hotspot is not selected displaying the inactive image
                g.DrawImage(inactiveImage, hotspotRect);

                //Getting how big the progress circle will be
                int fillWidth = (hotspotRect.Width / 100) * counter;
                int fillHeight = (hotspotRect.Width / 100) * counter;

                //Make the progress circle centered to the hotspot rectangle
                int xPos = (hotspotRect.Width - fillWidth) / 2 + hotspotRect.X;
                int yPos = (hotspotRect.Width - fillHeight) / 2 + hotspotRect.Y;

                //Displaying how close they are to activating the state
                g.FillEllipse(brush, xPos, yPos, fillWidth, fillHeight);

            }
        }
开发者ID:AlexanderMcNeill,项目名称:voxvisio,代码行数:25,代码来源:StateHotspot.cs

示例9: 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

示例10: DrawNormalState

 protected void DrawNormalState(Graphics g)
 {
     if (!facingDown)
         g.DrawImage(SimpleAlarm.Properties.Resources.upButton, this.Bounds);
     else
         g.DrawImage(SimpleAlarm.Properties.Resources.downButton, this.Bounds);
 }
开发者ID:cborrow,项目名称:SimpleAlarm,代码行数:7,代码来源:TimeUpDownControlButton.cs

示例11: Draw

 /// <summary>
 /// Draws the trophy
 /// </summary>
 /// <param name="g">The graphics object to draw the trophy on</param>
 public override void Draw(Graphics g)
 {
     switch (this.Colour)
     {
         case Colours.Red:
             g.DrawImage(Balloon_Cup.Properties.Resources.ballooncup_trophyred, _rekt);
             break;
         case Colours.Blue:
             g.DrawImage(Balloon_Cup.Properties.Resources.ballooncup_trophyblue, _rekt);
             break;
         case Colours.Green:
             g.DrawImage(Balloon_Cup.Properties.Resources.ballooncup_trophygreen, _rekt);
             break;
         case Colours.Grey:
             g.DrawImage(Balloon_Cup.Properties.Resources.ballooncup_trophygrey, _rekt);
             break;
         case Colours.Yellow:
             g.DrawImage(Balloon_Cup.Properties.Resources.ballooncup_trophygold, _rekt);
             break;
         case Colours.White:
             g.FillRectangle(Brushes.White, _rekt);
             break;
         default:
             throw new Exception("Trophy colour not found.");
     }
 }
开发者ID:WillMoreland,项目名称:BalloonCup,代码行数:30,代码来源:Trophy.cs

示例12: lineDrawing

        public void lineDrawing(String colorve, Graphics g, int xa, int ya, int xb, int yb)
        {
            int dx = xb - xa, dy = yb - ya, steps;
            float xIncrement, yIncrement, x = xa, y = ya;

            if (Math.Abs(dx) > Math.Abs(dy))
                steps = Math.Abs(dx);
            else
                steps = Math.Abs(dy);

            xIncrement = dx / (float)steps;
            yIncrement = dy / (float)steps;

            Bitmap bmp = new Bitmap(1, 1);
            bmp.SetPixel(0, 0, Color.FromName(colorve));

            g.DrawImage(bmp, round(x), round(y));

            for (int k = 0; k < steps; k++)
            {
                x += xIncrement;
                y += yIncrement;

                g.DrawImage(bmp, round(x), round(y));
            }
        }
开发者ID:ZARRINTASNIM,项目名称:MSPaint,代码行数:26,代码来源:Methods.cs

示例13: Draw

        public override void Draw(Graphics g)
        {
            UpdateBounds();

            if (BeenHit)
            {
                DrawExplosion(g);
                return;
            }

            if (Counter % 2 == 0)
                g.DrawImage(TheImage, MovingBounds, 0, 0, ImageBounds.Width, ImageBounds.Height, GraphicsUnit.Pixel);
            else
                g.DrawImage(OtherImage, MovingBounds, 0, 0, ImageBounds.Width, ImageBounds.Height, GraphicsUnit.Pixel);

            if (ActiveBomb)
            {
              TheBomb.Draw(g);
                if (Form1.ActiveForm != null)
                {
                    if (TheBomb.Position.Y > Form1.ActiveForm.ClientRectangle.Height)
                    {
                        ActiveBomb = false;
                    }
                }
            }

            if ((ActiveBomb == false) && (Counter % kBombInterval == 0))
            {
                ActiveBomb = true;
                TheBomb.Position.X = MovingBounds.X + MovingBounds.Width/2;
                TheBomb.Position.Y = MovingBounds.Y + 5;
            }
        }
开发者ID:brayanrp215,项目名称:Recursos,代码行数:34,代码来源:Invader.cs

示例14: Draw

        public override void Draw(Graphics g, int target)
        {
            Image head = PicLoader.Read("NPC", string.Format("{0}.PNG", Figue));
            int ty = Y + 50;
            int ty2 = ty;
            if (target == Id)
            {
                g.DrawImage(head, X - 5, ty - 5, Width*5/4, Width * 5 / 4);
                ty2 -= 2;
            }
            else
            {
                g.DrawImage(head, X, ty, Width, Width);
            }

            head.Dispose();

            Font font = new Font("΢ÈíÑźÚ", 12*1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
            g.DrawString(Name, font, Brushes.Black, X + 3, Y + Height + 30);
            g.DrawString(Name, font, Brushes.White, X, Y + Height + 27);
            font.Dispose();

            if (taskFinishs.Count > 0)
            {
                Image img = PicLoader.Read("System", "MarkTaskEnd.PNG");
                g.DrawImage(img, X + 15, ty2 - 35, 21, 30);
                img.Dispose();
            }
            else if (taskAvails.Count > 0)
            {
                Image img = PicLoader.Read("System", "MarkTaskBegin.PNG");
                g.DrawImage(img, X + 15, ty2 - 35, 24, 30);
                img.Dispose();
            }
        }
开发者ID:narlon,项目名称:TOMClassic,代码行数:35,代码来源:SceneNPC.cs

示例15: Draw

        public override void Draw(Graphics g)
        {
            if (nid > 0)
            {
                int itemCount = UserProfile.Profile.InfoBag.GetItemCount(nid);
                bool isEnough = itemCount >= need;

                g.DrawImage(DataType.Items.HItemBook.GetHItemImage(nid), x, y, width, height);
                if (IsIn && isEnough)
                {
                    g.DrawImage(DataType.Items.HItemBook.GetHItemImage(nid), x+3, y+3, width-6, height-6);
                }
                if (!isEnough)
                {//灰色遮罩
                    Brush brush = new SolidBrush(Color.FromArgb(120, Color.Black));
                    g.FillRectangle(brush, x, y, width, height);
                    brush.Dispose();
                }

                Font fontsong = new Font("宋体", 7*1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                g.DrawString(string.Format("{0}/{1}", need, itemCount), fontsong, isEnough ? Brushes.White : Brushes.Red, x + 1, y + 18);
                fontsong.Dispose();
            }

            foreach (IRegionDecorator decorator in decorators)
            {
                decorator.Draw(g, x, y, width, height);
            }
        }
开发者ID:narlon,项目名称:TOMClassic,代码行数:29,代码来源:ItemUseRegion.cs


注:本文中的System.Drawing.Graphics.DrawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。