Imports Microsoft.VisualStudio.DebuggerVisualizers
Imports System.Drawing
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary

Public Class PictureVisualizerSource
    Inherits VisualizerObjectSource

    Public Overrides Sub GetData(ByVal target As Object, ByVal outgoingData As IO.Stream)
        Dim img As Image

        img = CType(target, Image)

        If (Not img Is Nothing) Then

            Dim info As New PictureViewerInfo

            Try
                info.PicImage = img
            Catch e As Exception
                info.ErrorMessage = e.Message
            End Try

            Dim formatter As BinaryFormatter = New BinaryFormatter()
            formatter.Serialize(outgoingData, info)
        End If
    End Sub

End Class
