ochess/src/binres/binres.cpp

32 lines
975 B
C++
Raw Normal View History

2022-02-23 18:11:55 +01:00
#include "binres.hpp"
2023-06-03 15:44:46 +02:00
#include <unordered_map>
2022-02-23 18:11:55 +01:00
// Embedded binary data (e.g: PGNs icons):
#include "binary_data.hpp"
2023-05-10 10:49:31 +02:00
2022-02-23 18:11:55 +01:00
wxBitmap LoadPNG(std::string icon, wxSize size) {
wxImage img = LoadPNG(icon).ConvertToImage();
return (wxBitmap(
img.Scale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH)));
}
wxBitmap LoadPNG(std::string icon) {
2023-06-03 15:44:46 +02:00
std::unordered_map<std::string, wxBitmap> u = {
{"ui_zoom_in", wxBITMAP_PNG_FROM_DATA(ui_zoom_in)},
{"ui_zoom_out", wxBITMAP_PNG_FROM_DATA(ui_zoom_out)},
{"ui_coins_swap", wxBITMAP_PNG_FROM_DATA(ui_coins_swap)},
{"ui_eye_close", wxBITMAP_PNG_FROM_DATA(ui_eye_close)},
{"mat", wxBITMAP_PNG_FROM_DATA(mat)},
{"ochess", wxBITMAP_PNG_FROM_DATA(ochess)},
{"cburnett", wxBITMAP_PNG_FROM_DATA(cburnett)},
{"chesscom_8bits", wxBITMAP_PNG_FROM_DATA(chesscom_8bits)}
};
// Return png if exists
if(u.count(icon)){
return u[icon];
2022-02-23 18:11:55 +01:00
}
2023-06-03 15:44:46 +02:00
// Otherwise null bitmap
2022-02-23 18:11:55 +01:00
return (wxNullBitmap);
2023-01-16 14:55:48 +01:00
}