ezEngine  Milestone 7
ImageConversion.h
1 #pragma once
2 
5 #include <Foundation/Containers/StaticArray.h>
6 
7 #include <CoreUtils/Image/Image.h>
8 
9 EZ_DECLARE_FLAGS(ezUInt8, ezImageConversionFlags, None, InPlace, Lossy);
10 
12 class EZ_COREUTILS_DLL ezImageConversionBase : public ezEnumerable<ezImageConversionBase>
13 {
14 public:
16  static ezImageFormat::Enum
17  FindClosestCompatibleFormat(ezImageFormat::Enum format, const ezImageFormat::Enum* pCompatibleFormats, ezUInt32 uiNumCompatible);
18 
20  template<int N> static ezImageFormat::Enum
21  FindClosestCompatibleFormat(ezImageFormat::Enum format, const ezImageFormat::Enum(&compatibleFormats)[N])
22  {
23  return FindClosestCompatibleFormat(format, compatibleFormats, N);
24  }
25 
26  static ezResult Convert(const ezImage& source, ezImage& target, ezImageFormat::Enum targetFormat);
27 
29 
30 protected:
32  virtual ~ezImageConversionBase();
33 
34  virtual ezResult DoConvert(const ezImage& source, ezImage& target, ezImageFormat::Enum targetFormat) const = 0;
35 
37  {
39  {
40  m_sourceFormat = ezImageFormat::UNKNOWN;
41  m_targetFormat = ezImageFormat::UNKNOWN;
42  m_flags = ezImageConversionFlags::None;
43  }
44 
46  {
47  m_sourceFormat = source;
48  m_targetFormat = target;
49  m_flags = flags;
50  }
51 
52  ezImageFormat::Enum m_sourceFormat;
53  ezImageFormat::Enum m_targetFormat;
55  };
56 
57  ezStaticArray<SubConversion, 16> m_subConversions;
58 
59 private:
60  static void RebuildConversionTable();
61 };