6
我有一个瓷砖,但所有的瓷砖都在一个图像。我想在某种位图或图像数组中获取所有图块。 有没有这样的方法呢?如何获取图像的一部分并将其作为单独的图像使用?
我有一个瓷砖,但所有的瓷砖都在一个图像。我想在某种位图或图像数组中获取所有图块。 有没有这样的方法呢?如何获取图像的一部分并将其作为单独的图像使用?
使用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);
这是什么的PixelFormat的大小? – Bosak
我们可以指定新的图像像素格式 – Damith