Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Watkins MrKWatkins

View GitHub Profile
@MrKWatkins
MrKWatkins / ZX Spectrum Next 9-Bit.gpl
Created May 7, 2018
ZX Spectrum Next 9-Bit Palette for GIMP
View ZX Spectrum Next 9-Bit.gpl
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
ZX Spectrum Next 8-Bit Palette for GIMP
View ZX Spectrum Next 8-Bit.gpl
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 / ColourMapper.cs
Last active May 7, 2018
C# code to map the 24-bit colours in an image to the nearest 8 or 9-bit colours.
View ColourMapper.cs
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 / PaletteGenerator.cs
Created May 7, 2018
C# code to generate GIMP .gpl palette files for 8 and 9-bit ZX Spectrum Next palettes
View PaletteGenerator.cs
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 / LongToByteArrayConversion
Created Jan 21, 2014
Comparison of two functions to convert a long to a byte array, one using safe code, the other using unsafe code.
View LongToByteArrayConversion
using System;
using System.Diagnostics;
namespace TestCSharpConsoleApplication
{
internal static class Program
{
private static void Main()
{
const int iterations = 500000000;
@MrKWatkins
MrKWatkins / EnumConversion
Created Jan 20, 2014
Comparison of two functions to convert an enum value to a byte, one using safe code, the other using unsafe code.
View EnumConversion
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace TestCSharpConsoleApplication
{
internal static class Program
{
private static void Main()
{