From the Remarks section in BitmapCreateOptions
:
If PreservePixelFormat is not selected, the PixelFormat of the image is chosen by the system depending on what the system determines will yield the best performance. Enabling this option preserves the file format but may result in lesser performance.
Therefore you also need to set the PreservePixelFormat
flag:
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(imagePath);
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache
| BitmapCreateOptions.PreservePixelFormat;
bitmap.EndInit();