You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
100 lines
2.7 KiB
C++
100 lines
2.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "IcnsImageWrapper.h"
|
|
|
|
|
|
/* FIcnsImageWrapper structors
|
|
*****************************************************************************/
|
|
|
|
FIcnsImageWrapper::FIcnsImageWrapper()
|
|
: FImageWrapperBase()
|
|
{ }
|
|
|
|
|
|
/* FImageWrapper interface
|
|
*****************************************************************************/
|
|
|
|
bool FIcnsImageWrapper::SetCompressed(const void* InCompressedData, int64 InCompressedSize)
|
|
{
|
|
#if PLATFORM_MAC
|
|
return FImageWrapperBase::SetCompressed(InCompressedData, InCompressedSize);
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
|
|
// CanSetRawFormat returns true if SetRaw will accept this format
|
|
bool FIcnsImageWrapper::CanSetRawFormat(const ERGBFormat InFormat, const int32 InBitDepth) const
|
|
{
|
|
//checkf(false, TEXT("ICNS compression not supported"));
|
|
return false;
|
|
}
|
|
|
|
// returns InFormat if supported, else maps to something supported
|
|
ERawImageFormat::Type FIcnsImageWrapper::GetSupportedRawFormat(const ERawImageFormat::Type InFormat) const
|
|
{
|
|
//checkf(false, TEXT("ICNS compression not supported"));
|
|
return ERawImageFormat::BGRA8;
|
|
}
|
|
|
|
bool FIcnsImageWrapper::SetRaw(const void* InRawData, int64 InRawSize, const int32 InWidth, const int32 InHeight, const ERGBFormat InFormat, const int32 InBitDepth, const int32 InBytesPerRow)
|
|
{
|
|
// Only support tightly packed
|
|
check(InBytesPerRow == 0);
|
|
|
|
#if PLATFORM_MAC
|
|
return FImageWrapperBase::SetRaw(InRawData, InRawSize, InWidth, InHeight, InFormat, InBitDepth, InBytesPerRow);
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
|
|
void FIcnsImageWrapper::Compress(int32 Quality)
|
|
{
|
|
checkf(false, TEXT("ICNS compression not supported"));
|
|
}
|
|
|
|
|
|
void FIcnsImageWrapper::Uncompress(const ERGBFormat InFormat, const int32 InBitDepth)
|
|
{
|
|
#if PLATFORM_MAC
|
|
SCOPED_AUTORELEASE_POOL;
|
|
|
|
NSData* ImageData = [NSData dataWithBytesNoCopy:CompressedData.GetData() length:CompressedData.Num() freeWhenDone:NO];
|
|
NSImage* Image = [[NSImage alloc] initWithData:ImageData];
|
|
if (Image)
|
|
{
|
|
NSBitmapImageRep* Bitmap = [NSBitmapImageRep imageRepWithData:[Image TIFFRepresentation]];
|
|
if (Bitmap)
|
|
{
|
|
check(InFormat == ERGBFormat::BGRA || InFormat == ERGBFormat::RGBA);
|
|
check(InBitDepth == 8);
|
|
|
|
RawData.Empty();
|
|
RawData.Append([Bitmap bitmapData], [Bitmap bytesPerPlane]);
|
|
|
|
Format = InFormat;
|
|
BitDepth = InBitDepth;
|
|
|
|
Width = [Bitmap pixelsWide];
|
|
Height = [Bitmap pixelsHigh];
|
|
|
|
if (Format == ERGBFormat::BGRA)
|
|
{
|
|
for (int64 Index = 0; Index < [Bitmap bytesPerPlane]; Index += 4)
|
|
{
|
|
uint8 Byte = RawData[Index];
|
|
RawData[Index] = RawData[Index + 2];
|
|
RawData[Index + 2] = Byte;
|
|
}
|
|
}
|
|
}
|
|
[Image release];
|
|
}
|
|
#else
|
|
checkf(false, TEXT("ICNS uncompressing not supported on this platform"));
|
|
#endif
|
|
}
|