You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Minor change to FImageWrapperBase. GetRaw and GetCompressed now consume the array with the same name instead of having to do a copy of it. I changed the api IImageWrapper::GetCompressed to return a TArray64<uint8> instead of returning a const TArray64<uint8>&. Added the format RGBAF to the struct ERGBFormat. Changed the engine code using the EXR image wrapper to reflect that. The EXR image wrapper now avoid doing an unessary copy of the compressed image when calling compress. Improvement to the performence of the function UTextureFactory::ImportImage. We now use the magic bytes of the file for certains format to skip some tests. Here is some performance metrics I captured on my desktop (6 core, 12 threads XEON) Importing a folder of tiff files (22 files, 4.16 GB Total) Before: 66.152738 seconds After: 43.609245 seconds #jira UEENT-3822 #rb Alexis.Matte [CL 16128765 by Julien StJean in ue5-main branch]
142 lines
2.7 KiB
C++
142 lines
2.7 KiB
C++
// 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<uint8>& GetRawData() const
|
|
{
|
|
return RawData;
|
|
}
|
|
|
|
/**
|
|
* Moves the image's raw data into the provided array.
|
|
*
|
|
* @param OutRawData The destination array.
|
|
*/
|
|
void MoveRawData(TArray64<uint8>& OutRawData)
|
|
{
|
|
OutRawData = MoveTemp(RawData);
|
|
}
|
|
|
|
public:
|
|
|
|
/**
|
|
* Compresses the data.
|
|
*
|
|
* @param Quality The compression quality.
|
|
*/
|
|
virtual void Compress(int32 Quality) = 0;
|
|
|
|
/**
|
|
* Resets the local variables.
|
|
*/
|
|
virtual void Reset();
|
|
|
|
/**
|
|
* Sets last error message.
|
|
*
|
|
* @param ErrorMessage The error message to set.
|
|
*/
|
|
virtual void SetError(const TCHAR* ErrorMessage);
|
|
|
|
/**
|
|
* Function to uncompress our data
|
|
*
|
|
* @param InFormat How we want to manipulate the RGB data
|
|
*/
|
|
virtual void Uncompress(const ERGBFormat InFormat, int32 InBitDepth) = 0;
|
|
|
|
public:
|
|
|
|
//~ IImageWrapper interface
|
|
|
|
virtual TArray64<uint8> 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<uint8>& OutRawData) override;
|
|
|
|
virtual int32 GetWidth() const override
|
|
{
|
|
return Width;
|
|
}
|
|
|
|
virtual int32 GetNumFrames() const override
|
|
{
|
|
return NumFrames;
|
|
}
|
|
|
|
virtual int32 GetFramerate() const override
|
|
{
|
|
return Framerate;
|
|
}
|
|
|
|
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) override;
|
|
virtual bool SetAnimationInfo(int32 InNumFrames, int32 InFramerate) override;
|
|
|
|
protected:
|
|
|
|
/** Arrays of compressed/raw data */
|
|
TArray64<uint8> RawData;
|
|
TArray64<uint8> CompressedData;
|
|
|
|
/** Format of the raw data */
|
|
ERGBFormat RawFormat;
|
|
int8 RawBitDepth;
|
|
|
|
/** Format of the image */
|
|
ERGBFormat Format;
|
|
|
|
/** Bit depth of the image */
|
|
int8 BitDepth;
|
|
|
|
/** Width/Height of the image data */
|
|
int32 Width;
|
|
int32 Height;
|
|
|
|
/** Animation information */
|
|
int32 NumFrames;
|
|
int32 Framerate;
|
|
|
|
/** Last Error Message. */
|
|
FString LastError;
|
|
};
|