Loading Texture From File At Runtime Not Working Correctly

I’m loading a texture2d from file using IImageWrapper but the loaded texture is always a single flat color. Is there anything that would cause this? I would really appreciate some help with this.
I’m using pretty much the same code as in Rama’s victory BP

ImageLoader::ImageLoader()
{
TArray RawFileData;
FString NewPath=FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
NewPath+=“bitmapImage.bmp”;
std::string newstring=TCHAR_TO_UTF8(*NewPath);
std::ifstream inputFile(newstring);
FString HappyString(newstring.c_str()); //this is the full path

IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
// Note: PNG format.  Other formats are supported
TSharedPtr<IImageWrapper> ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::BMP);

if (FFileHelper::LoadFileToArray(RawFileData, *HappyString))
{
    if (ImageWrapper.IsValid() && ImageWrapper->SetCompressed(RawFileData.GetData(), RawFileData.Num()))
    {
        const TArray<uint8>* UncompressedBGRA = NULL;
        if (ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, UncompressedBGRA))
        {
            mytex = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), PF_B8G8R8A8);
            GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::FromInt(RawFileData.Num()));
            //oh yes, you need copy the loaded data onto texture:
            //mytex->MipGenSettings = TMGS_NoMipmaps;
            void* TextureData = mytex->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
            FMemory::Memcpy(TextureData, UncompressedBGRA->GetData(), UncompressedBGRA->Num());
            mytex->PlatformData->Mips[0].BulkData.Unlock();
            
            // Update the rendering resource from data.
            mytex->UpdateResource();
        }
    }
}

}

So I just tested the function on 4.15 and it works flawlessly, this is really irritating. At least now I know the reason it’s not working is because I’ve “upgraded” to 4.18. Would really like a better reason.

I use the exact same code as you, except line 3 which reads:
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::JPEG);
This works in 4.20.1, i.e. it loads my image from file and puts it into the texture. But I get a warning in the compile log:
“…warning C4996: ‘IImageWrapperPtr’: IImageWrapperPtr is deprecated. Please use ‘TSharedPtr’ instead!”
I came here because I googled TSharedPtr. Probably you are using it wrong somehow.

I did manage to get it working in 4.20, as far as I can tell the code is exactly the same. No idea why it wouldn’t work in 4.18.