Skip to content

Instantly share code, notes, and snippets.

View antonfirsov's full-sized avatar

Anton Firszov antonfirsov

View GitHub Profile
@antonfirsov
antonfirsov / RewriteCommits.cs
Created January 19, 2020 23:07
Rewrite SixLabors.Core History
private const string RepoPath = @"[...]\Core\.git\";
private static string FixCommitMessage(string m)
{
return "[SL.Core] " + m.Replace("#", "SixLabors/Core#");
}
static void Main(string[] args)
{
using var repo = new Repository(RepoPath);
@antonfirsov
antonfirsov / RRR.cs
Created December 18, 2019 19:09
_rightEndpoint Race Repro
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace UdpMultipleTest
{
static class Program
{
static void Main(string[] args)
public void RunThisOnYourDevice()
{
string inputImagesRoot = "YourRootToImages"; // https://github.com/SixLabors/ImageSharp/tree/master/tests/Images/Input
string reportFile = Path.Combine("WhateverPathYouCanWriteTo", "Report.txt");
string[] files = Directory.EnumerateFiles(
inputImagesRoot,
"*.*",
SearchOption.AllDirectories).Where(
f => Path.GetExtension(f).ToLower() == ".png" || Path.GetExtension(f).ToLower() == ".jpg"
// Contains a general pixel-format independant color definition
public struct Color
{
private Rgba64 data; // Could be also Vector4, but that would probably lead to compatibility issues.
public Color(Rgba64 pixel) { this.data = pixel; }
public Color(Rgba32 pixel) { this.data.FromRgba32(pixel); }
public Color(Vector4 vector) { this.data.FromVector4(vector); }
// No longer a static utility class, but a base class for the pixel-type aware Image<TPixel>.
// Nevertheless, it contains all the static methods, just as before.
public abstract class Image
{
// The generic methods load pixel-aware images:
public static Image<TPixel> Load<TPixel>(....);
// The non-generic methods load pixel-agnostic images:
public static Image Load(...);

DecodeJpegParseStreamOnly

Runs JpegDecoderCore.ParseStream() on jpeg420exif.jpg

Setup

BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17134.706 (1803/April2018Update/Redstone4)
Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
Frequency=2742189 Hz, Resolution=364.6722 ns, Timer=TSC
.NET Core SDK=2.2.202
  [Host] : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
public unsafe class WriteableBitmapMemoryManager : MemoryManager<Bgra32> {
private readonly WriteableBitmap bitmap;
private IBufferByteAccess pixelBuffer;
private byte* pixelBytes;
private readonly int length;
/// <summary>
/// Initializes a new instance of the <see cref="WriteableBitmapMemoryManager"/> class.
/// </summary>

JPEG & Exif

  • [2018-09-07] #698 - Allow several invalid data types when reading the exif resolution.
  • [2018-09-07] #699 - Fix EXIF overflow and Jpeg decoding
  • [2018-09-11] #686 - Ext.DrawImage generalization to support multiple formats. (Experimental)
  • [2018-10-04] #722 - Fix #721 ||| incorrect App0 markers
  • [2018-10-05] #724 - Decode components in correct order + cleanup + optimizations. ||| interleaved progressive jpegs
  • [2018-11-05] #768 - Various Jpeg optimizations
  • [2018-12-30] #784 - Jpeg 12 bit support
  • [2019-01-06] #801 - #797 throw ImageFormatException when no StartOfFrame marker is found
  • [2019-01-09] #804 - Use bounds checks in Huffman ctr. Fix #798
@antonfirsov
antonfirsov / OldKernelMap.MD
Last active November 29, 2018 02:42
Smart ResizeKernelMap
0.81138 0.24055 -0.05193 0.00000
-0.03204 0.64517 0.44502 -0.05815 0.00000
0.00000 -0.05836 0.44661 0.64748 -0.03216 -0.00357
0.00000 -0.05038 0.23337 0.78718 0.05522 -0.02539
-0.02539 0.05522 0.78718 0.23337 -0.05038 0.00000
-0.00357 -0.03216 0.64748 0.44661 -0.05836 0.00000
0.00000 -0.05836 0.44661 0.64748 -0.03216 -0.00357
Oh no! Gray16(256) != Gray16(257)
Oh no! Gray16(512) != Gray16(514)
Oh no! Gray16(768) != Gray16(771)
Oh no! Gray16(1024) != Gray16(1028)
Oh no! Gray16(1280) != Gray16(1284)
Oh no! Gray16(1536) != Gray16(1542)
Oh no! Gray16(1792) != Gray16(1799)
Oh no! Gray16(2048) != Gray16(2056)
Oh no! Gray16(2304) != Gray16(2313)