public override object Clone() { var result = new MemoryStreamImageProxy(); result.CopyFrom(this); return(result); }
private void CopyFrom(MemoryStreamImageProxy from) { this._url = from._url; this._name = from._name; this._stream = from._stream; this._image = from._image; this._hash = from._hash; }
public static MemoryStreamImageProxy FromStream(Stream istr, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = name; img._name = name; img.CopyFromStream(istr); return(img); }
public static MemoryStreamImageProxy FromFile(string fullpath) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = fullpath; img._name = System.IO.Path.GetFileName(fullpath); img.LoadStreamBuffer(fullpath); return(img); }
public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { MemoryStreamImageProxy s = (MemoryStreamImageProxy)obj; info.AddValue("Url", s._url); info.AddValue("Name", s._name); info.AddValue("Hash", s._hash); info.AddValue("Stream", s._stream); }
public virtual MemoryStreamImageProxy SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { MemoryStreamImageProxy s = null != o ? (MemoryStreamImageProxy)o : new MemoryStreamImageProxy(); s._url = info.GetString("Url"); s._name = info.GetString("Name"); s._hash = info.GetString("Hash"); s._stream = info.GetMemoryStream("Stream"); return(s); }
public static new MemoryStreamImageProxy FromFile(string fullpath) { var img = new MemoryStreamImageProxy { _url = fullpath, _name = System.IO.Path.GetFileName(fullpath), _extension = System.IO.Path.GetExtension(fullpath) }; img.LoadStreamBuffer(fullpath); return(img); }
public static new MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name) { var img = new MemoryStreamImageProxy(); MemoryStream str1, str2; string fmt1, fmt2; if (image is Metafile) { var mf = (Metafile)image; fmt1 = ".emf"; str1 = ImageToStream(image, ImageFormat.Emf); fmt2 = ".png"; str2 = ImageToStream(image, ImageFormat.Png); } else { fmt1 = ".jpg"; str1 = ImageToStream(image, ImageFormat.Jpeg); fmt2 = ".png"; str2 = ImageToStream(image, ImageFormat.Png); } if (str2.Length < str1.Length) { img._stream = str2; img._extension = fmt2; str1.Dispose(); } else { img._stream = str1; img._extension = fmt1; str2.Dispose(); } img.ComputeStreamHash(); if (string.IsNullOrEmpty(name)) { img._name = img._hash + img._extension; img._url = "image://" + img._name; } else { img._name = name; img._url = "image://" + name; } return(img); }
/// <summary> /// Creates a <see cref="MemoryStreamImageProxy"/> from a stream. A file name must be provided in order /// to deduce the kind of stream (.png for .png stream, .jpg for jpg stream and so on). /// </summary> /// <param name="istr">The image stream to copy from.</param> /// <param name="name">The name. The kind of image is deduced from the extension of this name.</param> /// <returns>A memory stream image proxy holding the image.</returns> /// <exception cref="ArgumentNullException"> /// istr /// or /// name - Name must be provided in order to deduce the file extension /// </exception> public static new MemoryStreamImageProxy FromStream(Stream istr, string name) { if (istr == null) { throw new ArgumentNullException(nameof(istr)); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), "Name must be provided in order to deduce the file extension"); } var img = new MemoryStreamImageProxy { _url = name, _name = name, _extension = System.IO.Path.GetExtension(name) }; img.CopyFromStream(istr); return(img); }
public static MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = "image://" + name; img._name = name; img._image = image; MemoryStream str1; MemoryStream str2; if (image is Metafile) { Metafile mf = (Metafile)image; str1 = ImageToStream(image, ImageFormat.Emf); str2 = ImageToStream(image, ImageFormat.Png); } else { str1 = ImageToStream(image, ImageFormat.Jpeg); str2 = ImageToStream(image, ImageFormat.Png); } if (str2.Length < str1.Length) { img._stream = str2; str1.Dispose(); } else { img._stream = str1; str2.Dispose(); } img.ComputeStreamHash(); return(img); }
public static MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = "image://" + name; img._name = name; img._image = image; MemoryStream str1; MemoryStream str2; if (image is Metafile) { Metafile mf = (Metafile)image; str1 = ImageToStream(image, ImageFormat.Emf); str2 = ImageToStream(image, ImageFormat.Png); } else { str1 = ImageToStream(image, ImageFormat.Jpeg); str2 = ImageToStream(image, ImageFormat.Png); } if (str2.Length < str1.Length) { img._stream = str2; str1.Dispose(); } else { img._stream = str1; str2.Dispose(); } img.ComputeStreamHash(); return img; }
public static MemoryStreamImageProxy FromFile(string fullpath) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = fullpath; img._name = System.IO.Path.GetFileName(fullpath); img.LoadStreamBuffer(fullpath); return img; }
public static ImageProxy FromStream(Stream istr, string name) { return(MemoryStreamImageProxy.FromStream(istr, name)); }
public static ImageProxy FromImage(System.Drawing.Image image, string name) { return(MemoryStreamImageProxy.FromImage(image, name)); }
public static ImageProxy FromStream(Stream istr) { return(MemoryStreamImageProxy.FromStream(istr)); }
public static MemoryStreamImageProxy FromStream(Stream istr, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = name; img._name = name; img.CopyFromStream(istr); return img; }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { MemoryStreamImageProxy s = SDeserialize(o, info, parent); return(s); }
public override object Clone() { MemoryStreamImageProxy result = new MemoryStreamImageProxy(); result.CopyFrom(this); return result; }
public static ImageProxy FromFile(string fullpath) { return(MemoryStreamImageProxy.FromFile(fullpath)); }