Example #1
0
        public void Deserialize(Stream stream, ICanvas canvas)
        {
            try
            {
                using (var packageStorage = BaseArchive.CreateArchive(stream))
                {
                    var xmlDoc = new XmlDocument();

                    using (var outStream = packageStorage.GetReadStream(_canvasFileName))
                        xmlDoc.Load(outStream);

                    var svgReader = new SvgReader(new TypeResolver(), new VoAttributeReader());
                    var svgDoc    = svgReader.CreateSvgNodeFromXml(xmlDoc.DocumentElement) as SvgDocument;
                    svgReader.Read(svgDoc, xmlDoc.DocumentElement);

                    var svgConverter = new SvgConverter(packageStorage);
                    svgConverter.FromSvg(canvas, svgDoc);

                    using (var cmykProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _cmykProfileFileName)))
                        canvas.CmykColorProfile = new ColorProfile(cmykProfileStream);

                    using (var grayscaleProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _grayscaleProfileFileName)))
                        canvas.GrayscaleColorProfile = new ColorProfile(grayscaleProfileStream);

                    using (var rgbProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _rgbProfileFileName)))
                        canvas.RgbColorProfile = new ColorProfile(rgbProfileStream);
                }
            }
            catch (Exception ex)
            {
                Configuration.Logger.Error(Exceptions.CanNotDeserializeCanvas, ex);

                throw new SerializationException(Exceptions.CanNotDeserializeCanvas, ex);
            }
        }
Example #2
0
 public SvgConverter(BaseArchive fileStorage)
 {
     _fileStorage = fileStorage;
 }