Skip to content

Commit

Permalink
Added "Delete Source" option for tiling, UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Oct 6, 2020
1 parent 3b2f4d2 commit 2d9382c
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 54 deletions.
Binary file modified .vs/MagickUtils/v16/.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions FormsHelpers/CropTabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static void CropPadding (TextBox pixMinBox, TextBox pixMaxBox, ComboBox m
CropUtils.CropPaddingDir(pixMin, pixMax, modeBox.SelectedIndex == 1);
}

public static void CropTiles (TextBox wBox, TextBox hBox, ComboBox modeBox)
public static void CropTiles (TextBox wBox, TextBox hBox, ComboBox modeBox, bool delSrc)
{
CropUtils.TileDir(wBox.GetInt(), hBox.GetInt(), modeBox.SelectedIndex == 1);
CropUtils.TileDir(wBox.GetInt(), hBox.GetInt(), modeBox.SelectedIndex == 1, delSrc);
}

public static Gravity GetGravity (int selectedIndex)
Expand Down
11 changes: 6 additions & 5 deletions MagickUtils/CropUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static void CropAbsolute (string path, int newWidth, int newHeight, Gravi
PostProcessing(img, path);
}

public static async void TileDir (int w, int h, bool useTileAmount)
public static async void TileDir (int w, int h, bool useTileAmount, bool delSrc)
{
int counter = 1;
FileInfo[] Files = IOUtils.GetFiles();
Expand All @@ -203,13 +203,13 @@ public static async void TileDir (int w, int h, bool useTileAmount)
{
Program.ShowProgress("Tiling Image ", counter, Files.Length);
counter++;
await Tile(file.FullName, w, h, useTileAmount);
await Tile(file.FullName, w, h, useTileAmount, delSrc);
if(counter % 2 == 0) await Program.PutTaskDelay();
}
Program.PostProcessing();
}

public static async Task Tile (string path, int tileW, int tileH, bool useTileAmount)
public static async Task Tile (string path, int tileW, int tileH, bool useTileAmount, bool delSrc)
{
MagickImage img = IOUtils.ReadImage(path);
PreProcessing(path);
Expand All @@ -224,8 +224,7 @@ public static async Task Tile (string path, int tileW, int tileH, bool useTileAm
}

int i = 1;
Program.Print("-> Creating tiles... (CropToTiles(" + tileW + ", " + tileH + "))");
//Program.Print("-> Tile size: " + w + "x" + h);
Program.Print("-> Creating tiles...");
var tiles = img.CropToTiles(tileW, tileH);
foreach(MagickImage tile in tiles)
{
Expand All @@ -236,6 +235,8 @@ public static async Task Tile (string path, int tileW, int tileH, bool useTileAm
}
await Program.PutTaskDelay();
PostProcessing(img, path);
if(delSrc)
DelSource(path);
}

public static async void MergeAllDir ()
Expand Down
122 changes: 76 additions & 46 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private void MainForm_Load (object sender, EventArgs e)
InitCombox(scaleResampleCombox, 0);
InitCombox(scaleModeCombox, 0);
InitCombox(filterModeCombox, 0);
// Crop/Expand/Tile
InitCombox(cropRelSizeMode, 0);
InitCombox(cropAbsGrav, 1);
InitCombox(cropDivisibleGrav, 1);
InitCombox(padMode, 0);

IOUtils.recursive = recursiveCbox.Checked;
ScaleUtils.onlyDownscale = onlyDownscaleCbox.Checked;
Expand Down Expand Up @@ -492,7 +497,7 @@ private void cropBtn_Click(object sender, EventArgs e)
if(cropTabControl.SelectedIndex == 3)
CropTabHelper.CropPadding(padPixMin, padPixMax, padMode);
if(cropTabControl.SelectedIndex == 4)
CropTabHelper.CropTiles(tilingW, tilingH, tileMode);
CropTabHelper.CropTiles(tilingW, tilingH, tileMode, tileDelSrc.Checked);
}

private void tabPage7_DragEnter (object sender, DragEventArgs e)
Expand Down
Binary file modified bin/x64/Debug/MagickUtils.exe
Binary file not shown.
Binary file modified bin/x64/Debug/MagickUtils.pdb
Binary file not shown.
Binary file modified obj/x64/Debug/MagickUtils.csproj.GenerateResource.cache
Binary file not shown.
Binary file modified obj/x64/Debug/MagickUtils.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified obj/x64/Debug/MagickUtils.exe
Binary file not shown.
Binary file modified obj/x64/Debug/MagickUtils.pdb
Binary file not shown.

0 comments on commit 2d9382c

Please sign in to comment.