Created
April 14, 2020 01:17
-
-
Save atruskie/f12f22830f79ba42943433edee964a53 to your computer and use it in GitHub Desktop.
Test ImageSharp pixel blending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using SixLabors.Fonts; | |
using SixLabors.ImageSharp; | |
using SixLabors.ImageSharp.PixelFormats; | |
using SixLabors.ImageSharp.Processing; | |
using Color = SixLabors.ImageSharp.Color; | |
using Pen = SixLabors.ImageSharp.Processing.Pen; | |
namespace ImageSharpTests | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// test how ImageSharp pixel blenders work. | |
var blender = PixelOperations<Rgb24>.Instance.GetPixelBlender(new GraphicsOptions()); | |
var background = new Rgb24[] { Color.Black }; | |
var foreground = new Rgba32[] { Color.Red.WithAlpha(0.5f) }; | |
var destination = new Rgb24[] { Color.White }; // default - expected to be overwritten | |
blender.Blend<Rgba32>(Configuration.Default, destination, background, foreground, 1f); | |
Console.WriteLine($"Destination: {destination[0]}"); // Destination: Rgb24(128, 0, 0) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment