mirror of https://github.com/SixLabors/ImageSharp
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.
59 lines
1.8 KiB
59 lines
1.8 KiB
// <copyright file="BlendTest.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp.Tests
|
|
{
|
|
using ImageSharp.Drawing.Brushes;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
using ImageSharp.PixelFormats;
|
|
|
|
using Xunit;
|
|
|
|
public class RecolorImageTest : FileTestBase
|
|
{
|
|
[Fact]
|
|
public void ImageShouldRecolorYellowToHotPink()
|
|
{
|
|
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
|
|
|
|
RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
|
|
|
|
foreach (TestFile file in Files)
|
|
{
|
|
using (Image image = file.CreateImage())
|
|
{
|
|
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
|
|
{
|
|
image.Fill(brush)
|
|
.Save(output);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ImageShouldRecolorYellowToHotPinkInARectangle()
|
|
{
|
|
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
|
|
|
|
RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
|
|
|
|
foreach (TestFile file in Files)
|
|
{
|
|
using (Image image = file.CreateImage())
|
|
{
|
|
using (FileStream output = File.OpenWrite($"{path}/Shaped_{file.FileName}"))
|
|
{
|
|
int imageHeight = image.Height;
|
|
image.Fill(brush, new Rectangle(0, imageHeight/2 - imageHeight/4, image.Width, imageHeight/2))
|
|
.Save(output);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|