Ejemplo n.º 1
0
        private void CreateMapAndSetInitialTransformations()
        {
            switch (SelectedImageFileFormat)
              {
            case ImageFileFormat.ImageFile:
              using (var ms = new MemoryStream(originalMapBytes))
              {
            Map = new Map(ms);
            ms.Position = 0;
            var ed = QuickRouteJpegExtensionData.FromStream(ms);
            // is it a QuickRoute image? if yes, use embedded transformation matrix
            if (ed != null && ed.Sessions != null && ed.Sessions.Count > 0)
            {
              InitialTransformation = ed.Sessions.CalculateAverageTransformation();
            }
            break;
              }

            case ImageFileFormat.QuickRouteFile:
              using (var ms = new MemoryStream(originalMapBytes))
              {
            var d = Document.OpenFromQrt(ms);
            if (d != null)
            {
              Map = d.Map;
              InitialTransformation = d.Sessions.CalculateAverageTransformation();
            }
              }
              break;

            case ImageFileFormat.KmzFile:
              using (var ms = new MemoryStream(originalMapBytes))
              {
            var kmz = new KmzDocument(ms);
            if (kmz.ImageStream != null)
            {
              Map = new Map(kmz.ImageStream);
              InitialTransformation = kmz.Transformation;
            }
            break;
              }
              }
        }
Ejemplo n.º 2
0
        private static Image GetImageFromBytes(byte[] bytes, ImageFileFormat fileFormat)
        {
            try
              {
            switch (fileFormat)
            {
              case ImageFileFormat.ImageFile:
            using (var ms = new MemoryStream(bytes))
            {
              return Image.FromStream(ms);
            }

              case ImageFileFormat.QuickRouteFile:
            using (var ms = new MemoryStream(bytes))
            {
              var d = Document.OpenFromQrt(ms);
              return d.Map.Image;
            }

              case ImageFileFormat.KmzFile:
            using (var ms = new MemoryStream(bytes))
            {
              var kmz = new KmzDocument(ms);
              if (kmz.ImageStream != null)
              {
                return Image.FromStream(kmz.ImageStream);
              }
            }
            break;
            }
              }
              catch
              {
              }

              return null;
        }