2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "ImageWrapperPrivatePCH.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FImageWrapperBase structors
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
FImageWrapperBase::FImageWrapperBase( )
|
|
|
|
|
: RawFormat(ERGBFormat::Invalid)
|
|
|
|
|
, RawBitDepth(0)
|
|
|
|
|
, Format(ERGBFormat::Invalid)
|
|
|
|
|
, BitDepth(0)
|
|
|
|
|
, Width(0)
|
|
|
|
|
, Height(0)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FImageWrapperBase interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void FImageWrapperBase::Reset( )
|
|
|
|
|
{
|
|
|
|
|
LastError.Empty();
|
|
|
|
|
|
|
|
|
|
RawFormat = ERGBFormat::Invalid;
|
|
|
|
|
RawBitDepth = 0;
|
|
|
|
|
Format = ERGBFormat::Invalid;
|
|
|
|
|
BitDepth = 0;
|
|
|
|
|
Width = 0;
|
|
|
|
|
Height = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FImageWrapperBase::SetError( const TCHAR* ErrorMessage )
|
|
|
|
|
{
|
|
|
|
|
LastError = ErrorMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IImageWrapper structors
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
const TArray<uint8>& FImageWrapperBase::GetCompressed(int32 Quality)
|
|
|
|
|
{
|
|
|
|
|
LastError.Empty();
|
|
|
|
|
Compress(Quality);
|
|
|
|
|
|
|
|
|
|
return CompressedData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool FImageWrapperBase::GetRaw( const ERGBFormat::Type InFormat, int32 InBitDepth, const TArray<uint8>*& OutRawData )
|
|
|
|
|
{
|
|
|
|
|
LastError.Empty();
|
|
|
|
|
Uncompress(InFormat, InBitDepth);
|
|
|
|
|
|
|
|
|
|
if (LastError.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
OutRawData = &RawData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LastError.IsEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool FImageWrapperBase::SetCompressed( const void* InCompressedData, int32 InCompressedSize )
|
|
|
|
|
{
|
2015-03-19 15:02:50 -04:00
|
|
|
if( InCompressedSize > 0 && InCompressedData != nullptr )
|
|
|
|
|
{
|
|
|
|
|
Reset();
|
|
|
|
|
RawData.Empty(); // Invalidates the raw data too
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-03-19 15:02:50 -04:00
|
|
|
CompressedData.Empty(InCompressedSize);
|
|
|
|
|
CompressedData.AddUninitialized(InCompressedSize);
|
|
|
|
|
FMemory::Memcpy(CompressedData.GetData(), InCompressedData, InCompressedSize);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-03-19 15:02:50 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-03-19 15:02:50 -04:00
|
|
|
return false;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
bool FImageWrapperBase::SetRaw( const void* InRawData, int32 InRawSize, const int32 InWidth, const int32 InHeight, const ERGBFormat::Type InFormat, const int32 InBitDepth )
|
|
|
|
|
{
|
|
|
|
|
check(InRawData != NULL);
|
|
|
|
|
check(InRawSize > 0);
|
|
|
|
|
check(InWidth > 0);
|
|
|
|
|
check(InHeight > 0);
|
|
|
|
|
|
|
|
|
|
Reset();
|
|
|
|
|
CompressedData.Empty(); // Invalidates the compressed data too
|
|
|
|
|
|
|
|
|
|
RawData.Empty(InRawSize);
|
|
|
|
|
RawData.AddUninitialized(InRawSize);
|
2014-09-29 04:23:44 -04:00
|
|
|
FMemory::Memcpy(RawData.GetData(), InRawData, InRawSize);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
RawFormat = InFormat;
|
|
|
|
|
RawBitDepth = InBitDepth;
|
|
|
|
|
|
|
|
|
|
Width = InWidth;
|
|
|
|
|
Height = InHeight;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|