Skip to content

Commit

Permalink
Merge pull request #1996 from alcomposer/better-thumb-find
Browse files Browse the repository at this point in the history
Use findFiles to return _thumb images associated with the patch file
  • Loading branch information
timothyschoen authored Dec 3, 2024
2 parents 3e93be7 + 8d86405 commit 8a7119e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Source/Components/WelcomePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,19 +822,17 @@ class WelcomePanel : public Component
libraryTiles.clear();

auto addTile = [this](File& patchFile){
auto patchThumbnailBase = File(patchFile.getParentDirectory().getFullPathName() + "\\" + patchFile.getFileNameWithoutExtension() + "_thumb");
StringArray possibleExtensions { ".png", ".jpg", ".jpeg", ".gif" };
auto pName = patchFile.getFileNameWithoutExtension();
auto foundThumbs = patchFile.getParentDirectory().findChildFiles(File::findFiles, true, pName + "_thumb.png;" + pName + "_thumb.jpg;" + pName + "_thumb.jpeg;" + pName + "_thumb.gif");

float scale = 1.0f;
Image thumbImage;
for (auto& ext : possibleExtensions) {
auto patchThumbnail = patchThumbnailBase.withFileExtension(ext);
if (patchThumbnail.existsAsFile()) {
FileInputStream fileStream(patchThumbnail);
if (fileStream.openedOk()) {
thumbImage = ImageFileFormat::loadFrom(fileStream).convertedToFormat(Image::ARGB);
for (auto& thumb: foundThumbs) {
FileInputStream fileStream(thumb);
if (fileStream.openedOk()) {
thumbImage = ImageFileFormat::loadFrom(fileStream).convertedToFormat(Image::ARGB);
if (thumbImage.isValid())
break;
}
}
}
String placeholderIcon;
Expand Down

0 comments on commit 8a7119e

Please sign in to comment.