我这里有一个示例 wpf 应用程序,我想知道为什么 BMP 加载速度比 PNG 快。这是确切的设置:
- Windows 7
- Visual Studio 2013
- landscape.png, 1920x1080, 2.4mb
- landscape.bmp, 1920x1080, 5.6mb
- wpf-app, class MainWindow.xaml.cs constructor, no other code before
Run Code Online (Sandbox Code Playgroud)
代码:
var sw = Stopwatch.StartNew();
var Bitmap1 = new Bitmap("landscape.bmp");
long t1 = sw.ElapsedMilliseconds;
sw.Restart();
var Bitmap2 = new Bitmap("landscape.png");
long t2 = sw.ElapsedMilliseconds;
Run Code Online (Sandbox Code Playgroud)
因此 BMP 加载大约需要 6 毫秒,PNG 需要 40 毫秒。
为什么会这样?