<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>