Download

TSharedPtr<IImageWrapper->GetRaw() problem! Unreal 4.25

Unreal Engine 4.25

I’m getting this compile error:



error C2664: 'bool IImageWrapper::GetRaw(const ERGBFormat,int32,TArray<uint8,FDefaultAllocator> &)': cannot convert argument 3 from 'const TArray<uint8,FDefaultAllocator> *' to 'TArray<uint8,FDefaultAllocator64> &'


I noticed there is an overloaded function for GetRaw built in to the engine that makes it either look for a TArray OR a TArray64

And for the life of me I can’t get this to compile. I’ve tried using TArray64 for “BinaryArray” and “RawData” variables, but it still compiled with the same error…

What am I missing about this?.. Most likely I don’t understand something, but I also wonder if this is a bug/issue with 4.25…



UE_LOG(LogTemp, Log, TEXT("Try to load a png!"));

FString PngFile = FString(TEXT("C:/Users/dev/Desktop/BRYAN_TEST/cat.png"));
IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
//IImageWrapperPtr PNGImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
//^^^ Noticed this was depreciated! It suggested using the next line instead.
TSharedPtr<IImageWrapper> PNGImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
TArray<uint8> BinaryArray;

if(FFileHelper::LoadFileToArray(BinaryArray, *PngFile))
{
UE_LOG(LogTemp, Log, TEXT("LoadFileToArray() success"));

if(PNGImageWrapper.IsValid())
{
UE_LOG(LogTemp, Log, TEXT("its valid, keep going"));
const TArray<uint8>* RawData = NULL;

if(PNGImageWrapper->GetRaw(ERGBFormat::BGRA, 8, RawData))
{
UE_LOG(LogTemp, Log, TEXT("GetRaw success keep going"));
}
}

}


if I comment out the GetRaw() line and the whole if statement my UE_LOG shows:



Try to load a png!
LogTemp: LoadFileToArray() success
LogTemp: its valid, keep going


Alternatively I might be missing something dumb with pointer/address stuff when passing this in? But it is strange that it’s getting confused about what type of argument it is with that overload funciton situation.

Look at the declaration of your third parameter:


const TArray<uint8>* RawData

Reading it from right to left: RawData is a pointer to a TArray of uint8 that is constant.

bool IImageWrapper::GetRaw()'s third parameter is a reference. Drop that * from RawData’s declaration, and probably the const, as well.

Thanks! I had to remove const and * for it to compile but it does indeed compile now. Got to go deeper into some c++ tutorials on lynda.com to better understand pointers, refs, polymorphism… still learning, thanks a lot!

Not a problem. We all gotta start somewhere. Glad you’re back on track.