C# 如何获取剪贴板图像';它的高度和宽度是多少?

C# 如何获取剪贴板图像';它的高度和宽度是多少?,c#,vb.net,C#,Vb.net,如何获取剪贴板图像的高度和宽度 我需要一个像下面这样的代码 If My.Computer.Clipboard.ContainsImage Then MsgBox(Clipboard.Image(1).Height) 'This line is not real code. MsgBox(Clipboard.Image(1).Width) 'This line is not real code. End If 我需要图像大小,因为我想确定,如果我

如何获取剪贴板图像的高度和宽度

我需要一个像下面这样的代码

    If My.Computer.Clipboard.ContainsImage Then
        MsgBox(Clipboard.Image(1).Height) 'This line is not real code.
        MsgBox(Clipboard.Image(1).Width)  'This line is not real code.
    End If

我需要图像大小,因为我想确定,如果我将粘贴正确的图像

您可以这样使用:


你看过剪贴板中的GetImage选项了吗?我需要图像大小,因为我想确定我是否会粘贴正确的图像!我需要图像大小,因为我想确定,如果我将粘贴正确的图像!我无法将此C#代码转换为vb.net代码。有人支持吗?当然:-)对不起。。。非常感谢你。祝您有个美好的一天。
 Dim returnImage As System.Drawing.Image = Nothing
 If Clipboard.ContainsImage() Then
    returnImage = Clipboard.GetImage()
    If returnImage.Height != WantedImageHeight || returnImage.Width != WantedImageWidth Then
        MsgBox('The image is not correct')
    End If
 End If
if (Clipboard.ContainsImage())
    {
      System.Drawing.Image tempImg =  Clipboard.GetImage();
      int widthOfImg = tempImg.Width;
      int heightOfImg = tempImg.Height; 
    }