public static void SaveAsPng(this Texture2D texture, Stream stream) { switch (texture.Format) { case SurfaceFormat.Bgra4444: byte[] data = new byte[texture.Width * texture.Height * 2]; texture.GetTexture_BGRA4444(data); data = WzLib.Wz_Png.GetPixelDataBgra4444(data, texture.Width, texture.Height); unsafe { fixed(byte *pData = data) { using (var bmp = new System.Drawing.Bitmap(texture.Width, texture.Height, texture.Width * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, new IntPtr(pData))) { bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); } } } break; default: texture.SaveAsPng(stream, texture.Width, texture.Height); break; } }
public static void GetTexture_BGRA4444 <T>(this Texture2D texture, T[] data) where T : struct { texture.GetTexture_BGRA4444 <T>(0, 0, null, data, 0, data.Length); }