]>
git.saurik.com Git - wxWidgets.git/blob - tests/benchmarks/image.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tests/benchmarks/image.cpp
3 // Purpose: wxImage benchmarks
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
14 BENCHMARK_FUNC(LoadBMP
)
17 return image
.LoadFile("horse.bmp");
20 BENCHMARK_FUNC(LoadJPEG
)
22 static bool s_handlerAdded
= false;
23 if ( !s_handlerAdded
)
25 s_handlerAdded
= true;
26 wxImage::AddHandler(new wxJPEGHandler
);
30 return image
.LoadFile("horse.jpg");
33 BENCHMARK_FUNC(LoadPNG
)
35 static bool s_handlerAdded
= false;
36 if ( !s_handlerAdded
)
38 s_handlerAdded
= true;
39 wxImage::AddHandler(new wxPNGHandler
);
43 return image
.LoadFile("horse.png");
46 BENCHMARK_FUNC(LoadTIFF
)
48 static bool s_handlerAdded
= false;
49 if ( !s_handlerAdded
)
51 s_handlerAdded
= true;
52 wxImage::AddHandler(new wxTIFFHandler
);
56 return image
.LoadFile("horse.tif");
59 static const wxImage
& GetTestImage()
61 static wxImage s_image
;
62 static bool s_triedToLoad
= false;
66 s_image
.LoadFile("horse.bmp");
72 BENCHMARK_FUNC(EnlargeNormal
)
74 return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_NORMAL
).IsOk();
77 BENCHMARK_FUNC(EnlargeHighQuality
)
79 return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_HIGH
).IsOk();
82 BENCHMARK_FUNC(ShrinkNormal
)
84 return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_NORMAL
).IsOk();
87 BENCHMARK_FUNC(ShrinkHighQuality
)
89 return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_HIGH
).IsOk();