public Map(string source, MapSourceType sourceType, MapStorageType storageType) { this.source = source; this.sourceType = sourceType; this.storageType = storageType; this.image = GetImage(source, sourceType); }
public Map(string source, MapSourceType sourceType, MapStorageType storageType) { this.source = source; this.sourceType = sourceType; this.storageType = storageType; this.image = GetImage(source, sourceType); }
public Map(Stream stream) { this.source = null; this.sourceType = MapSourceType.FileSystem; this.storageType = MapStorageType.Inline; stream.Position = 0; this.image = StripQuickRouteHeader(stream); }
public Map(Bitmap image) { this.source = null; this.sourceType = MapSourceType.FileSystem; this.storageType = MapStorageType.Inline; this.image = image; this.rawData = null; }
public Map(Stream stream) { this.source = null; this.sourceType = MapSourceType.FileSystem; this.storageType = MapStorageType.Inline; stream.Position = 0; this.image = StripQuickRouteHeader(stream); }
public Map(Bitmap image) { this.source = null; this.sourceType = MapSourceType.FileSystem; this.storageType = MapStorageType.Inline; this.image = image; this.rawData = null; }
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)); }
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; } }
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); }
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; } }
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); }
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; }