title: How to convert from Bitmap to Image and show the screenshot on the browser with VB.NET?
body: <p>I'm trying to transform from bitmap to base64 and from base64 to Image, because I want to show the screenshot on the image field named Image1. The problem is that I can't assign the value imagen to Image, it says that "Value of type  'System.Drawing.Image' cannot be converted to 'System.Web.UI.WebControls.Image' </p>
  
  <pre><code> Imports System.Drawing
   Imports System.Windows.Forms
  
   Public Class fotoPrueba
     Inherits System.Web.UI.Page
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
  End Sub
  
  Protected Sub Button1_Click(sender As Object, e As EventArgs)
      Dim bmp As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
      Dim base As String
      Dim imagen As Image
  
      base = BitmapToBase64(bmp)
  
      imagen = Base64ToImage(base)
  
      Image1 = imagen
  End Sub
  
  Public Function BitmapToBase64(ByVal image As System.Drawing.Bitmap) As String
      Dim base64 As String
      Dim memory As New System.IO.MemoryStream()
      image.Save(memory, Imaging.ImageFormat.Bmp)
      base64 = System.Convert.ToBase64String(memory.ToArray)
      memory.Close()
      memory = Nothing
      Return base64
  End Function
  
  Function Base64ToImage(ByVal base64string As String) As System.Drawing.Image
      'Setup image and get data stream together
      Dim img As System.Drawing.Image
      Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream
      Dim b64 As String = base64string.Replace(" ", "+")
      Dim b() As Byte
  
      'Converts the base64 encoded msg to image data
      b = Convert.FromBase64String(b64)
      MS = New System.IO.MemoryStream(b)
  
      'creates image
      img = System.Drawing.Image.FromStream(MS)
  
      Return img
  End Function
  
  End Class
  </code></pre>