VB.NET中怎么获取二进制图像

VB.NET中怎么获取二进制图像,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

从 Byte() 中进行VB.NET二进制图像的获取

  1. Public Function GetImage
    FromStream
    ()Function GetImageFromStream
    (ByVal ImageStream As Byte())
     As Image  

  2. Me.mobjImage = Nothing 

  3. If (ImageStream Is Nothing)
     Then  

  4. Return False  

  5. End If 

  1. Dim index As Integer = 0 

  2. If (((ImageStream(0) = &H15) 
    AndAlso (ImageStream(1) = &H1C)) 
    AndAlso (ImageStream.Length 
    >= 80)) Then  

  3. index = &H4E  

  4. Do While (index < (ImageStream.
    Length - 1))  

  5. If ((ImageStream(index) = &H42)
     AndAlso (ImageStream((index + 
    1)) = &H4D)) Then  

  6. Exit Do  

  7. End If  

  8. index += 1  

  9. Loop  

  10. If ((ImageStream(index) <> &H42)
     OrElse (ImageStream((index 
    + 1)) <> &H4D)) Then  

  11. index = &H87  

  12. End If  

  13. End If 

  1. Try  

  2. Dim stream As New MemoryStream
    (ImageStream, index, 
    (ImageStream.Length - index))  

  3. objImage = Drawing.Image.
    FromStream(stream)  

  4. Catch obj1 As Exception  

  5. return nothing  

  6. End Try  

  7. Return objImage  

  8. End Function  

看完上述内容,你们掌握VB.NET中怎么获取二进制图像的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!