user1306322
user1306322

Reputation: 8721

How to load user generated png images as textures (not xnb's)?

The idea is to let users create their own textures, put them in a folder as images (and maybe set some properties in a separate text file) for the game to load and work accordingly.

Usually I have my own textures as images, they are processed by Visual Studio when compiling, and then the game uses XNB files. But how about end users that don't have VS installed?

UPD: The only safe option (that doesn't require manual resource disposal) seems to be replacing the original resource files in XNB format. For that, you can process your own PNG, WAV and other files with this tool from codeplex and put them in content folder of the game.

Upvotes: 0

Views: 932

Answers (1)

Blau
Blau

Reputation: 5762

if you works in windows only... (not xbox and not windows phone)

you can use Texture2d.FromStream(File.OpenRead(path));

You have to realize that this way, you should call the texture dispose method when the texture is not needed to free resources.

Wehn you use the content manager, is the manager who call the method when the game ends.

Upvotes: 2

Related Questions