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

imgToBase64

converte imagem em base64

Source

<Extension()> _
Public Function toBase64(ByVal img As Image) As String
    Try
        Dim ms As New System.IO.MemoryStream
        Dim arrImage() As Byte
        img.Save(ms, Imaging.ImageFormat.Bmp)
        arrImage = ms.GetBuffer
        Return Convert.ToBase64String(arrImage)

    Catch ex As Exception
        Return ""
    End Try
End Function

Example

img.toBase64

Author: Alex Martins

Submitted on: 23 aug. 2017

Language: VB

Type: image

Views: 3609