-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Tiledmode to use with tilesets / chipsets added a simple nearestNeighbor filter
- Loading branch information
Showing
82 changed files
with
828 additions
and
90 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,51 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FilterWrapper.Filters.Simple | ||
{ | ||
class NearestN : IImageFilter | ||
{ | ||
List<Setting> settings = new List<Setting>(); | ||
|
||
SettingInteger scale = new SettingInteger("Scale", "Factor to scale", 2, 8, 2); | ||
|
||
public NearestN() { | ||
settings.Add(scale); | ||
} | ||
|
||
public IEnumerable<Setting> Settings | ||
{ | ||
get { | ||
return settings; | ||
} | ||
} | ||
|
||
public string Info | ||
{ | ||
get { | ||
return "Simple NearestNeighbor"; | ||
} | ||
} | ||
|
||
public string Name | ||
{ | ||
get { | ||
return "NearestNeighbor"; | ||
} | ||
} | ||
|
||
public FilterImage Execute(FilterImage input) { | ||
FilterImage newImage = new FilterImage(input.Width * scale.Value, input.Height * scale.Value); | ||
for (int x = 0; x < input.Width; x++) { | ||
for (int y = 0; y < input.Height; y++) { | ||
int argb = input.PixelArgb(x, y); | ||
for (int ix = 0; ix < scale.Value; ix++) { | ||
for (int iy = 0; iy < scale.Value; iy++) { | ||
newImage.SetPixelArgb(ix + x * scale.Value, iy + y * scale.Value, argb); | ||
} | ||
} | ||
} | ||
} | ||
return newImage; | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
FilterWrapper/obj/Debug/netstandard2.0/FilterWrapper.csproj.CoreCompileInputs.cache
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 |
---|---|---|
@@ -1 +1 @@ | ||
6cea6cf4370041ae4f7ff6649fa35a667f711cb0 | ||
124a0c664ae08c6e24eb8f0b168c978604712569 |
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
Binary file removed
BIN
-332 KB
FilterWrapper/obj/Debug/netstandard2.0/FilterWrapper.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
FilterWrapper/obj/Release/netstandard2.0/FilterWrapper.csproj.CoreCompileInputs.cache
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 |
---|---|---|
@@ -1 +1 @@ | ||
6cea6cf4370041ae4f7ff6649fa35a667f711cb0 | ||
124a0c664ae08c6e24eb8f0b168c978604712569 |
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
Binary file not shown.
Binary file modified
BIN
+764 Bytes
(100%)
FilterWrapper/obj/Release/netstandard2.0/FilterWrapper.pdb
Binary file not shown.
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,85 @@ | ||
| ||
using FilterWrapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
|
||
namespace ImageFilter | ||
{ | ||
public partial class MainWindow | ||
{ | ||
//check if the tilesize give into textbox is valid integer | ||
private void CheckTileSize(object sender, TextCompositionEventArgs e) { | ||
Regex regex = new Regex("[^0-9]+"); | ||
if (regex.IsMatch(((TextBox)sender).Text)) { | ||
((TextBox)sender).Text = ""; | ||
} | ||
if (regex.IsMatch(e.Text)) { | ||
e.Handled = true; | ||
return; | ||
} | ||
} | ||
|
||
private async Task ExecuteCurrentFilterTiled() { | ||
int tileSizeY; | ||
int tileSizeX; | ||
if (!int.TryParse(((TextBox)this.FindName("tileYbox")).Text, out tileSizeY) || !int.TryParse(((TextBox)this.FindName("tileXbox")).Text, out tileSizeX)) { | ||
MessageBox.Show("invalid tile dimensions"); | ||
return; | ||
} | ||
if (tileSizeX == 0 || tileSizeX > this.inputImage.Width || tileSizeY == 0 || tileSizeY > this.inputImage.Height) { | ||
MessageBox.Show("Tiles should be at least 1 pixel (x & y) and not bigger than the input image"); | ||
return; | ||
} | ||
|
||
converting = true; | ||
//maybe display its settings again to see the up to date settings | ||
DisplayCurrentFilterSettings(); | ||
|
||
PushProgress("Creating target Image", 1); | ||
//just run the converter with the first tile, to see how big the output tiles are | ||
Task<FilterImage> testConvertTask = Task.Run(() => this.currentFilter.Execute(this.inputImage.GrabSubImage(0, 0, tileSizeX, tileSizeY))); | ||
FilterImage testOutputFilterImage = await testConvertTask; | ||
|
||
int scaleX = testOutputFilterImage.Width / tileSizeX; | ||
int scaleY = testOutputFilterImage.Height / tileSizeY; | ||
FilterImage outputImage = new FilterImage(this.inputImage.Width * scaleX, this.inputImage.Height * scaleY); | ||
|
||
int offsetX; | ||
int offsetY = 0; | ||
int tilesProcessed = 1; | ||
int tilesToProcess = (inputImage.Height / tileSizeY) * (inputImage.Width / tileSizeX); | ||
while (offsetY <= inputImage.Height - tileSizeY) { | ||
offsetX = 0; | ||
while (offsetX <= inputImage.Width - tileSizeX) { | ||
PushProgress($"converting tile: {tilesProcessed} / {tilesToProcess}", 2); | ||
Task <FilterImage> convertTileTask = Task.Run(() => this.currentFilter.Execute(this.inputImage.GrabSubImage(offsetX, offsetY, tileSizeX, tileSizeY))); | ||
FilterImage iOutputTile = await convertTileTask; | ||
outputImage.PutImage(offsetX * scaleX, offsetY * scaleY, iOutputTile); | ||
offsetX += tileSizeX; | ||
tilesProcessed++; | ||
} | ||
offsetY += tileSizeY; | ||
} | ||
|
||
//convert the result back to bitmap | ||
PushProgress("Fetching result", 3); | ||
var outputTask = Task.Run(() => FilterImageConvert.BitmapFromFilterImage(outputImage)); | ||
var outputBitmap = await outputTask; | ||
|
||
//apply the output bitmap guiwise | ||
PushProgress("Rendering result", 3); | ||
SetOutputImage(outputBitmap); | ||
|
||
converting = false; | ||
|
||
} | ||
} | ||
} |
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
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-78 Bytes
(100%)
ImageFilter/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
Oops, something went wrong.