implemented #21

This commit is contained in:
Manuel Kamper 2024-08-19 09:51:28 +02:00
parent 17a71f1317
commit ce1a828711
6 changed files with 58 additions and 6 deletions

View File

@ -10,17 +10,28 @@ namespace Mk0.Software.ImageSorter
private string imagePath;
public string newFilePath { get; set; }
public Konverter(string imagePath, bool auto = false, string autoFormat = "")
public Konverter(string imagePath, bool auto = false, MagickFormat autoFormat = MagickFormat.Png)
{
InitializeComponent();
this.imagePath = imagePath;
labelBildname.Text = imagePath;
comboBoxFormat.SelectedIndex = 0;
if (auto)
{
using (MagickImage image = new MagickImage(imagePath))
{
image.Format = autoFormat;
newFilePath = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath) + "." + autoFormat.ToString().ToLower());
image.Write(newFilePath);
}
}
else
{
InitializeComponent();
labelBildname.Text = imagePath;
comboBoxFormat.SelectedIndex = 0;
}
}
private void ButtonKonvert_Click(object sender, EventArgs e)
{
//todo konvertieren
using (MagickImage image = new MagickImage(imagePath))
{
if (comboBoxFormat.SelectedItem == "PNG")

View File

@ -1292,7 +1292,23 @@ namespace Mk0.Software.ImageSorter
/// <param name="e"></param>
private void PictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
Zoom();
if (e.Error != null && Path.GetExtension(pictureBoxImage.ImageLocation).ToLower() == ".webp")
{
Konverter k = new Konverter(pictureBoxImage.ImageLocation, true);
if (File.Exists(k.newFilePath))
{
string del = pictureBoxImage.ImageLocation;
images[imageIndex] = k.newFilePath;
LoadPicture(imageIndex);
FileSystem.DeleteFile(del, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin, UICancelOption.DoNothing);
Image myImg = CopyImage.GetCopyImage(k.newFilePath);
ShowAutoConvertMessage(myImg, k.newFilePath);
}
}
else
{
Zoom();
}
}
/// <summary>
@ -1470,6 +1486,17 @@ namespace Mk0.Software.ImageSorter
banner.ShowMessages();
}
/// <summary>
/// Anzeige eines Banners bei automatischem Konvertieren von WEBP-Bildern
/// </summary>
/// <param name="bild"></param>
/// <param name="bildpfad"></param>
private void ShowAutoConvertMessage(Image bild, string bildpfad)
{
banner.Enqueue("Das WEBP-Bild \"" + Path.GetFileName(bildpfad) + "\" wurde", "automatisch konvertiert.", bild, Properties.Resources.converted);
banner.ShowMessages();
}
/// <summary>
/// Anzeige eines Banners bei erstelltem Duplikat
/// </summary>

View File

@ -231,6 +231,7 @@
<None Include="Resources\border-2-topbottom-icon.png" />
<None Include="Resources\border-2-leftright-icon.png" />
<None Include="Resources\border-2-all-icon.png" />
<None Include="Resources\converted.png" />
<Content Include="Resources\heic.ico" />
<None Include="Resources\inpaint-icon.png" />
<None Include="Resources\inpaint-reloadfile.png" />

View File

@ -220,6 +220,16 @@ namespace Mk0.Software.ImageSorter.Properties {
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap converted {
get {
object obj = ResourceManager.GetObject("converted", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>

View File

@ -259,4 +259,7 @@
<data name="inpaint_reloadfile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\inpaint-reloadfile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="converted" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\converted.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB