Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/System.Drawing/Bitmap2XmlSerializer.cs @ 3036

Last change on this file since 3036 was 3036, checked in by epitzer, 15 years ago

make most serializers internal and complete API documentation (#548)

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Drawing;
6using System.IO;
7using System.Drawing.Imaging;
8using System.Text.RegularExpressions;
9using HeuristicLab.Persistence.Core;
10using HeuristicLab.Persistence.Default.Xml.Compact;
11
12namespace HeuristicLab.Persistence.Default.Xml.Primitive {
13  internal sealed class Bitmap2XmlSerializer : PrimitiveXmlSerializerBase<Bitmap> {
14
15    public override XmlString Format(Bitmap o) {
16      MemoryStream stream = new MemoryStream();
17      o.Save(stream, ImageFormat.Png);
18      byte[] array = stream.ToArray();
19      Byte1DArray2XmlSerializer serializer = new Byte1DArray2XmlSerializer();
20      return serializer.Format(array);
21    }
22
23    public override Bitmap Parse(XmlString t) {
24      Byte1DArray2XmlSerializer serializer = new Byte1DArray2XmlSerializer();
25      byte[] array = serializer.Parse(t);
26
27      MemoryStream stream = new MemoryStream();
28      stream.Write(array, 0, array.Length);
29      stream.Seek(0, SeekOrigin.Begin);
30
31      Bitmap bitmap = new Bitmap(stream);
32      return bitmap;
33    }
34  }
35}
Note: See TracBrowser for help on using the repository browser.