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.
54 lines
1.6 KiB
54 lines
1.6 KiB
// <copyright file="PngEncoderTests.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
using ImageSharp.Formats;
|
|
|
|
namespace ImageSharp.Tests
|
|
{
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
using Xunit;
|
|
|
|
public class PngEncoderTests : FileTestBase
|
|
{
|
|
[Fact]
|
|
public void ImageCanSaveIndexedPng()
|
|
{
|
|
string path = CreateOutputDirectory("Png", "Indexed");
|
|
|
|
foreach (TestFile file in Files)
|
|
{
|
|
using (Image image = file.CreateImage())
|
|
{
|
|
using (FileStream output = File.OpenWrite($"{path}/{file.FileNameWithoutExtension}.png"))
|
|
{
|
|
image.MetaData.Quality = 256;
|
|
image.Save(output, new PngFormat());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ImageCanSavePngInParallel()
|
|
{
|
|
string path = this.CreateOutputDirectory("Png");
|
|
|
|
Parallel.ForEach(
|
|
Files,
|
|
file =>
|
|
{
|
|
using (Image image = file.CreateImage())
|
|
{
|
|
using (FileStream output = File.OpenWrite($"{path}/{file.FileNameWithoutExtension}.png"))
|
|
{
|
|
image.SaveAsPng(output);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|