# How can I create an Image object from a texture2d? Or vice versa.

**URL:** <https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424>\
**Category:** Blueprint\
**Tags:** casting, image, object, unreal-engine, objects, Blueprint, question, texture-channel\
**Created:** [March 13, 2024, 10:43pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424 "2024-03-13T22:43:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1nsaneEExituuuU](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@1nsaneEExituuuU](https://forums.unrealengine.com/u/1nsaneEExituuuU)\
**Post date:** [March 13, 2024, 10:43pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/1 "2024-03-13T22:43:40Z")

</div>

Hello, I am quite stuck on what I’d expect to be quite a simple issue.

When I spawn a buff object from class (in this case “Debuff Burn”) It takes an Image object that it then uses to display the image.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/3/4e348f7bd410974d9f39107ef02a38ca85c14ca5.png)

However my texture files are “Texture2d”

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/6/6162640e3b62ab5dec3cb908576e87bebcf65022.png)

So how can I get the tab in my first picture filled in with the textures from the second picture?

Can I perhaps convert the textures to images in some way? Something like this?  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/3/84327fb09b65b224bfe19b51cec421ee93c70ea6.png)

I am also interested in knowing the vice versa because I could just change the debuff to take a texture, fixing the initial issue, but that means having to get the texture2d from an image object down the line, which I couldnt figure out either…

* * *

Tried to fix it like this: Letting my class take a texture (instead of an image object) and then constructing an image object and setting its brush before then sending it to my “add buff to slot” function

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/1/9a1abdb2d5f83176b5fd6e0db509a547ed891b6f.png)

This doesn’t seem to work either as it’s still just using a white image (which im assuming is just what it defaults to)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/9/56943876afa8308ce11c6022267779ac2c50d77f.png)  
Left (white box): The icon that becomes visible from running with construct image (or if i don’t select any texture at all)  
Right (Arrows): The default icons when they are set correctly

Is there problems in my add buff to slot function maybe?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/6/e563704dfe6f6767292349d04c40c2426f5d0e21.png)

Ty in advance. Somehow I couldn’t really find anything similar, so I assume I’m just missing something ^^

---

<div class="post-metadata">

**Author:** ![cinewulf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cinewulf/32/910280_2.png) [@cinewulf](https://forums.unrealengine.com/u/cinewulf)\
**Post date:** [March 14, 2024, 11:30pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/2 "2024-03-14T23:30:20Z")

</div>

Yes, (at least in the Widget Designer) white is the default when no Brush is set. So I also assume that the texture size gets properly set by _Set Brush from Texture_.

I have no ready solution, but for debugging,

- maybe you could try to check if the input image from _Add Buff to Slot_ is loaded (with the _Is Loaded_ node)?
- And/or try to _Async Load Asset_ the image before sending it to the _Make SlateBrush_?

---

<div class="post-metadata">

**Author:** ![1nsaneEExituuuU](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@1nsaneEExituuuU](https://forums.unrealengine.com/u/1nsaneEExituuuU)\
**Post date:** [March 14, 2024, 11:59pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/3 "2024-03-14T23:59:59Z")

</div>

Appreciate the response

I was just about to hit the bed, Ill try your debugging suggestion in the morning and report back

ik such a weird issue i feel like ^^

* * *

Testing if texture is valid:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/6/de6189f9b25862a93ed2d5b406b4d424da2c3c0b.png)

Testing if image is valid:  
same as above just dragging buff img instead of texture.

Testing if image is valid inside add buff function:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/f/0df66b6b8a9f7fcf61314707b55f0a2a7b46a327.png)

All was valid, but it does make sense, since it just creates the image object with the white brush, it seems like the passed image does not have the updated brush from “set brush from texture”

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [March 15, 2024, 12:00pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/4 "2024-03-15T12:00:13Z")

</div>

Try with this one:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/8/de8d37b1910b4c69f3f3ee9fd37a057f3248fdaf.jpeg)

You can then just select a Texture2d asset from your calling event/spawn.

---

<div class="post-metadata">

**Author:** ![1nsaneEExituuuU](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@1nsaneEExituuuU](https://forums.unrealengine.com/u/1nsaneEExituuuU)\
**Post date:** [March 15, 2024, 5:30pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/5 "2024-03-15T17:30:26Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/7/e57dc6dc1f7208be05ad3af3cbdf4828da3eb05e.png)  
I applied it to my current system but with no luck still just a white image.

---

<div class="post-metadata">

**Author:** ![1nsaneEExituuuU](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@1nsaneEExituuuU](https://forums.unrealengine.com/u/1nsaneEExituuuU)\
**Post date:** [March 15, 2024, 7:26pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/6 "2024-03-15T19:26:26Z")

</div>

I found the solution going vice versa. Casting to texture2d.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/1/f112e987cbe4c18c79020cf807dc3b9c99ce5d56.png)

I had tried this earlier without getting the brush from buff icon and then breaking that. But both objects seem to be the same to me, maybe someone can explain the difference in these pics =p

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/9/c19ff041f81020cec6a65ad1386d5485327c1e4f.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/d/3cd3204d2ec15b7e8e95546bd77694902fcd3d44.png)

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [March 15, 2024, 8:00pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/7 "2024-03-15T20:00:49Z")

</div>

ahh i didnt notice your function Add buff to slot had Texture2d as input.

You can try to switch it to an Image/Widget Object Reference.

The param input in the slate Image is of type Object so it can accept anything (like texture 2d, material etc…)

---

<div class="post-metadata">

**Author:** ![1nsaneEExituuuU](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@1nsaneEExituuuU](https://forums.unrealengine.com/u/1nsaneEExituuuU)\
**Post date:** [March 15, 2024, 8:42pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/8 "2024-03-15T20:42:53Z")

</div>

That’s what I meant by vice versa i changed that to take a texture ref, but that lead to other code down the line needing to go from image-\>texture as seen on latest pics.

The first time i casted i just did it straight and it gave an error, but after getting brush, breaking that and then casting it worked fine.

Weird, but very happy I figured it out =D

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 14, 2024, 8:43pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-image-object-from-a-texture2d-or-vice-versa/1750424/9 "2024-04-14T20:43:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
