C# 将PNG文件转换为XNB

C# 将PNG文件转换为XNB,c#,xna,monogame,C#,Xna,Monogame,您好,我正在尝试将PNG文件转换为XNB,以便在示例程序Breakernoid项目中使用。 我使用XNA格式化程序将.png转换为.xnb,但72kb的文件创建了2Mb.xnb文件。对我来说,这本身就是一个危险信号 基本上,我只想创建自己的图像文件并在项目中使用。虽然文档中说MonogameDevelopment接受content文件夹中的.png文件,但它不起作用 非常感谢您的帮助,谢谢 不管怎样,我试着使用它,但我的应用程序崩溃了 Microsoft.Xna.Framework.Conten

您好,我正在尝试将PNG文件转换为XNB,以便在示例程序Breakernoid项目中使用。 我使用XNA格式化程序将.png转换为.xnb,但72kb的文件创建了2Mb.xnb文件。对我来说,这本身就是一个危险信号

基本上,我只想创建自己的图像文件并在项目中使用。虽然文档中说MonogameDevelopment接受content文件夹中的.png文件,但它不起作用

非常感谢您的帮助,谢谢

不管怎样,我试着使用它,但我的应用程序崩溃了

Microsoft.Xna.Framework.Content.ContentLoadException was unhandled
  HResult=-2146233088
  Message=Could not load board2 asset as a non-content file!
  Source=MonoGame.Framework
  StackTrace:
       at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
       at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
       at MMCreate.Game1.LoadContent() in C:\Shri\CSProjects\GameProjects\MMCreate\Game1.cs:line 103
       at Microsoft.Xna.Framework.Game.Initialize()
       at MMCreate.Game1.Initialize() in C:\Shri\CSProjects\GameProjects\MMCreate\Game1.cs:line 89
       at Microsoft.Xna.Framework.Game.DoInitialize()
       at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
       at Microsoft.Xna.Framework.Game.Run()
       at MMCreate.Program.Main() in C:\Shri\CSProjects\GameProjects\MMCreate\Program.cs:line 22
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2146233088
       Message=The content file was not found.
       Source=MonoGame.Framework
       StackTrace:
            at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
            at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
       InnerException: 
            FileName=C:\Shri\CSProjects\GameProjects\MMCreate\bin\Windows\Debug\Content\board2.xnb
            HResult=-2147024894
            Message=Could not find file 'C:\Shri\CSProjects\GameProjects\MMCreate\bin\Windows\Debug\Content\board2.xnb'.
            Source=mscorlib
            StackTrace:
                 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                 at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
                 at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
                 at Microsoft.Xna.Framework.TitleContainer.OpenStream(String name)
                 at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
            InnerException: 

标题输入错误将png转换为.xnb文件,我正在使用vs 2015社区版InnerException说它找不到该文件。。。你确定它存在吗?这可能是由一些事情引起的。你能发布你的内容吗?加载代码,以及你将PNG文件添加到项目中所采取步骤的一些解释。@BurningLights是的,该文件确实存在。@craftworkgames今晚将发布加载代码,谢谢