• 创建BitMap


    <span style="font-size:18px;">Bitmap pResource=(Bitmap)Image.FromFile("..\..\res\animal.bmp");
    
    Bitmap pBitMap = new Bitmap(36, 36);        //BitMap大小
    Graphics pGraphics = Graphics.FromImage(pBitMap);       //创建Graphics对象
    Rectangle pDestRec = new Rectangle(0, 0, 39, 39);         //创建所绘制图像的位置和大小,以PictureEdit左上角为(0,0)
    
    Rectangle pSrcRec = new Rectangle(0, 2*39, 39, 39);     //创建所截取bmp图像的位置
    pGraphics.DrawImage(pResource, pDestRec, pSrcRec, System.Drawing.GraphicsUnit.Pixel);     //绘制出所需要的bitmap
    
     
    
     
    
    将图片会知道pictureEdit上:先创建一个Graphics对象,然后将创建的BitMap进行绘制
    
    if (this.pictureEdit1.Image == null)
    {
    Bitmap bmp = new Bitmap(this.pictureEdit1.Width, pictureEdit1.Height);
    this.pictureEdit1.Image = bmp;
    }
    Graphics g = Graphics.FromImage(this.pictureEdit1.Image);
    
    g.DrawImage(pBitMap, 20, 95,38,38);</span>

  • 相关阅读:
    [bzoj4364] [IOI2014]wall砖墙
    [bzoj3064] [Tyvj 1518] CPU监控
    [bzoj3434] [WC2014]时空穿梭
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    MSSQL
  • 原文地址:https://www.cnblogs.com/dengshiwei/p/4258692.html
Copyright © 2020-2023  润新知