110,502
社区成员
发帖
与我相关
我的任务
分享
Bitmap bmp = Bitmap.FromFile("D:\\test.png") as Bitmap;
Bitmap newBitmap = new Bitmap(50, 50);
Graphics g = Graphics.FromImage(newBitmap);
g.DrawImage(bmp, new Rectangle(0, 0, 50, 50), new Rectangle(0, 0, 1, 1), GraphicsUnit.Pixel);
newBitmap.Save("D:\\newTest.png");
g.Dispose();
newBitmap.Dispose();
bmp.Dispose();
base.OnPaint(e);
Bitmap bmp = new Bitmap(1,1);
using(Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.Red);
//g.FillEllipse(Brushes.Black, new Rectangle(0, 0, 10, 10));
}
System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
attr.SetWrapMode(WrapMode.Tile); //这个是关键
e.Graphics.DrawImage(bmp,new Rectangle(0,0,50,100), 0,0,bmp.Width,bmp.Height,GraphicsUnit.Pixel, attr,null,IntPtr.Zero);