Parse 12 vs 24 bit colors eventually

This commit is contained in:
Lani Aung
2021-10-02 19:18:58 -06:00
parent 66ccf83051
commit 4b4fffdbf1
15 changed files with 1447 additions and 29 deletions
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using fxl.codes.kisekae.Models;
using Microsoft.Extensions.Logging;
namespace fxl.codes.kisekae.Services
{
public class FileParserService
{
private readonly ILogger<FileParserService> _logger;
private readonly IsolatedStorageFile _storage;
public FileParserService(ILogger<FileParserService> logger)
{
_logger = logger;
_storage = IsolatedStorageFile.GetUserStoreForApplication();
}
public void ParsePalette(string directory, PaletteModel palette)
{
_logger.LogTrace($"Reading palette {palette.FileName} from {directory}");
using var stream = _storage.OpenFile(Path.Combine(directory, palette.FileName), FileMode.Open);
if (!stream.CanRead) throw new InvalidDataException();
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
var header = Encoding.ASCII.GetBytes("KiSS");
if (buffer[..header.Length].SequenceEqual(header))
{
// Matching header I guess?
}
}
}
}