File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 3737#include " private/lv_video_bmp.hpp"
3838#include " private/lv_video_png.hpp"
3939#include < cstring>
40- #include < iostream>
41- #include < fstream>
4240#include < filesystem>
41+ #include < fstream>
42+ #include < functional>
43+ #include < unordered_map>
4344
4445namespace LV {
4546
4647 namespace fs = std::filesystem;
4748
4849 namespace {
4950
51+ using BitmapLoad = std::function<VideoPtr (std::istream&)>;
52+ std::unordered_map<std::string, BitmapLoad> const bitmap_load_map =
53+ {
54+ { " bmp" , bitmap_load_bmp },
55+ { " png" , bitmap_load_png }
56+ };
57+
5058 bool is_valid_scale_method (VisVideoScaleMethod scale_method)
5159 {
5260 return scale_method == VISUAL_VIDEO_SCALE_NEAREST
@@ -195,17 +203,14 @@ namespace LV {
195203
196204 VideoPtr Video::create_from_stream (std::istream& input)
197205 {
198- auto image = bitmap_load_bmp (input);
199- if (image) {
200- return image;
201- }
202-
203- image = bitmap_load_png (input);
204- if (image) {
205- return image;
206+ for (auto entry : bitmap_load_map) {
207+ auto image {entry.second (input)};
208+ if (image) {
209+ return image;
210+ }
206211 }
207212
208- return {} ;
213+ return nullptr ;
209214 }
210215
211216 VideoPtr Video::create_scale_depth (VideoConstPtr const & src,
You can’t perform that action at this time.
0 commit comments