Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorConverters/EmbeddedImageVisitor.cs @ 13949

Last change on this file since 13949 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.4 KB
Line 
1using System;
2using System.IO;
3using System.Text;
4using System.Windows;
5using System.Collections.Generic;
6
7using System.Windows.Media;
8using System.Windows.Media.Imaging;
9
10using SharpVectors.Dom.Svg;
11using SharpVectors.Renderers.Wpf;
12
13using SharpVectors.Runtime;
14
15namespace SharpVectors.Converters
16{
17    public sealed class EmbeddedImageVisitor : WpfEmbeddedImageVisitor
18    {
19        public EmbeddedImageVisitor()
20        {
21        }
22
23        public override BitmapSource Visit(SvgImageElement element,
24            WpfDrawingContext context)
25        {
26            string sURI    = element.Href.AnimVal;
27            int nColon     = sURI.IndexOf(":");
28            int nSemiColon = sURI.IndexOf(";");
29            int nComma     = sURI.IndexOf(",");
30
31            string sMimeType  = sURI.Substring(nColon + 1,
32                nSemiColon - nColon - 1);
33
34            string sContent   = sURI.Substring(nComma + 1);
35            byte[] imageBytes = Convert.FromBase64CharArray(sContent.ToCharArray(),
36                0, sContent.Length);
37
38            //BitmapImage imageSource = new BitmapImage();
39            //imageSource.BeginInit();
40            //imageSource.StreamSource = new MemoryStream(imageBytes);
41            //imageSource.EndInit();
42
43            return new EmbeddedBitmapSource(new MemoryStream(imageBytes));
44        }
45    }
46}
Note: See TracBrowser for help on using the repository browser.