Found it
when you convert base64 data image is a byte array containing the JPG OR PNG FORMAT is not a FColor array.
you can create an texture directly by using :
FImageUtils::ImportBufferAsTexture2D(BGRA8PixelData);
and also you need send only the base64 data , so you need to extract data:image/png;base64,
UTexture2D* ATcpSocketConnection::Base64_ToImage(FString Source)
{
TArray<uint8> data_buffer;
FString Left, Right;
// you need to remove Data:image....,
Source.Split(TEXT(","),&Left,&Right);
if (Right == "") return nullptr;
bool isDecode = FBase64::Decode(Right, data_buffer);
if (isDecode) {
return CreateBitTextureAtRuntime(data_buffer);
}
else {
return nullptr;
}
}
UTexture2D* ATcpSocketConnection::CreateBitTextureAtRuntime(TArray<uint8> BGRA8PixelData)
{
UTexture2D * Texture = FImageUtils::ImportBufferAsTexture2D(BGRA8PixelData);
Texture->MipGenSettings = TMGS_NoMipmaps;
Texture->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
Texture->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
Texture->SRGB = false;
Texture->Filter = TextureFilter::TF_Nearest;
Texture->UpdateResource();
return Texture;
}
hope it’s help
Have a nice day
Daniel