I'm working on a tilesheet builder tool for my game to speed up tile creation, and I need to save a generated texture2D as a png. I've tried using the .SaveAsPng function but it isn't implemented in Monogame.
Is there any way around this in monogame?
EDIT: I've tried this:
private void SaveTextureData(RenderTarget2D texture, string filename)
{
byte[] imageData = new byte[4 * texture.Width * texture.Height];
texture.GetData<byte>(imageData);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(texture.Width, texture.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Imaging.BitmapData bmData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, texture.Width, texture.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat);
IntPtr pnative = bmData.Scan0;
System.Runtime.InteropServices.Marshal.Copy(imageData, 0, pnative, 4 * texture.Width * texture.Height);
bitmap.UnlockBits(bmData);
bitmap.Save(filename);
}
but it's giving a weird output, and I don't know why: http://i.imgur.com/XT9Dnjj.png
Thanks for any help!