WPF – GetBitmapImage

publicstaticBitmapImage GetBitmapImage(string pathFileName)
{

BitmapImage bitmap = newBitmapImage();

bitmap.BeginInit();

bitmap.CacheOption = BitmapCacheOption.OnLoad;

bitmap.UriSource = newUri(pathFileName, UriKind.Relative);

bitmap.EndInit();

return bitmap;

}