ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

base64ToImage

Converte base64 image em imagem

Source

<Extension()> _
Public Function toImage(ByVal base64String As String) As Image
    Try

        Dim b As Byte()
        b = Convert.FromBase64String(base64String)
        Dim ms As New System.IO.MemoryStream(b, 0, b.Length)
        ms.Write(b, 0, b.Length)
        Return Image.FromStream(ms, True)
    Catch ex As Exception
        Return Nothing
    End Try
End Function

Example

str_base64.ToImage

Author: Alex Martins

Submitted on: 23 aug. 2017

Language: VB

Type: string

Views: 3450