コード例 #1
0
 public Map(string source, MapSourceType sourceType, MapStorageType storageType)
 {
     this.source      = source;
     this.sourceType  = sourceType;
     this.storageType = storageType;
     this.image       = GetImage(source, sourceType);
 }
コード例 #2
0
ファイル: Map.cs プロジェクト: jarkko/quickroute-gps
 public Map(string source, MapSourceType sourceType, MapStorageType storageType)
 {
     this.source = source;
       this.sourceType = sourceType;
       this.storageType = storageType;
       this.image = GetImage(source, sourceType);
 }
コード例 #3
0
 public Map(Stream stream)
 {
     this.source      = null;
     this.sourceType  = MapSourceType.FileSystem;
     this.storageType = MapStorageType.Inline;
     stream.Position  = 0;
     this.image       = StripQuickRouteHeader(stream);
 }
コード例 #4
0
 public Map(Bitmap image)
 {
     this.source      = null;
     this.sourceType  = MapSourceType.FileSystem;
     this.storageType = MapStorageType.Inline;
     this.image       = image;
     this.rawData     = null;
 }
コード例 #5
0
ファイル: Map.cs プロジェクト: jarkko/quickroute-gps
 public Map(Stream stream)
 {
     this.source = null;
       this.sourceType = MapSourceType.FileSystem;
       this.storageType = MapStorageType.Inline;
       stream.Position = 0;
       this.image = StripQuickRouteHeader(stream);
 }
コード例 #6
0
ファイル: Map.cs プロジェクト: jarkko/quickroute-gps
 public Map(Bitmap image)
 {
     this.source = null;
       this.sourceType = MapSourceType.FileSystem;
       this.storageType = MapStorageType.Inline;
       this.image = image;
       this.rawData = null;
 }
コード例 #7
0
        private Bitmap GetImage(string source, MapSourceType sourceType)
        {
            Stream stream = null;

            switch (sourceType)
            {
            case MapSourceType.FileSystem:
                stream = new FileStream(source, FileMode.Open);
                break;

            case MapSourceType.Url:
                stream = GetImageStreamFromUrl(source);
                break;
            }

            return(StripQuickRouteHeader(stream));
        }
コード例 #8
0
        protected Map(SerializationInfo info, StreamingContext context)
        {
            source      = info.GetString("source");
            sourceType  = (MapSourceType)(info.GetValue("sourceType", typeof(MapSourceType)));
            storageType = (MapStorageType)(info.GetValue("storageType", typeof(MapStorageType)));
            switch (storageType)
            {
            case MapStorageType.Inline:
                //rawData = (byte[])(info.GetValueNo("rawData", typeof(byte[])));
                var getValueNoThrowMethod = info.GetType().GetMethod("GetValueNoThrow", BindingFlags.Instance | BindingFlags.NonPublic);
                rawData = (byte[])getValueNoThrowMethod.Invoke(info, new object[] { "rawData", typeof(byte[]) });


                if (rawData != null)
                {
                    // version 2.3 file format contains rawData field, create image from it
                    using (var ms = new MemoryStream(rawData))
                    {
                        image = (Bitmap)System.Drawing.Image.FromStream(ms);
                    }
                }
                else
                {
                    // version 2.2 file format
                    image = (Bitmap)(info.GetValue("image", typeof(Bitmap)));
                }
                break;

            case MapStorageType.Reference:
                switch (sourceType)
                {
                case MapSourceType.FileSystem:
                    image = (Bitmap)System.Drawing.Image.FromFile(source);
                    break;

                case MapSourceType.Url:
                    image = GetImageFromUrl(source);
                    break;
                }
                break;
            }
        }
コード例 #9
0
ファイル: Map.cs プロジェクト: gabbe/quickroute
        private Bitmap GetImage(string source, MapSourceType sourceType)
        {
            Stream stream = null;

            switch (sourceType)
            {
            case MapSourceType.FileSystem:
                stream = new FileStream(source, FileMode.Open);
                break;

            case MapSourceType.Url:
                stream = GetImageStreamFromUrl(source);
                break;
            }

            var result = StripQuickRouteHeader(stream);

            if (stream != null)
            {
                stream.Close();
                stream.Dispose();
            }
            return(result);
        }
コード例 #10
0
ファイル: Map.cs プロジェクト: jarkko/quickroute-gps
        protected Map(SerializationInfo info, StreamingContext context)
        {
            source = info.GetString("source");
              sourceType = (MapSourceType)(info.GetValue("sourceType", typeof(MapSourceType)));
              storageType = (MapStorageType)(info.GetValue("storageType", typeof(MapStorageType)));
              switch (storageType)
              {
            case MapStorageType.Inline:
              //rawData = (byte[])(info.GetValueNo("rawData", typeof(byte[])));
              var getValueNoThrowMethod = info.GetType().GetMethod("GetValueNoThrow", BindingFlags.Instance | BindingFlags.NonPublic);
              rawData = (byte[])getValueNoThrowMethod.Invoke(info, new object[] { "rawData", typeof(byte[]) });

              if (rawData != null)
              {
            // version 2.3 file format contains rawData field, create image from it
            using (var ms = new MemoryStream(rawData))
            {
              image = (Bitmap)System.Drawing.Image.FromStream(ms);
            }
              }
              else
              {
            // version 2.2 file format
            image = (Bitmap)(info.GetValue("image", typeof(Bitmap)));
              }
              break;

            case MapStorageType.Reference:
              switch (sourceType)
              {
            case MapSourceType.FileSystem:
              image = (Bitmap)System.Drawing.Image.FromFile(source);
              break;
            case MapSourceType.Url:
              image = GetImageFromUrl(source);
              break;
              }
              break;
              }
        }
コード例 #11
0
ファイル: Map.cs プロジェクト: jarkko/quickroute-gps
        private Bitmap GetImage(string source, MapSourceType sourceType)
        {
            Stream stream = null;
              switch (sourceType)
              {
            case MapSourceType.FileSystem:
              stream = new FileStream(source, FileMode.Open);
              break;

            case MapSourceType.Url:
              stream = GetImageStreamFromUrl(source);
              break;
              }

              return StripQuickRouteHeader(stream);
        }
コード例 #12
0
ファイル: Map.cs プロジェクト: romanbdev/quickroute-gps
        private Bitmap GetImage(string source, MapSourceType sourceType)
        {
            Stream stream = null;
              switch (sourceType)
              {
            case MapSourceType.FileSystem:
              stream = new FileStream(source, FileMode.Open);
              break;

            case MapSourceType.Url:
              stream = GetImageStreamFromUrl(source);
              break;
              }

              var result = StripQuickRouteHeader(stream);
              if(stream != null)
              {
            stream.Close();
            stream.Dispose();
              }
              return result;
        }