load image, create texture

Hi,

I need to load an image (png/jpg) from disk and by http, create a texture and asign it to a material.
I have created a class deriving from AActor and extended it with Blueprint to be able to write code and use some cool Blueprint features.

I plan to load the image through code and make the texture available to Blueprint so it can assign it to the mesh component it contains.

Will it work? If yes, where should I look for information about how to do it, what classes to use?
The goal is to have a mesh and have a texture made of a loaded image. What is the right project structure for this task? Level Blueprint, Custom Blueprint, C++ class? I’m so confused.

You will need to use C++ here and incorporate it in to Blueprint somehow, goal here is to bring your image to UTexture2D type, if use that type on blueprint it you will notice it will change in to texture picker in variable list. You make that object from raw pixel data (FColor array) using this function:

I can’t find function how to get that data from PNG or JPEG (how to decompress those files) using UE4 APIs, you could try to search deeper.

Now to apply this to mesh, create a material with texture parameter and thru that parameter you can send the image to material which can be used in it (it does not need to just plainly use it ;]). Look up in “Material Instance Dynamic” section, you can do the same via C++ ofcorse

Also as you mention it, you should use Level Blueprint only for level scripting not game code

Thanks for quick answer. That’s good I’m not delusional about the idea. So what you’re saying about using Level Blueprint only, is I should create a standalone script that loads the image and use it in the Level Blueprint?

No, i only said you should use LeveL Blueprint only for level scripting, not game code, thats not related to your question just extra anwser. I seen lot of people who puts every global game code to Level Blueprint