2011-09-03 54 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

相關問題