HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StbImageLoader.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_STBIMAGELOADER_H
7 #define MATERIALX_STBIMAGELOADER_H
8 
9 /// @file
10 /// Image loader using the stb image library
11 
13 
15 
16 /// Shared pointer to an StbImageLoader
17 using StbImageLoaderPtr = std::shared_ptr<class StbImageLoader>;
18 
19 /// @class StbImageLoader
20 /// Stb image file loader
22 {
23  public:
25  {
26  // Set all extensions supported by stb image
27  _extensions.insert(BMP_EXTENSION);
28  _extensions.insert(GIF_EXTENSION);
29  _extensions.insert(HDR_EXTENSION);
30  _extensions.insert(JPG_EXTENSION);
31  _extensions.insert(JPEG_EXTENSION);
32  _extensions.insert(PIC_EXTENSION);
33  _extensions.insert(PNG_EXTENSION);
34  _extensions.insert(PSD_EXTENSION);
35  _extensions.insert(TGA_EXTENSION);
36  }
37  virtual ~StbImageLoader() { }
38 
39  /// Create a new stb image loader
40  static StbImageLoaderPtr create() { return std::make_shared<StbImageLoader>(); }
41 
42  /// Save an image to the file system.
43  bool saveImage(const FilePath& filePath,
45  bool verticalFlip = false) override;
46 
47  /// Load an image from the file system.
48  ImagePtr loadImage(const FilePath& filePath) override;
49 };
50 
52 
53 #endif
virtual bool saveImage(const FilePath &filePath, ConstImagePtr image, bool verticalFlip=false)
Definition: File.h:26
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
std::shared_ptr< class StbImageLoader > StbImageLoaderPtr
Shared pointer to an StbImageLoader.
GLenum GLenum GLsizei void * image
Definition: glad.h:5132
virtual ~StbImageLoader()
#define MX_RENDER_API
Definition: Export.h:18
virtual ImagePtr loadImage(const FilePath &filePath)
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
Definition: Image.h:26
static StbImageLoaderPtr create()
Create a new stb image loader.