2011-09-03 76 views

回答

19

使用Bitmap.Clone(Rectangle, PixelFormat),在这里我们可以设置新形象PixelFormat和矩形

// Create a Bitmap object from a file. 
Bitmap myBitmap = new Bitmap("Grapes.jpg"); 

// Clone a portion of the Bitmap object. 
Rectangle cloneRect = new Rectangle(0, 0, 100, 100); 
System.Drawing.Imaging.PixelFormat format = 
    myBitmap.PixelFormat; 
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format); 

// Draw the cloned portion of the Bitmap object. 
e.Graphics.DrawImage(cloneBitmap, 0, 0); 
+0

这是什么的PixelFormat的大小? – Bosak

+0

我们可以指定新的图像像素格式 – Damith

相关问题