序列化带有填充标签的system.drawing.image列表

时间:2019-02-12 13:39:30

标签: .net serialization

  • 创建新的system.drawing.image
  • 使用值设置image.tag
  • 将图像添加到图像列表

    ImageList = New List(Of System.Drawing.Image)

    Using stream As IO.FileStream = File.Open(ThumbFilePath, IO.FileMode.Create)
    Dim formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
    formatter.Serialize(stream, ImageList)
    stream.Flush()
    stream.Close()
    End Using
    

因此,当我从流中进行反序列化检索图像列表时,image.tag无效。我认为该标签甚至根本没有序列化。 有什么办法可以将标签信息与每个图像一起保存在列表中,并对其进行序列化以在以后进行检索?

1 个答案:

答案 0 :(得分:0)

反序列化:

Using stream As IO.FileStream = IO.File.Open(ThumbFilePath, IO.FileMode.Open, IO.FileAccess.Read)
            Dim formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
            ImageList = CType(formatter.Deserialize(stream), List(Of System.Drawing.Image))
        End Using