MSW/GteWICFileIO.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <Graphics/GteTexture2.h>
11 #include <guiddef.h>
12 #include <memory>
13 
14 namespace gte
15 {
16 
17 class GTE_IMPEXP WICFileIO
18 {
19 public:
20  // Support for loading from BMP, GIF, ICON, JPEG, PNG, and TIFF.
21  // The returned texture has a format that matches as close as possible
22  // the format on disk. If the load is not successful, the function
23  // returns a null object.
24  static std::shared_ptr<Texture2> Load(std::string const& filename,
25  bool wantMipmaps);
26 
27  // Support for saving to PNG format. Currently, the only formats
28  // supported are R8G8B8A8 and R16.
29  static bool SaveToPNG(std::string const& filename,
30  std::shared_ptr<Texture2> const& texture);
31 
32  // Support for saving to JPEG format. Currently, the only formats
33  // supported are R8G8B8A8 and R16. The image quality is in [0,1], where
34  // a value of 0 indicates lowest quality (largest amount of compression)
35  // and a value of 1 indicates highest quality (smallest amount of
36  // compression).
37  static bool SaveToJPEG(std::string const& filename,
38  std::shared_ptr<Texture2> const& texture, float imageQuality);
39 
40 private:
42  {
43  public:
44  ~ComInitializer();
46  bool IsInitialized() const;
47  private:
49  };
50 
51  template <typename T>
52  class ComObject
53  {
54  public:
55  ComObject();
56  ComObject(T* inObject);
57  ~ComObject();
58  operator T*() const;
59  T& operator*() const;
60  T** operator&();
61  T* operator->() const;
62  private:
63  T* object;
64  };
65 
67  {
68  DFType gtFormat;
69  GUID const* wicInputGUID;
70  GUID const* wicConvertGUID;
71  };
72  enum { NUM_LOAD_FORMATS = 14 };
73  static LoadFormatMap const msLoadFormatMap[NUM_LOAD_FORMATS];
74 
76  {
77  DFType gtFormat;
78  GUID const* wicOutputGUID;
79  };
80  enum { NUM_SAVE_FORMATS = 11 };
81  static SaveFormatMap const msSaveFormatMap[NUM_SAVE_FORMATS];
82 
83  // Helper function to share code between saving PNG and JPEG. Set
84  // imageQuality to -1.0f for PNG. Set it to a number in [0,1] for
85  // JPEG.
86  static bool SaveTo(std::string const& filename,
87  std::shared_ptr<Texture2> const& texture, float imageQuality);
88 };
89 
90 }
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
GLuint texture
Definition: glcorearb.h:410
Vector4< float > operator*(Transform const &M, Vector4< float > const &V)
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02