diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-04-03 03:52:16 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-04-03 03:52:16 +0000 |
| commit | e7b12030bd0f8084432a7c38d6f48d57f0bc9684 (patch) | |
| tree | 765043aeff0fe359566abb2384f86ce46935ac7e /TextureLoader/interface | |
| parent | Implemented encoding image as jpeg (diff) | |
| download | DiligentTools-e7b12030bd0f8084432a7c38d6f48d57f0bc9684.tar.gz DiligentTools-e7b12030bd0f8084432a7c38d6f48d57f0bc9684.zip | |
Added options to capture RGB vs RGBA when encoding image as png plus some format conversions
Diffstat (limited to 'TextureLoader/interface')
| -rw-r--r-- | TextureLoader/interface/Image.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/TextureLoader/interface/Image.h b/TextureLoader/interface/Image.h index 0f614a6..8ceca41 100644 --- a/TextureLoader/interface/Image.h +++ b/TextureLoader/interface/Image.h @@ -23,6 +23,8 @@ #pragma once +#include <vector> + #include "../../../DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" #include "../../../DiligentCore/Primitives/interface/FileStream.h" #include "../../../DiligentCore/Primitives/interface/DataBlob.h" @@ -89,14 +91,18 @@ namespace Diligent const ImageLoadInfo& LoadInfo, Image **ppImage); - static void Encode(Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT TexFormat, - const void* pData, - Uint32 Stride, - EImageFileFormat FileFormat, - int JpegQuality, - IDataBlob** ppEncodedData); + struct EncodeInfo + { + Uint32 Width = 0; + Uint32 Height = 0; + TEXTURE_FORMAT TexFormat = TEX_FORMAT_UNKNOWN; + bool KeepAlpha = false; + const void* pData = nullptr; + Uint32 Stride = 0; + EImageFileFormat FileFormat = EImageFileFormat::jpeg; + int JpegQuality = 95; + }; + static void Encode(const EncodeInfo& Info, IDataBlob** ppEncodedData); /// Returns image description const ImageDesc &GetDesc(){ return m_Desc; } @@ -104,6 +110,14 @@ namespace Diligent /// Returns a pointer to the image data IDataBlob *GetData(){ return m_pData; } + static std::vector<Uint8> ConvertImageData(Uint32 Width, + Uint32 Height, + const Uint8* pData, + Uint32 Stride, + TEXTURE_FORMAT SrcFormat, + TEXTURE_FORMAT DstFormat, + bool KeepAlpha); + private: template<typename AllocatorType, typename ObjectType> friend class MakeNewRCObj; |
