36 lines
1.1 KiB
C#
36 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);
|
|
|
|
MemoryStream outStream = new MemoryStream();
|
|
GZipStream gZStream = new GZipStream(outStream, CompressionLevel.Optimal);
|
|
|
|
gZStream.Write(bytes, 0, bytes.Length);
|
|
|
|
byte[] compressed = outStream.ToArray();
|
|
|
|
gZStream.Dispose();
|
|
outStream.Dispose();
|
|
return compressed;
|
|
}
|
|
}
|
|
}
|