1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #pragma once |
4 | |
5 | #include "BsFreeImgPrerequisites.h" |
6 | #include "Importer/BsSpecificImporter.h" |
7 | #include "Importer/BsImporter.h" |
8 | |
9 | namespace bs |
10 | { |
11 | /** @addtogroup FreeImg |
12 | * @{ |
13 | */ |
14 | |
15 | /** Importer implementation that handles various import for various image formats using the FreeImg library. */ |
16 | class FreeImgImporter : public SpecificImporter |
17 | { |
18 | struct RawImageData; |
19 | |
20 | public: |
21 | FreeImgImporter(); |
22 | virtual ~FreeImgImporter(); |
23 | |
24 | /** @copydoc SpecificImporter::isExtensionSupported */ |
25 | bool isExtensionSupported(const String& ext) const override; |
26 | |
27 | /** @copydoc SpecificImporter::isMagicNumberSupported */ |
28 | bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const override; |
29 | |
30 | /** @copydoc SpecificImporter::import */ |
31 | SPtr<Resource> import(const Path& filePath, SPtr<const ImportOptions> importOptions) override; |
32 | |
33 | /** @copydoc SpecificImporter::createImportOptions */ |
34 | SPtr<ImportOptions> createImportOptions() const override; |
35 | private: |
36 | /** Converts a magic number into an extension name. */ |
37 | String magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const; |
38 | |
39 | /** Imports an image from the provided data stream. */ |
40 | SPtr<PixelData> importRawImage(const Path& fileData); |
41 | |
42 | /** |
43 | * Generates six cubemap faces from the provided source texture. * |
44 | * |
45 | * @param[in] source Source texture containing the pixels to generate the cubemap from. |
46 | * @param[in] sourceType Type of the source texture, determines how is the data interpreted. |
47 | * @param[out] output Will contain the six cubemap faces, if the method returns true. The faces will be in the |
48 | * same order as presented in the CubemapFace enum. |
49 | * @return True if the cubemap faces were successfully generated, false otherwise. |
50 | */ |
51 | bool generateCubemap(const SPtr<PixelData>& source, CubemapSourceType sourceType, |
52 | std::array<SPtr<PixelData>, 6>& output); |
53 | |
54 | Vector<String> mExtensions; |
55 | UnorderedMap<String, int> mExtensionToFID; |
56 | }; |
57 | |
58 | /** @} */ |
59 | } |