0

解決策がわかりません。これは私のコードです:

   Dim wbRect As Rectangle = WebBrowser1.ClientRectangle
   Dim wbBm As New Bitmap(WebBrowser1.ClientRectangle.Width, WebBrowser1.ClientRectangle.Height)
   Dim gwb As Graphics = Graphics.FromImage(wbBm)
   gwb.CopyFromScreen(WebBrowser1.PointToScreen(New Point(14, 31)),
   New Point(0, 0),
   New Size(PictureBox1.Width, PictureBox1.Height))
   wbBm.Save("c:\temp1.bmp")
   PictureBox1.ImageLocation = "c:\temp1.bmp"
   PictureBox1.BringToFront()

   Dim bm As New Bitmap("c:\img1.bmp") //here appears an error - Parameter is not valid

   Dim rect As New Rectangle(0, 0, bm.Width, bm.Height)
   Dim bmpData As System.Drawing.Imaging.BitmapData = bm.LockBits(rect, _
   System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb)

エラーを削除するにはどうすればよいですか?

4

1 に答える 1

0

ファイルが存在しない場合、このエラーが発生します。開く前に、img1.bmpが存在することを確認してください。

    Dim fn As String = "c:\img1.bmp"
    If File.Exists(fn)
        Dim bm As New Bitmap(fn) ''here appears an error - Parameter is not valid

        Dim rect As New Rectangle(0, 0, bm.Width, bm.Height)
        Dim bmpData As System.Drawing.Imaging.BitmapData = bm.LockBits(rect, _
        System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb)
    End If
于 2013-02-01T22:04:51.793 に答える