Skip to content

Commit

Permalink
Added DDS compression and mipmap options
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Sep 21, 2020
1 parent c8fdbf7 commit 5f1c94f
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 47 deletions.
155 changes: 108 additions & 47 deletions Code/Forms/SettingsForm.Designer.cs

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

4 changes: 4 additions & 0 deletions Code/Forms/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void LoadSettings ()

Config.LoadGuiElement(jpegQ);
Config.LoadGuiElement(webpQ);
Config.LoadGuiElement(ddsUseDxt);
Config.LoadGuiElement(ddsMipsAmount);
}

private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
Expand All @@ -61,6 +63,8 @@ void SaveSettings()

Config.SaveGuiElement(jpegQ);
Config.SaveGuiElement(webpQ);
Config.SaveGuiElement(ddsUseDxt);
Config.SaveGuiElement(ddsMipsAmount);
}

private void confAlphaBgColorBtn_Click(object sender, EventArgs e)
Expand Down
2 changes: 2 additions & 0 deletions Code/IO/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ private static string WriteDefaultValIfExists(string key)
"useCpu" => WriteDefault("useCpu", "False"),
"jpegQ" => WriteDefault("jpegQ", "95"),
"webpQ" => WriteDefault("webpQ", "95"),
"ddsUseDxt" => WriteDefault("ddsUseDxt", "True"),
"ddsMipsAmount" => WriteDefault("ddsMipsAmount", "0"),
_ => null,
};
}
Expand Down
7 changes: 7 additions & 0 deletions Code/ImageUtils/ImageProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Windows.Forms;
using Cupscale.IO;
using ImageMagick;
using ImageMagick.Formats.Bmp;
using ImageMagick.Formats.Dds;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using Paths = Cupscale.IO.Paths;
Expand Down Expand Up @@ -147,6 +149,11 @@ public static async Task ConvertImage(string path, Format format, bool fillAlpha
{
img.Format = MagickFormat.Dds;
ext = "dds";
DdsCompression comp = DdsCompression.None;
if(Config.GetBool("ddsUseDxt"))
comp = DdsCompression.Dxt1;
DdsWriteDefines ddsDefines = new DdsWriteDefines { Compression = comp, Mipmaps = Config.GetInt("ddsMipsAmount") };
img.Settings.SetDefines(ddsDefines);
}
if (fillAlpha)
{
Expand Down

0 comments on commit 5f1c94f

Please sign in to comment.