// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreTypes.h" #include "Containers/Array.h" #include "Containers/EnumAsByte.h" #include "Containers/UnrealString.h" #include "IImageWrapper.h" /** * The abstract helper class for handling the different image formats */ class FImageWrapperBase : public IImageWrapper { public: /** Default Constructor. */ FImageWrapperBase(); public: /** * Gets the image's raw data. * * @return A read-only byte array containing the data. */ const TArray64& GetRawData() const { return RawData; } /** * Moves the image's raw data into the provided array. * * @param OutRawData The destination array. */ void MoveRawData(TArray64& OutRawData) { OutRawData = MoveTemp(RawData); } public: /** * Compresses the data. * * @param Quality The compression quality. * * returns void. call SetError() in your implementation if you fail. */ virtual void Compress(int32 Quality) = 0; /** * Resets the local variables. */ virtual void Reset(); /** * Sets last error message. * * @param ErrorMessage The error message to set. */ void SetError(const TCHAR* ErrorMessage); /** * Function to uncompress our data * * @param InFormat How we want to manipulate the RGB data * * returns void. call SetError() in your implementation if you fail. */ virtual void Uncompress(const ERGBFormat InFormat, int32 InBitDepth) = 0; public: //~ IImageWrapper interface virtual TArray64 GetCompressed(int32 Quality = 0) override; virtual int32 GetBitDepth() const override { return BitDepth; } virtual ERGBFormat GetFormat() const override { return Format; } virtual int32 GetHeight() const override { return Height; } virtual bool GetRaw(const ERGBFormat InFormat, int32 InBitDepth, TArray64& OutRawData) override; virtual int32 GetWidth() const override { return Width; } virtual bool SetCompressed(const void* InCompressedData, int64 InCompressedSize) override; virtual bool SetRaw(const void* InRawData, int64 InRawSize, const int32 InWidth, const int32 InHeight, const ERGBFormat InFormat, const int32 InBitDepth, const int32 InBytesPerRow = 0) override; protected: int GetBytesPerPel() const { return GetRGBFormatBytesPerPel(Format,BitDepth); } int GetBytesPerRow() const { return Width * GetBytesPerPel(); } /** Arrays of compressed/raw data */ TArray64 RawData; TArray64 CompressedData; /** Format of the raw data */ ERGBFormat Format; int BitDepth; /** Width/Height of the image data */ int32 Width; int32 Height; /** Last Error Message. */ FString LastError; };