The above image is 480x720 in pixels. It came from a vertical shoot of a Canon DSLC. Windows can show it in the right way, same as StackOverflow do.
However, the following code does not:
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = File.OpenRead("test.jpg");
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
//Fail; bitmap.PixelWidth==720
Debug.Assert(bitmap.PixelWidth==480);
//Fail; bitmap.PixelHeight==480
Debug.Assert(bitmap.PixelWidth==720);
So how can I get it in the right way within WPF in C#?