C# 如何绘制宽度和高度为c的剪切图像#

C# 如何绘制宽度和高度为c的剪切图像#,c#,image,canvas,cursor,C#,Image,Canvas,Cursor,我已经在一个引擎上工作了一段时间,现在光标太小了,所以我想知道如何更改高度和宽度。这是我正在使用的代码 public void drawCutImage(int cutX, int cutY, int cutWidth, int cutHeight, int drawX, int drawY, Image image) { // Clone a portion of the Bitmap object. Rectangle sourceRect =

我已经在一个引擎上工作了一段时间,现在光标太小了,所以我想知道如何更改高度和宽度。这是我正在使用的代码

    public void drawCutImage(int cutX, int cutY, int cutWidth, int cutHeight, int drawX, int drawY, Image image)
    {
        // Clone a portion of the Bitmap object.
        Rectangle sourceRect = new Rectangle(cutHeight * cutX, cutWidth * cutY, cutWidth, cutHeight);
        System.Drawing.Imaging.PixelFormat format =
            image.PixelFormat;

        // Draw the cloned portion of the Bitmap object.
        sCanvas.DrawImage(image, drawX, drawY, sourceRect, GraphicsUnit.Pixel);
    }
但我希望能够做到这一点

        sCanvas.DrawImage(image, drawX, drawY, drawWidth, drawHeight, sourceRect, GraphicsUnit.Pixel);

此链接将非常有用,请访问;
您还可以使用另一种方式剪切图像,方法是使用特定的起点和大小裁剪和克隆图像

private static Image cropImage(Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
return bmpImage.Clone(cropArea, bmpImage.PixelFormat);
}
希望这有帮助。

试试格式化!这正是你想要的。