MCPcopy Create free account
hub / github.com/dfranx/ImFileDialog / m_loadPreview

Method m_loadPreview

ImFileDialog.cpp:878–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876 }
877 }
878 void FileDialog::m_loadPreview()
879 {
880 for (size_t i = 0; m_previewLoaderRunning && i < m_content.size(); i++) {
881 auto& data = m_content[i];
882
883 if (data.HasIconPreview)
884 continue;
885
886 if (data.Path.has_extension()) {
887 std::string ext = data.Path.extension().u8string();
888 if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".tga") {
889 int width, height, nrChannels;
890 unsigned char* image = stbi_load(data.Path.u8string().c_str(), &width, &height, &nrChannels, STBI_rgb_alpha);
891
892 if (image == nullptr || width == 0 || height == 0)
893 continue;
894
895 data.HasIconPreview = true;
896 data.IconPreviewData = image;
897 data.IconPreviewWidth = width;
898 data.IconPreviewHeight = height;
899 }
900 }
901 }
902
903 m_previewLoaderRunning = false;
904 }
905 void FileDialog::m_clearTree(FileTreeNode* node)
906 {
907 if (node == nullptr)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected