Tool Yet another PNG to XNB converter

psmith

Terrarian
It was fun to create my own png_to_xnb variant. I used an early version of this to create my texture pack. Maybe someone will also find it useful.

Source is here (C#): https://github.com/sullerandras/png_to_xnb
Precompiled exe (17 kB): https://github.com/sullerandras/png_to_xnb/raw/master/png_to_xnb.exe

It is a standalone exe, it should work on any Windows 7 or newer without installing .NET or XNA frameworks. On Mac you need wine or mono to run it.
Note that it supports batch converting via command line arguments. Start it without any command line arguments (e.g. double clicking it) to see a basic GUI.

Also note that the program only handles 8 bits per pixel PNG files. In other words: 16 bits / pixel images will not work properly, you need to convert them to 8 bpp.

This is my first C# project. I used Mono (Xamarin Studio) on a Mac for development.
 
Last edited:
I don't know about yet another......this is the first standalone converter I've seen that converts from PNG to XNB! (I gave up on my own when I couldn't find documentation on the file type.)

I just tried it out real quick, and it looks like transparency has been reduced to white. Is this expected?

Anyway, great job, the whole "install all this software that is no longer supported just to convert some images" hurdle is now gone.
 
Good job on this dude!
 
I don't know about yet another......this is the first standalone converter I've seen that converts from PNG to XNB! (I gave up on my own when I couldn't find documentation on the file type.)

I just tried it out real quick, and it looks like transparency has been reduced to white. Is this expected?

Anyway, great job, the whole "install all this software that is no longer supported just to convert some images" hurdle is now gone.

Thanks. I think I found the format specification here: http://xbox.create.msdn.com/en-US/sample/xnb_format (a really lame looking site, but the zip contains the documentation I was working from (in .docx format! lol! not pdf)).

The transparency should be ok. This program generates the exact same output as the earlier version I used to generate my HD textures (on Mac using wine. On Windows I haven't tested extensively, but I suppose it works the same).
 
Thanks for the program
 
I'm getting this once I can use my own computer. Here, take my imaginary money: $ , because xnb files are very annoying to make.
 
It seems like the converter doesn't retain the transparancy of my pngs
 

Attachments

  • 2016-01-22_00002.jpg
    2016-01-22_00002.jpg
    152.9 KB · Views: 2,773
It seems like the converter doesn't retain the transparancy of my pngs
Can you send me the png file which is wrong?
In the converter I used the .NET Bitmap class, which should handle 8 bit per pixel RGBA png files. If you use 16 bit / channel, it will probably not work.
 
Can you send me the png file which is wrong?
In the converter I used the .NET Bitmap class, which should handle 8 bit per pixel RGBA png files. If you use 16 bit / channel, it will probably not work.

Thanks for the info. I saved my PNGs with @ 8 bits and it works perfectly :D
 
Huh, I open it and it instantly closes. Weird. Would be really helpful if it worked xD

Help would be appreciated :D
 
How exactly do I use this?
It closes out when I click the exe
 
How exactly do I use this?
It closes out when I click the exe
It is a command line application, you need to start it from CMD.EXE. If you double click on the exe it will close itself immediately because there are no command line arguments passed in.
 
It was fun to create my own png_to_xnb variant. I used an early version of this to create my texture pack. Maybe someone will also find it useful.

Source is here (C#): https://github.com/sullerandras/png_to_xnb
Precompiled exe (12 kB): https://github.com/sullerandras/png_to_xnb/raw/master/png_to_xnb.exe

It is a standalone exe, it should work on any Windows 7 or newer without installing .NET or XNA frameworks. On Mac you need wine or mono to run it.
Note that this is a command line program. No GUI.
Also note that the program only handles 8 bits per pixel PNG files. In other words: 16 bits / pixel images will not work properly, you need to convert them to 8 bpp.

This is my first C# project. I used Mono (Xamarin Studio) on a Mac for development.
You should try adding a tutorial because this gets a little confusing
Edit: It would also be cool if you could drag a png file onto the exe to convert it
 
Last edited:
You should try adding a tutorial because this gets a little confusing
Edit: It would also be cool if you could drag a png file onto the exe to convert it
Updated the program, added a very basic GUI and "dragging the file onto the exe will convert the file" should also work.
 
For some reason my transparency did not save when I put the xnb in the content folder and loaded the game :/
 
For some reason my transparency did not save when I put the xnb in the content folder and loaded the game :/
Most likely your PNG is using 16 bits per pixel. Try to save it as 8 BPP and check if transparency works.
 
Most likely your PNG is using 16 bits per pixel. Try to save it as 8 BPP and check if transparency works.
How exactly would I save it as 8 BPP using Paint.NET
 
I figured it out :P
Open the png file with paint.net
save it as a gif
rename the gif to a png
done
 
Back
Top Bottom