1

VB.NET을 사용하여 AForge.NET에서 이미지를 반전해야하는 OMR 프로젝트에서 작업하고 있습니다. 이 코드를 사용하고 있습니다. -VB.NET에서 AForge.NET으로 반전 된 이미지

Private Sub Load_Butt_Click(sender As Object, e As EventArgs) Handles Load_Butt.Click 
    ' load image 
    Dim image As Bitmap = AForge.Imaging.Image.FromFile("c://test.bmp") 
    ' create invert filter 
    Dim filter As New Invert() 
    Dim inv_img As Bitmap 
    ' apply the invert filter 
    inv_img = filter.Apply(image) 
    PictureBox1.Image = inv_img 
End Sub 

오류가 없습니다. 나는이 프로그램을 실행할 때하지만

AForge.Imaging.dll

에서 발생 유형 'AForge.Imaging.UnsupportedImageFormatException'의

처리되지 않은 예외가 says- 오류가 발생합니다. See Screenshot

답변

0

문제는 픽셀 format.I로했다가 도움이 될 수 있습니다 기대하고 작업 코드를 게시하고 다른 사람 someday-

Public image As Bitmap = AForge.Imaging.Image.FromFile("c://test.bmp") 

Public inv_img As Bitmap 

Public Sub ApplyFilter(filter As IFilter) 
    ' apply filter 
    inv_img = filter.Apply(image) 
    ' display image 
    PictureBox1.Image = inv_img 
End Sub 
Public Sub Load_Butt_Click(sender As Object, e As EventArgs) Handles Load_Butt.Click 


    ' check pixel format 
    If (image.PixelFormat = PixelFormat.Format16bppGrayScale) OrElse (Bitmap.GetPixelFormatSize(image.PixelFormat) > 32) Then 
     MessageBox.Show("The demo application supports only color images.", "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error]) 
     ' free image 
     image.Dispose() 
     image = Nothing 
    Else 
     ' make sure the image has 24 bpp format 
     If image.PixelFormat <> PixelFormat.Format24bppRgb Then 
      Dim temp As Bitmap = AForge.Imaging.Image.Clone(image, PixelFormat.Format24bppRgb) 
      image.Dispose() 
      image = temp 
     End If 
    End If 


    ApplyFilter(New Invert()) 
End Sub