📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.7 KiB

// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Drawing.Brushes;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
public class RecolorImageTest : FileTestBase
{
[Fact]
public void ImageShouldRecolorYellowToHotPink()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
{
image.Mutate(x => x.Fill(brush));
image.Save($"{path}/{file.FileName}");
}
}
}
[Fact]
public void ImageShouldRecolorYellowToHotPinkInARectangle()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
{
int imageHeight = image.Height;
image.Mutate(x => x.Fill(brush, new Rectangle(0, imageHeight / 2 - imageHeight / 4, image.Width, imageHeight / 2)));
image.Save($"{path}/Shaped_{file.FileName}");
}
}
}
}
}