IllusiveMangas
IllusiveMangas

Reputation: 33

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

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.

Upvotes: 3

Views: 5224

Answers (1)

Phil Lamb
Phil Lamb

Reputation: 1437

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).

Upvotes: 4

Related Questions