Skip to content

Instantly share code, notes, and snippets.

View JimBobSquarePants's full-sized avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@JimBobSquarePants
JimBobSquarePants / YCbCrToRgbTables.cs
Created April 24, 2017 23:19
LUT Tables for YCbCr -> Rgb conversion method
// <copyright file="YCbCrToRgbTables.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Formats.Jpeg.Components.Decoder
{
using System.Runtime.CompilerServices;
using ImageSharp.PixelFormats;
@JimBobSquarePants
JimBobSquarePants / Program.cs
Created April 21, 2017 07:58
Really Rough ImageSharp Benchmark.
using System;
using System.IO;
using System.Numerics;
using System.Reflection;
using ImageSharp;
using ImageSharp.Processing;
namespace Test.ISharp
{
class Program
@JimBobSquarePants
JimBobSquarePants / Benchmarks.md
Last active December 25, 2018 21:00
Imaging Benchmarks 19/04/2017

Resize

BenchmarkDotNet=v0.10.3.0, OS=Microsoft Windows 10.0.15063
Processor=Intel(R) Core(TM) i7-6600U CPU 2.60GHz, ProcessorCount=4
Frequency=2742191 Hz, Resolution=364.6719 ns, Timer=TSC
dotnet cli version=1.0.3
  [Host]     : .NET Core 4.6.25009.03, 64bit RyuJIT
  Job-YVBYQX : .NET Core 4.6.25009.03, 64bit RyuJIT
@JimBobSquarePants
JimBobSquarePants / readme.md
Created March 1, 2017 13:19
Color Blindness Simulation of Umbraco Backoffice

See below images. TODO: Use contrast checker against output.

@JimBobSquarePants
JimBobSquarePants / Clamp.md
Created January 24, 2017 07:42
Benchmarking integer clamping methods using BenchMarkDotNet
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-6600U CPU 2.60GHz, ProcessorCount=4
Frequency=2742193 Hz, Resolution=364.6716 ns, Timer=TSC
  [Host]     : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
  DefaultJob : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0

Allocated=0 B
@JimBobSquarePants
JimBobSquarePants / GifEncoder.md
Last active December 17, 2016 10:59
Performance improvements in the gif encoder

WIP improvements made so far in the gif encoder. All the time/memory usage is in the OctreeQuantizer.cs I don't know what quantizer System.Drawing uses (Most likely a fixed palette with pre-dithering) but the quality difference is incomparable.

It'll probably take a better mind than mine to bring the memory usage in the quantizer down further.

P.S ArrayPool<T> rocks!!!

@JimBobSquarePants
JimBobSquarePants / bitshifter.cs
Created July 6, 2016 07:20
Packing to and from different numerical types.
// How do I get these two sets of methods to return the same output value?
void Main()
{
uint x1 = PackUint(0.5f, 1, 0.5f, 1);
byte[] b1 = ToBytes(x1);
x1.Dump(); // 4286644096
b1.Dump(); // 128, 255, 128, 255 RIGHT! :)
ulong x2 = PackUlong(0.5f, 1, 0.5f, 1);
@JimBobSquarePants
JimBobSquarePants / TypeWrapper.cs
Last active February 20, 2020 21:59
You can do really crazy things with C#
public class TypeWrapper
{
private readonly dynamic dyn;
private readonly Dictionary<string, CallSite<Action<CallSite, object, object>>> setters
= new Dictionary<string, CallSite<Action<CallSite, object, object>>>();
private readonly Dictionary<string, CallSite<Func<CallSite, object, object>>> getters
= new Dictionary<string, CallSite<Func<CallSite, object, object>>>();
public TypeWrapper(object d)
@JimBobSquarePants
JimBobSquarePants / DominantColors.cs
Created April 13, 2016 15:20
An ImageProcessor Core equivalent to the output described at https://manu.ninja/dominant-colors-for-lazy-loading-images
/// <summary>
/// Returns a 1x1 pixel Base64 encoded gif from the given image containing a single dominant color.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="string"/></returns>
public static string ToBase64GifPixelString(this Image source)
{
// Leave the original image intact
using (Image temp = new Image(source))
{
@JimBobSquarePants
JimBobSquarePants / ImageCropperPropertyConverter.cs
Last active March 10, 2016 04:49
ImageCropperPropertyConverter for Umbraco
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ImageCropperPropertyConverter.cs" company="Deepend">
// Copyright (c) Deepend
// </copyright>
// <summary>
// The image cropper property converter. This allows Ditto to map the image cropper using the built in Umbraco
// methods.
// </summary>
// --------------------------------------------------------------------------------------------------------------------