我从目录加载纹理有一些问题.也许代码优先:
private Texture2D LoadTextureStream(string filePath)
{
Texture2D file = null;
RenderTarget2D result = null;
try
{
using (System.IO.Stream titleStream = TitleContainer.OpenStream(filePath))
{
file = Texture2D.FromStream(GraphicsDevice, titleStream);
}
}
catch
{
throw new System.IO.FileLoadException("Cannot load '" + filePath + "' file!");
}
PresentationParameters pp = GraphicsDevice.PresentationParameters;
//Setup a render target to hold our final texture which will have premulitplied alpha values
result = new RenderTarget2D(GraphicsDevice, file.Width, file.Height, true, pp.BackBufferFormat, pp.DepthStencilFormat);
GraphicsDevice.SetRenderTarget(result);
GraphicsDevice.Clear(Color.Black);
//Multiply each color by the source alpha, and write …Run Code Online (Sandbox Code Playgroud)