I want to use the build in image wrapper to import images from local disk so I can work on them with code (pixel manipulation and reading)
This is the image wrapper.
IImageWrapper | Unreal Engine Documentation
I’m confused about some of it’s usage.
What class should I be using it with, a UClass object or an Actor Class ?
The documentation is also very bad and does not give anything, like how to set a filepath to local disk with an FString.
I managed to compile but I get no results with the Actor class, where does the image load ? is it in the memory buffer ? There is no documentation at all.
I did manage to find some examples but only one of these examples showed how to make a path to local disk, the rest of the examples have the FString Image FIle Variable that get’s tossed around but I’m looking how to set a path and these tutorials of the forum and answer hub don’t have a link like object to local disk, like FString ImageFile = “C:/someimage.png” and there is no documentation on it, it’s a nightmare to use this wrapper, I’m stuck on it for days.
So what class should I use with it, how to set file path to it, and where to check for the image after loading into the arrays, get it out of the array uncompressed and set it’s with and height and then look where for it ? There is also a version where you can convert it to 2dtexture after you set it’s uncompressed properties. So where does the 2dtexture end up ? where to look for it, how to access it.
Here is one example that I did and I managed to compile in an actor class.
Link to source on asnwer hub:
AnswerHub (unrealengine.com)]
(Is it possible to load bitmap or JPG files at runtime and use them on assets as textures? - Rendering - Epic Developer Community Forums)
…
FString pngfile = "myimage.png";
IImageWrapperModule& ImageWrapperModule =
FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
// Note: PNG format. Other formats are supported
IImageWrapperPtr ImageWrapper =
ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
if (FFileHelper::LoadFileToArray(RawFileData, *pngfile))
{
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);
…
This has a link.
FString pngfile = “myimage.png”;
But the link is anbigus and if I try to change it to a path it does not work, and where is the location of this image for example in the engine, where do you have to put it not to make a path ?
Also what class should I use, is the actor class good for this ?
Where should I look for the image ? it’s in the buffer ? after I get it out it go’s where ?
This example has one array, there are examples with 2 Tarrays where one you put it in, then the other you take it out to it’s properties with, height, size and so on. It also has a 2dconversion way of getting a texture, there are no results.