Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load a texture from a path in XNA at runtime?

Tags:

c#

xna

xna-4.0

I'm trying to do a RPG Editor in XNA, the thing is that I need to load the textures from a path written in a XMAL file.

I've done some research, but most of the solutions are changing the content pipeline or simply creating your own.

like image 210
IllusiveMangas Avatar asked Nov 25 '25 21:11

IllusiveMangas


1 Answers

Try this:

FileStream filestream = new FileStream("mytexture.jpg");
Texture2D myTexture = Texture2D.FromStream(graphicsDevice, filestream);

Texture2D.FromStream

Disclaimer: I haven't tested this code (don't have xna installed on this computer).

like image 190
Phil Lamb Avatar answered Nov 28 '25 11:11

Phil Lamb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!