Skip to content

Instantly share code, notes, and snippets.

@MrKWatkins
MrKWatkins / ZX Spectrum Next 9-Bit.gpl
Created May 7, 2018 16:47
ZX Spectrum Next 9-Bit Palette for GIMP
GIMP Palette
Name: ZX Spectrum Next 9-Bit
Columns: 16
#
0 0 0 Index 0
0 0 36 Index 1
0 0 72 Index 2
0 0 108 Index 3
0 0 144 Index 4
0 0 180 Index 5
@MrKWatkins
MrKWatkins / ZX Spectrum Next 8-Bit.gpl
Created May 7, 2018 16:46
ZX Spectrum Next 8-Bit Palette for GIMP
GIMP Palette
Name: ZX Spectrum Next 8-Bit
Columns: 16
#
0 0 0 Index 0
0 0 85 Index 1
0 0 170 Index 2
0 0 255 Index 3
0 36 0 Index 4
0 36 85 Index 5
@MrKWatkins
MrKWatkins / PaletteGenerator.cs
Created May 7, 2018 16:43
C# code to generate GIMP .gpl palette files for 8 and 9-bit ZX Spectrum Next palettes
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using JetBrains.Annotations;
namespace Elena.Compiler.Console
{
/// <summary>
/// Utility class to write out 8 and 9-bit Next palettes in Gimp GPL format.
/// </summary>
@MrKWatkins
MrKWatkins / ColourMapper.cs
Last active May 7, 2018 16:43
C# code to map the 24-bit colours in an image to the nearest 8 or 9-bit colours.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using JetBrains.Annotations;
namespace Elena.Compiler.Console
{
/// <summary>
/// Maps the colours in a bitmap to the nearest Next colour. Uses the palettes from <see cref="PaletteGenerator" />.
/// (https://gist.github.com/MrKWatkins/ea62814ed78b79edf8c5aa4902652ff3)
@MrKWatkins
MrKWatkins / LongToByteArrayConversion
Created January 21, 2014 22:34
Comparison of two functions to convert a long to a byte array, one using safe code, the other using unsafe code.
using System;
using System.Diagnostics;
namespace TestCSharpConsoleApplication
{
internal static class Program
{
private static void Main()
{
const int iterations = 500000000;
@MrKWatkins
MrKWatkins / EnumConversion
Created January 20, 2014 21:08
Comparison of two functions to convert an enum value to a byte, one using safe code, the other using unsafe code.
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace TestCSharpConsoleApplication
{
internal static class Program
{
private static void Main()
{