ezEngine  Milestone 7
Image.h
1 #pragma once
2 
3 #include <Foundation/Containers/DynamicArray.h>
4 #include <Foundation/Containers/HybridArray.h>
5 #include <Foundation/Logging/Log.h>
6 
7 #include <CoreUtils/Image/Implementation/ImageHeader.h>
8 
17 class EZ_COREUTILS_DLL ezImage : public ezImageHeader
18 {
19 public:
21  inline ezImage();
22 
24  ezResult LoadFrom(const char* szFileName, ezLogInterface* pLog = ezGlobalLog::GetInstance());
25 
27  ezResult SaveTo(const char* szFileName, ezLogInterface* pLog = ezGlobalLog::GetInstance());
28 
32  inline ezUInt32 GetNumBlocksX(ezUInt32 uiMipLevel = 0) const;
33 
37  inline ezUInt32 GetNumBlocksY(ezUInt32 uiMipLevel = 0) const;
38 
39 
44  inline ezUInt32 GetDataSize() const;
45 
47  template<typename T>
48  T* GetDataPointer();
49 
51  template<typename T>
52  const T* GetDataPointer() const;
53 
55  template<typename T>
56  const T* GetSubImagePointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0) const;
57 
59  template<typename T>
60  T* GetSubImagePointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0);
61 
65  template<typename T>
66  const T* GetPixelPointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0, ezUInt32 x = 0, ezUInt32 y = 0, ezUInt32 z = 0) const;
67 
71  template<typename T>
72  T* GetPixelPointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0, ezUInt32 x = 0, ezUInt32 y = 0, ezUInt32 z = 0);
73 
77  template<typename T>
78  const T* GetBlockPointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0, ezUInt32 uiBlockX = 0, ezUInt32 uiBlockY = 0, ezUInt32 z = 0) const;
79 
83  template<typename T>
84  T* GetBlockPointer(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0, ezUInt32 uiBlockX = 0, ezUInt32 uiBlockY = 0, ezUInt32 z = 0);
85 
90  void AllocateImageData();
91 
95  inline ezUInt32 GetRowPitch(ezUInt32 uiMipLevel = 0) const;
96 
98  inline ezUInt32 GetDepthPitch(ezUInt32 uiMipLevel = 0) const;
99 
101  inline ezUInt32 GetDataOffSet(ezUInt32 uiMipLevel = 0, ezUInt32 uiFace = 0, ezUInt32 uiArrayIndex = 0) const;
102 
103 private:
104  struct SubImage
105  {
107 
108  int m_uiRowPitch;
109  int m_uiDepthPitch;
110  int m_uiDataOffset;
111  };
112 
113  inline void ValidateSubImageIndices(ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const;
114 
115  inline SubImage& GetSubImage(ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex);
116 
117  inline const SubImage& GetSubImage(ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const;
118 
119  ezHybridArray<SubImage, 16> m_subImages;
121 };
122 
123 #include <CoreUtils/Image/Implementation/Image_inl.h>