-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from emiliano84/dev
Dev
- Loading branch information
Showing
31 changed files
with
1,216 additions
and
808 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using SixLabors.ImageSharp; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Yugen.Mosaic.Uwp.Helpers | ||
{ | ||
public static class ColorHelper | ||
{ | ||
public static Rgba32 GetAverageColor(Image<Rgba32> source, int x, int y, Size tileSize) => GetAverageColor(source, x * tileSize.Width, y * tileSize.Height, | ||
tileSize.Width, tileSize.Height, x * tileSize.Width + tileSize.Width, y * tileSize.Height + tileSize.Height); | ||
|
||
public static Rgba32 GetAverageColor(Image<Rgba32> source) => GetAverageColor(source, 0, 0, source.Width, source.Height, source.Width, source.Height); | ||
|
||
private static Rgba32 GetAverageColor(Image<Rgba32> source, int startX, int startY, int width, int height, int endX, int endY) | ||
{ | ||
long aR = 0; | ||
long aG = 0; | ||
long aB = 0; | ||
|
||
Parallel.For(startY, endY, h => | ||
{ | ||
Span<Rgba32> rowSpan = source.GetPixelRowSpan(h); | ||
|
||
for (var w = startX; w < endX; w++) | ||
{ | ||
var pixel = new Rgba32(); | ||
rowSpan[w].ToRgba32(ref pixel); | ||
|
||
aR += pixel.R; | ||
aG += pixel.G; | ||
aB += pixel.B; | ||
} | ||
}); | ||
|
||
aR /= width * height; | ||
aG /= width * height; | ||
aB /= width * height; | ||
|
||
return new Rgba32(Convert.ToByte(aR), Convert.ToByte(aG), Convert.ToByte(aB)); | ||
} | ||
|
||
|
||
public static int GetDifference(Rgba32 source, Rgba32 target) | ||
{ | ||
var dR = Math.Abs(source.R - target.R); | ||
var dG = Math.Abs(source.G - target.G); | ||
var dB = Math.Abs(source.B - target.B); | ||
var diff = Math.Max(dR, dG); | ||
return Math.Max(diff, dB); | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Windows.ApplicationModel.Resources; | ||
|
||
namespace Yugen.Mosaic.Uwp.Helpers | ||
{ | ||
public static class ResourceHelper | ||
{ | ||
private static readonly ResourceLoader _resourceLoader = _resourceLoader ?? new ResourceLoader(); | ||
|
||
public static string GetText(string key) => _resourceLoader.GetString(key); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using SixLabors.ImageSharp; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using System.IO; | ||
using Windows.Storage.Streams; | ||
|
||
namespace Yugen.Mosaic.Uwp.Interfaces | ||
{ | ||
public interface IMosaicService | ||
{ | ||
Image<Rgba32> AddMasterImage(Stream stream); | ||
Image<Rgba32> AddTileImage(string name, Stream stream); | ||
Image<Rgba32> GenerateMosaic(Size outputSize, Size tileSize, int mosaicType); | ||
Image<Rgba32> GetResizedImage(Image<Rgba32> image, int size); | ||
InMemoryRandomAccessStream GetStream(Image<Rgba32> image); | ||
void RemoveTileImage(string name); | ||
void Reset(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Yugen.Mosaic.Uwp.Interfaces | ||
{ | ||
public interface ISearchAndReplaceService | ||
{ | ||
void SearchAndReplace(); | ||
} | ||
} |
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
Oops, something went wrong.