2 * Copyright (C) 2023 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "PictureFolderImageFileLoader.h"
12 #include "FileItemList.h"
14 #include "ServiceBroker.h"
15 #include "TextureCache.h"
16 #include "filesystem/Directory.h"
17 #include "guilib/Texture.h"
18 #include "imagefiles/ImageFileURL.h"
19 #include "playlists/PlayListFileItemClassify.h"
20 #include "settings/Settings.h"
21 #include "settings/SettingsComponent.h"
22 #include "utils/FileExtensionProvider.h"
25 using namespace XFILE
;
27 bool CPictureFolderImageFileLoader::CanLoad(const std::string
& specialType
) const
29 return specialType
== "picturefolder";
32 std::unique_ptr
<CTexture
> CPictureFolderImageFileLoader::Load(
33 const IMAGE_FILES::CImageFileURL
& imageFile
) const
35 CFileItemList imagesInFolder
;
36 CDirectory::GetDirectory(imageFile
.GetTargetFile(), imagesInFolder
,
37 CServiceBroker::GetFileExtensionProvider().GetPictureExtensions(),
38 DIR_FLAG_NO_FILE_DIRS
);
40 for (int i
= 0; i
< imagesInFolder
.Size();)
42 if (!imagesInFolder
[i
]->IsPicture() || imagesInFolder
[i
]->IsZIP() ||
43 imagesInFolder
[i
]->IsRAR() || PLAYLIST::IsPlayList(*imagesInFolder
[i
]))
45 imagesInFolder
.Remove(i
);
50 if (imagesInFolder
.IsEmpty())
55 imagesInFolder
.Randomize();
56 std::vector
<std::string
> imagesToTile
;
57 int size
= std::min(4, imagesInFolder
.Size());
58 imagesToTile
.reserve(size
);
59 for (int thumb
= 0; thumb
< size
; thumb
++)
61 imagesToTile
.push_back(imagesInFolder
[thumb
]->GetPath());
64 return CPicture::CreateTiledThumb(imagesToTile
);