Bloom.ImageProcessing.ImageUtils.GetImageFromFile C# (CSharp) Method

GetImageFromFile() public static method

Read a bitmap image from a file. The file must be known to exist before calling this method.
Image.FromFile and Image.FromStream lock the file until the image is disposed of. Therefore, we copy the image and dispose of the original. On Windows, Image.FromFile leaks file handles, so we use FromStream instead. For details, see the last answer to http://stackoverflow.com/questions/16055667/graphics-drawimage-out-of-memory-exception
public static GetImageFromFile ( string path ) : Image
path string
return Image
        public static Image GetImageFromFile(string path)
        {
            Debug.Assert(RobustFile.Exists(path), String.Format("{0} does not exist for ImageUtils.GetImageFromFile()?!", path));
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var image = new Bitmap(stream))
                {
                    return new Bitmap(image);
                }
            }
        }