Tuesday, January 3, 2012

XNA : How to convert in code image to texture2D

Hi,

For a project, i have to load dynamic picture and use them into my game.

To do this i have simply create this little code :

public class ImageToTexture
{
     public static Texture2D loadPictureFromFile(GraphicsDevice graph, String file)
     {
          Stream ss = new FileStream(file, FileMode.Open);
          Texture2D load = Texture2D.FromStream(graph, ss);
          return load;
     }
}

No comments:

Post a Comment