35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using Microsoft.Xna.Framework.Content.Pipeline;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
|
{
|
|
[ContentProcessor(DisplayName = "Texture Atlas Processor")]
|
|
class TextureAtlasProcessor : ContentProcessor<TextureAtlasData, byte[]>
|
|
{
|
|
|
|
public override byte[] Process(TextureAtlasData input, ContentProcessorContext context)
|
|
{
|
|
string serialized = JsonConvert.SerializeObject(input);
|
|
byte[] bytes = Encoding.UTF8.GetBytes(serialized);
|
|
|
|
using (MemoryStream outStream = new MemoryStream())
|
|
{
|
|
using (GZipStream gZipStream = new GZipStream(outStream, CompressionLevel.Optimal))
|
|
{
|
|
gZipStream.Write(bytes, 0, bytes.Length);
|
|
byte[] compressed = outStream.ToArray();
|
|
return compressed;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|