Tasks and resize
This commit is contained in:
parent
0d8ab38efd
commit
27a2affc19
2 changed files with 64 additions and 12 deletions
|
|
@ -9,6 +9,7 @@ using MaddoLibrary.Base.Log;
|
|||
using SixLabors.Fonts;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Drawing;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using Font = SixLabors.Fonts.Font;
|
||||
using FontFamily = SixLabors.Fonts.FontFamily;
|
||||
using FontStyle = SixLabors.Fonts.FontStyle;
|
||||
|
|
@ -32,6 +33,9 @@ namespace CatalogLib
|
|||
MaddoLogger.Log("Loaded Image: {0}", workFile.FullName);
|
||||
//image.Rotate(-90);
|
||||
|
||||
//if (PicSettings.Instance.r)
|
||||
image.Mutate(x => x.Resize(PicSettings.Instance.FotoAltezza, PicSettings.Instance.FotoLarghezza, new BoxResampler()));
|
||||
|
||||
if (PicSettings.Instance.GeneraleRotazioneAutomatica)
|
||||
{
|
||||
image.Mutate(img => img.AutoOrient());
|
||||
|
|
@ -115,7 +119,7 @@ namespace CatalogLib
|
|||
//image.DrawText("sssssssssssssssssssssssssssssssssssssssssssssss", font, Color.Black, new Vector2(200, 200));
|
||||
image.Save(Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
|
||||
//image.Resize(200, 200).Save("");
|
||||
|
||||
|
||||
MaddoLogger.Log("Saved Image: {0} to: {1}", workFile.FullName, Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +160,13 @@ namespace CatalogLib
|
|||
float scalingFactor = Math.Min(image.Width / size.Width, image.Height / size.Height);
|
||||
Font scaledFont = new Font(font, scalingFactor * font.Size);
|
||||
|
||||
image.Mutate(x => x.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center, new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }));
|
||||
image.Mutate(x =>
|
||||
x.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center,
|
||||
new TextGraphicsOptions(true)
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Bottom
|
||||
}));
|
||||
//image.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center, new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom });
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using CatalogLib;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using MaddoLibrary.Base.Log;
|
||||
using MaddoLibrary.Helpers;
|
||||
using WPFCatalog.Messages;
|
||||
|
||||
|
|
@ -76,19 +77,60 @@ namespace WPFCatalog
|
|||
//string s = d.Name;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
private struct ImageTask
|
||||
{
|
||||
public Task TaskImage;
|
||||
public string ImageName;
|
||||
public bool Completed;
|
||||
}
|
||||
|
||||
//private List<ImageTask> _tasks;
|
||||
private async void Start()
|
||||
{
|
||||
Task outerTask = new Task(() =>
|
||||
{
|
||||
var tasks = new List<Task>();
|
||||
// todo folder mode
|
||||
MaddoLogger.Log("Starting elaboration");
|
||||
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
|
||||
{
|
||||
//Task t = new Task(() =>
|
||||
//{
|
||||
|
||||
// //CompleteFile(file);
|
||||
//});
|
||||
tasks.Add(FileTask(file));
|
||||
//_tasks.Add(new ImageTask() { ImageName = file, TaskImage = t, Completed = false });
|
||||
//t.Start();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Task.WhenAll(tasks).Start();
|
||||
|
||||
//tt.RunSynchronously();
|
||||
MaddoLogger.Log("Finished");
|
||||
DialogHelper.PopUpAlert("Finished", "message");
|
||||
});
|
||||
|
||||
|
||||
outerTask.Start();
|
||||
}
|
||||
|
||||
private Task FileTask(string file)
|
||||
{
|
||||
MaddoLogger.Log("Starting task for image {0}", file);
|
||||
IImageProcessor i = new ImgSharpCreator();
|
||||
|
||||
//ImageCreator2 i = new ImageCreator2();
|
||||
i.Start(new FileInfo(file));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void CompleteFile(string file)
|
||||
{
|
||||
|
||||
// todo folder mode
|
||||
|
||||
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
|
||||
{
|
||||
IImageProcessor i = new ImgSharpCreator();
|
||||
|
||||
//ImageCreator2 i = new ImageCreator2();
|
||||
i.Start(new FileInfo(file));
|
||||
}
|
||||
DialogHelper.PopUpAlert("Finished", "message");
|
||||
}
|
||||
|
||||
private void OpenSourceFolder()
|
||||
|
|
@ -687,7 +729,7 @@ namespace WPFCatalog
|
|||
|
||||
|
||||
public string ColoreTestoRGB
|
||||
{
|
||||
{
|
||||
get { return PicSettings.ColoreTestoRGB; }
|
||||
set
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue