Convertendo bitmap em ImageSource
Estou tentando tirar uma captura de tela e defini-la como plano de fundo de uma janela WPF. Este é o meu código para converter a captura de tela em ImageSource. Estou recebendo uma NullReferenceException ao converter de bitmap. Como fazer isso corretamente?
Dim screenSize = Forms.SystemInformation.PrimaryMonitorSize
Dim bitmap = New System.Drawing.Bitmap(screenSize.Width, screenSize.Height)
Dim g = System.Drawing.Graphics.FromImage(bitmap)
g.CopyFromScreen(New System.Drawing.Point(0, 0), New System.Drawing.Point(0, 0), screenSize)
g.Flush()
Dim c As ImageSourceConverter = New ImageSourceConverter()
Dim img As ImageSource = c.ConvertFrom(bitmap)