1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-02 17:27:23 -04:00
OpenDiablo2/OpenDiablo2.Common/Models/Palette.cs
2018-11-22 16:22:39 -05:00

43 lines
978 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenDiablo2.Common.Models
{
public struct PaletteEntry
{
public int R;
public int G;
public int B;
}
public struct Palette
{
public string Name { get; set; }
public PaletteEntry[] Colors;
public static Palette LoadFromStream(Stream stream, string paletteName)
{
var result = new Palette
{
Name = paletteName,
Colors = new PaletteEntry[256]
};
var br = new BinaryReader(stream);
for (var i = 0; i <= 255; i++)
result.Colors[i] = new PaletteEntry
{
B = br.ReadByte(),
G = br.ReadByte(),
R = br.ReadByte()
};
return result;
}
}
}