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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Drawing;
|
---|
6 | using System.IO;
|
---|
7 | using System.Drawing.Imaging;
|
---|
8 | using System.Text.RegularExpressions;
|
---|
9 | using HeuristicLab.Persistence.Core;
|
---|
10 | using HeuristicLab.Persistence.Default.Xml.Compact;
|
---|
11 |
|
---|
12 | namespace 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.