1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-16 00:08:29 -04:00
OpenDiablo2/OpenDiablo2.Common/Models/Palette.cs
2018-11-22 00:18:42 -05:00

42 lines
922 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)
{
var result = new Palette
{
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;
}
}
}