1
我試圖檢查一組圖像(通常超過50個,每個大約3 MB),以確定它們的方向。 當我已經處理了一堆內容時,出現「內存不足」錯誤。vb.net - 處理大量圖像時內存不足
所以我的問題是如何分別檢查每個圖像以便使用最少的內存?
我真的很新vb.net和編程可言,所以這是我能想出如何做我的任務的唯一方法:
Dim MyFiles As New ArrayList()
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox2.Clear()
If CheckBox2.Checked = True Then
TextBox2.Text = "Checking the orientation of the images ..." & vbNewLine & vbNewLine
For i As Integer = 0 To MyFiles.Count - 1
TextBox2.AppendText("Checking " & MyFiles(i) & vbNewLine)
If Image.FromFile(MyFiles(i)).Width < Image.FromFile(MyFiles(i)).Height Then
TextBox2.AppendText(vbNewLine & "There are images with portrait orientation. Splitting aborted!" & vbNewLine)
Return
End If
Next
TextBox2.AppendText(vbNewLine & "All images are with landscape orientation." & vbNewLine)
End If
'ConvertBMP("C:\test.bmp", ImageFormat.Jpeg)
End Sub
你是不配置Image對象,這就是爲什麼最終會出現「內存不足」的原因。 –