From aea8b2af60e48ed31c86c738e975f582a9211289 Mon Sep 17 00:00:00 2001 From: Emiliano Magliocca Date: Tue, 5 May 2020 09:59:27 +0300 Subject: [PATCH] Fix ApplyTileFoundProcessor --- .../Services/SearchAndReplaceService.cs | 32 ++++++++++++++----- Yugen.Mosaic.Uwp/Yugen.Mosaic.Uwp.csproj | 8 +---- build-pipelines.yml | 5 +++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Yugen.Mosaic.Uwp/Services/SearchAndReplaceService.cs b/Yugen.Mosaic.Uwp/Services/SearchAndReplaceService.cs index 1b35664..38e4819 100644 --- a/Yugen.Mosaic.Uwp/Services/SearchAndReplaceService.cs +++ b/Yugen.Mosaic.Uwp/Services/SearchAndReplaceService.cs @@ -1,11 +1,10 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using System; using System.Collections.Generic; +using System.Threading.Tasks; using Yugen.Mosaic.Uwp.Interfaces; using Yugen.Mosaic.Uwp.Models; -using Size = SixLabors.ImageSharp.Size; namespace Yugen.Mosaic.Uwp.Services { @@ -30,17 +29,34 @@ public SearchAndReplaceService(Image outputImage, Size tileSize, int tX, public virtual void SearchAndReplace() { } - // TODO: check this out + // TODO: c.DrawImage crash (System.NullReferenceException) + // with the current SixLabors.ImageSharp.Drawing preview version + //internal void ApplyTileFoundProcessor(int x, int y, Image source) + //{ + // _outputImage.Mutate(c => + // { + // var point = new Point(x * source.Width, y * source.Height); + // try + // { + // c.DrawImage(source, point, 1); + // } + // catch { } + // }); + //} + internal void ApplyTileFoundProcessor(int x, int y, Image source) { - _outputImage.Mutate(c => + Parallel.For(0, source.Height, h => { - var point = new Point(x * source.Width, y * source.Height); - try + Span rowSpan = source.GetPixelRowSpan(h); + + for (var w = 0; w < source.Width; w++) { - c.DrawImage(source, point, 1); + var pixel = new Rgba32(); + rowSpan[w].ToRgba32(ref pixel); + + _outputImage[x * source.Width + w, y * source.Height + h] = pixel; } - catch { } }); } } diff --git a/Yugen.Mosaic.Uwp/Yugen.Mosaic.Uwp.csproj b/Yugen.Mosaic.Uwp/Yugen.Mosaic.Uwp.csproj index 5a1d3c2..4e52cc0 100644 --- a/Yugen.Mosaic.Uwp/Yugen.Mosaic.Uwp.csproj +++ b/Yugen.Mosaic.Uwp/Yugen.Mosaic.Uwp.csproj @@ -18,8 +18,6 @@ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true False - - False SHA256 True @@ -38,7 +36,6 @@ false prompt true - False bin\x86\Release\ @@ -62,7 +59,6 @@ false prompt true - False bin\ARM\Release\ @@ -87,7 +83,6 @@ prompt true true - False bin\ARM64\Release\ @@ -111,7 +106,6 @@ false prompt true - True bin\x64\Release\ @@ -270,7 +264,7 @@ 1.0.0-rc0001 - 1.0.0-unstable0436 + 1.0.0-unstable0446 1.6.5 diff --git a/build-pipelines.yml b/build-pipelines.yml index 3b5d779..ea5e35c 100644 --- a/build-pipelines.yml +++ b/build-pipelines.yml @@ -37,6 +37,11 @@ steps: - task: NuGetToolInstaller@1 +- task: NuGetCommand@2 + inputs: + command: 'custom' + arguments: 'sources add -Name myget -Source https://www.myget.org/F/sixlabors/api/v3/index.json' + - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)'