diff --git a/Readme.md b/Readme.md index 5675e4c..c5dcb8e 100644 --- a/Readme.md +++ b/Readme.md @@ -8,16 +8,16 @@ A combination tool for managing Terraria content resources. Convert, extract, backup, and restore. The unofficial sequel to TExtract. -![Window Preview](http://i.imgur.com/oTuVrGQ.png) +![Window Preview](https://i.imgur.com/oTuVrGQ.png) -### [Wiki](https://github.com/trigger-death/TConvert/wiki) | [Credits](https://github.com/trigger-death/TConvert/wiki/Credits) | [Image Album](http://imgur.com/a/QaoPd) +### [Wiki](https://github.com/trigger-death/TConvert/wiki) | [Credits](https://github.com/trigger-death/TConvert/wiki/Credits) | [Image Album](https://imgur.com/a/QaoPd) ### [![Get TConvert](http://i.imgur.com/4BGRFF0.png)](https://github.com/trigger-death/TConvert/releases/latest) ## About * **Created By:** Robert Jordan -* **Version:** 1.0.1.0 +* **Version:** 1.0.2.0 * **Language:** C#, WPF ## Requirements for Running diff --git a/TConvert/App.config b/TConvert/App.config index af2dfb1..e02e280 100644 --- a/TConvert/App.config +++ b/TConvert/App.config @@ -98,6 +98,9 @@ True + + True + \ No newline at end of file diff --git a/TConvert/App.xaml.cs b/TConvert/App.xaml.cs index 8f7ddac..15d9b6e 100644 --- a/TConvert/App.xaml.cs +++ b/TConvert/App.xaml.cs @@ -41,7 +41,7 @@ private Assembly OnResolveAssemblies(object sender, ResolveEventArgs args) { string path = assemblyName.Name + ".dll"; if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false) { - path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path); + path = string.Format(@"{0}\{1}", assemblyName.CultureInfo, path); } using (Stream stream = executingAssembly.GetManifestResourceStream(path)) { diff --git a/TConvert/CommandLine.cs b/TConvert/CommandLine.cs index 18acf5c..3a0f6be 100644 --- a/TConvert/CommandLine.cs +++ b/TConvert/CommandLine.cs @@ -40,7 +40,9 @@ private enum ArgTypes { //AutoCloseDef= 0x4000, //KeepOpenDef = 0x8000, Compress = 0x10000, - DontCompress= 0x20000 + DontCompress= 0x20000, + Premultiply = 0x40000, + DontPremultiply = 0x80000, } /**Information about a command line option.*/ @@ -96,6 +98,8 @@ public string OptionsToString() { { ArgTypes.Compress,new OptionInfo(ProcessCompress, "Compress", "Images will be compressed.", null, "-ic", "--compress") }, { ArgTypes.DontCompress,new OptionInfo(ProcessDontCompress, "Don't Compress", "Images will not be compressed.", null, "-dc", "--dont-compress") }, + { ArgTypes.Premultiply, new OptionInfo(ProcessPremultiply, "Premultiply", "RGB will be multiplied by alpha.", null, "-pr", "--premult") }, + { ArgTypes.DontPremultiply, new OptionInfo(ProcessDontPremultiply, "Don't Premultiply", "RGB will not be modified.", null, "-dp", "--dont-premult") }, }; #endregion @@ -124,6 +128,8 @@ public string OptionsToString() { private static bool autoClose = Settings.Default.AutoCloseCmdProgress; /**True if images are compressed.*/ private static bool compress = Settings.Default.CompressImages && XCompress.IsAvailable; + /**True if alpha is premultiplied.*/ + private static bool premultiply = Settings.Default.PremultiplyAlpha; /**True if a sound is played upon completion.*/ private static bool sound = Settings.Default.CompletionSound; /**True if in console-only mode.*/ @@ -335,12 +341,12 @@ public static void ProcessFiles() { }); #if !(CONSOLE) if (!console) { - Processing.StartProgressThread(null, "Processing Files...", autoClose, compress, sound, thread); + Processing.StartProgressThread(null, "Processing Files...", autoClose, compress, sound, premultiply, thread); } else #endif { - Processing.StartConsoleThread("Processing Files...", silent, compress, sound, thread); + Processing.StartConsoleThread("Processing Files...", silent, compress, sound, premultiply, thread); } } @@ -554,6 +560,24 @@ private static void ProcessDontCompress() { else compress = false; } + /**Processes the Premultiply option.*/ + private static void ProcessPremultiply() { + if (passedArgs.HasFlag(ArgTypes.Premultiply)) + LogOptionAlreadySpecified(ArgTypes.Premultiply); + if (passedArgs.HasFlag(ArgTypes.DontPremultiply)) + LogOptionAlreadySpecified(ArgTypes.DontPremultiply); + else + premultiply = true; + } + /**Processes the Premultiply option.*/ + private static void ProcessDontPremultiply() { + if (passedArgs.HasFlag(ArgTypes.Premultiply)) + LogOptionAlreadySpecified(ArgTypes.Premultiply); + if (passedArgs.HasFlag(ArgTypes.DontPremultiply)) + LogOptionAlreadySpecified(ArgTypes.DontPremultiply); + else + premultiply = false; + } #endregion //-------------------------------- diff --git a/TConvert/Config.cs b/TConvert/Config.cs index af1540b..a525b30 100644 --- a/TConvert/Config.cs +++ b/TConvert/Config.cs @@ -39,6 +39,8 @@ public static class Config { public static bool CompressImages { get; set; } /**True if a sound is played on completion.*/ public static bool CompletionSound { get; set; } + /**True if alpha is premultiplied by default when converting to xnb.*/ + public static bool PremultiplyAlpha { get; set; } #endregion //=========== CLASSES ============ @@ -181,6 +183,7 @@ public static void Load() { AutoCloseCmdProgress = Settings.Default.AutoCloseCmdProgress; CompressImages = Settings.Default.CompressImages && XCompress.IsAvailable; CompletionSound = Settings.Default.CompletionSound; + PremultiplyAlpha = Settings.Default.PremultiplyAlpha; Extract.FolderInput = Settings.Default.ExtractFolderInput; Extract.FolderOutput = Settings.Default.ExtractFolderOutput; @@ -224,6 +227,7 @@ public static void Save() { Settings.Default.AutoCloseCmdProgress = AutoCloseCmdProgress; Settings.Default.CompressImages = CompressImages; Settings.Default.CompletionSound = CompletionSound; + Settings.Default.PremultiplyAlpha = PremultiplyAlpha; Settings.Default.ExtractFolderInput = Extract.FolderInput; Settings.Default.ExtractFolderOutput = Extract.FolderOutput; diff --git a/TConvert/Convert/PngConverter.cs b/TConvert/Convert/PngConverter.cs index baf71a0..1a4b341 100644 --- a/TConvert/Convert/PngConverter.cs +++ b/TConvert/Convert/PngConverter.cs @@ -53,7 +53,7 @@ public class PngConverter { #region Converting /**Converts the specified input file and writes it to the output file.*/ - public static bool Convert(string inputFile, string outputFile, bool changeExtension, bool compressed, bool reach) { + public static bool Convert(string inputFile, string outputFile, bool changeExtension, bool compressed, bool reach, bool premultiply) { if (changeExtension) { outputFile = Path.ChangeExtension(outputFile, ".xnb"); } @@ -80,11 +80,11 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten } writer.Write(flagBits); // flag-bits; 00=reach, 01=hiprofile, 80=compressed, 00=uncompressed if (compressed) { - WriteCompressedData(writer, bmp); + WriteCompressedData(writer, bmp, premultiply); } else { writer.Write(MetadataSize + bmp.Width * bmp.Height * 4); // compressed file size - WriteData(bmp, writer); + WriteData(bmp, writer, premultiply); } } } @@ -97,11 +97,11 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten #region Writing /**Write compressed image data.*/ - private static void WriteCompressedData(BinaryWriter writer, Bitmap png) { + private static void WriteCompressedData(BinaryWriter writer, Bitmap png, bool premultiply) { using (MemoryStream stream = new MemoryStream()) { byte[] uncompressedData; using (BinaryWriter writer2 = new BinaryWriter(stream)) { - WriteData(png, writer2); + WriteData(png, writer2, premultiply); uncompressedData = stream.ToArray(); } byte[] compressedData = XCompress.Compress(uncompressedData); @@ -111,7 +111,7 @@ private static void WriteCompressedData(BinaryWriter writer, Bitmap png) { } } /**Write uncompressed image data.*/ - private static void WriteData(Bitmap bmp, BinaryWriter writer) { + private static void WriteData(Bitmap bmp, BinaryWriter writer, bool premultiply) { writer.Write7BitEncodedInt(1); // type-reader-count writer.Write7BitEncodedString(Texture2DType); // type-reader-name writer.Write((int)0); // reader version number @@ -130,14 +130,30 @@ private static void WriteData(Bitmap bmp, BinaryWriter writer) { } BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); try { - var length = bitmapData.Stride * bitmapData.Height; + int length = bitmapData.Stride * bitmapData.Height; byte[] bytes = new byte[length]; Marshal.Copy(bitmapData.Scan0, bytes, 0, length); - // Swap the R and B channels for (int i = 0; i < bytes.Length; i += 4) { - byte b = bytes[i]; - bytes[i] = bytes[i + 2]; - bytes[i + 2] = b; + // Always swap red and blue channels premultiply alpha if requested + int a = bytes[i + 3]; + if (!premultiply || a == 255) { + // No premultiply necessary + byte b = bytes[i]; + bytes[i] = bytes[i + 2]; + bytes[i + 2] = b; + } + else if (a != 0) { + byte b = bytes[i]; + bytes[i] = (byte) (bytes[i + 2] * a / 255); + bytes[i + 1] = (byte) (bytes[i + 1] * a / 255); + bytes[i + 2] = (byte) (b * a / 255); + } + else { + // alpha is zero, so just zero everything + bytes[i] = 0; + bytes[i + 1] = 0; + bytes[i + 2] = 0; + } } writer.Write(bytes); } diff --git a/TConvert/Convert/WavConverter.cs b/TConvert/Convert/WavConverter.cs index 423d157..6adcd72 100644 --- a/TConvert/Convert/WavConverter.cs +++ b/TConvert/Convert/WavConverter.cs @@ -97,8 +97,7 @@ public static bool Convert(string inputFile, string outputFile, bool changeExten throw new WavException("Average bytes per second number incorrect."); if (nBlockAlign != (nChannels * (wBitsPerSample / 8))) throw new WavException("Block align number incorrect."); - - + inputStream.Position = chunkSize; format = new string(reader.ReadChars(4)); diff --git a/TConvert/Extract/Ffmpeg.cs b/TConvert/Extract/Ffmpeg.cs index 243f4cf..fd409ca 100644 --- a/TConvert/Extract/Ffmpeg.cs +++ b/TConvert/Extract/Ffmpeg.cs @@ -61,8 +61,6 @@ public static bool Convert(string input, string output) { "-acodec pcm_s16le " + "-nostdin " + "-ab 128k " + - //"-fflags +bitexact -flags:a +bitexact " + - //"-metadata title=\"\" " + "-map_metadata -1 " + "-y " + "\"" + Path.GetFullPath(output) + "\""; diff --git a/TConvert/MainWindow.xaml b/TConvert/MainWindow.xaml index aab4bcb..2965e7d 100644 --- a/TConvert/MainWindow.xaml +++ b/TConvert/MainWindow.xaml @@ -44,6 +44,11 @@ + + + + + diff --git a/TConvert/MainWindow.xaml.cs b/TConvert/MainWindow.xaml.cs index d9e637c..3b3a220 100644 --- a/TConvert/MainWindow.xaml.cs +++ b/TConvert/MainWindow.xaml.cs @@ -144,6 +144,7 @@ private void LoadConfig() { menuItemCompressImages.IsEnabled = XCompress.IsAvailable; menuItemCompressImages.IsChecked = Config.CompressImages; + menuItemPremultiply.IsChecked = Config.PremultiplyAlpha; menuItemCompletionSound.IsChecked = Config.CompletionSound; menuItemAutoCloseProgress.IsChecked = Config.AutoCloseProgress; menuItemAutoCloseDropProgress.IsChecked = Config.AutoCloseDropProgress; @@ -251,7 +252,7 @@ private void OnExtract(object sender, RoutedEventArgs e) { Processing.ExtractSingleFile(input, output); }); } - Processing.StartProgressThread(this, "Extracting...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Extracting...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } private void OnExtractModeChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) @@ -374,7 +375,7 @@ private void OnConvert(object sender, RoutedEventArgs e) { Processing.ConvertSingleFile(input, output); }); } - Processing.StartProgressThread(this, "Converting...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Converting...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } private void OnConvertModeChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) @@ -471,7 +472,7 @@ private void OnBackup(object sender, RoutedEventArgs e) { Thread thread = new Thread(() => { Processing.BackupFiles(input, output); }); - Processing.StartProgressThread(this, "Backing Up...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Backing Up...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } private void OnRestore(object sender, RoutedEventArgs e) { string input = Config.Backup.FolderBackup; @@ -495,7 +496,7 @@ private void OnRestore(object sender, RoutedEventArgs e) { Thread thread = new Thread(() => { Processing.RestoreFiles(input, output); }); - Processing.StartProgressThread(this, "Restoring...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Restoring...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } private void OnBackupChangeContent(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); @@ -556,7 +557,7 @@ private void OnRunScript(object sender, RoutedEventArgs e) { thread = new Thread(() => { Processing.RunScript(input); }); - Processing.StartProgressThread(this, "Running Script...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Running Script...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } private void OnChangeScript(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); @@ -648,7 +649,7 @@ private void OnFileDrop(object sender, DragEventArgs e) { Thread thread = new Thread(() => { Processing.ProcessDropFiles(extractFiles.ToArray(), convertFiles.ToArray(), scriptFiles.ToArray()); }); - Processing.StartProgressThread(this, "Processing Drop Files...", Config.AutoCloseDropProgress, Config.CompressImages, Config.CompletionSound, thread); + Processing.StartProgressThread(this, "Processing Drop Files...", Config.AutoCloseDropProgress, Config.CompressImages, Config.CompletionSound, Config.PremultiplyAlpha, thread); } } } @@ -730,6 +731,11 @@ private void OnExit(object sender, RoutedEventArgs e) { Close(); } + private void OnPremultiplyAlphaChecked(object sender, RoutedEventArgs e) { + if (!loaded) + return; + Config.PremultiplyAlpha = menuItemPremultiply.IsChecked; + } private void OnCompressImagesChecked(object sender, RoutedEventArgs e) { if (!loaded) return; diff --git a/TConvert/Processing.cs b/TConvert/Processing.cs index 32e56ed..0b9c961 100644 --- a/TConvert/Processing.cs +++ b/TConvert/Processing.cs @@ -43,17 +43,21 @@ public struct PathPair { public string Output; /**True if compression should be used.*/ public bool Compress; + /**True if alpha is premultiplied.*/ + public bool Premultiply; /**Constructs a path pair.*/ public PathPair(string input, string output) { Input = input; Output = output; Compress = false; + Premultiply = true; } /**Constructs a path pair.*/ - public PathPair(string input, string output, bool compress) { + public PathPair(string input, string output, bool compress, bool premultiply) { Input = input; Output = output; Compress = compress; + Premultiply = premultiply; } } /**A loaded script.*/ @@ -106,6 +110,8 @@ public static class Processing { private static bool compressImages = true; /**True if a sound is played upon completion.*/ private static bool completionSound; + /**True if alpha is premultiplied when converting back to xnb.*/ + private static bool premultiplyAlpha = true; #endregion //-------------------------------- @@ -119,28 +125,29 @@ public static class Processing { private static bool silent; /**The start time of the console operation.*/ private static DateTime startTime; - + #endregion //-------------------------------- #region Window Only - #if !(CONSOLE) +#if !(CONSOLE) private static ProgressWindow progressWindow; private static bool autoCloseProgress; private static bool console = false; - #endif - +#endif + #endregion //-------------------------------- #endregion //=========== STARTING =========== #region Starting - #if !(CONSOLE) +#if !(CONSOLE) /**Starts a progress window processing thread.*/ - public static void StartProgressThread(Window owner, string message, bool autoClose, bool compress, bool sound, Thread thread) { + public static void StartProgressThread(Window owner, string message, bool autoClose, bool compress, bool sound, bool premultiply, Thread thread) { console = false; compressImages = compress; + premultiplyAlpha = premultiply; completionSound = sound; lastUpdate = DateTime.MinValue; autoCloseProgress = autoClose; @@ -162,14 +169,15 @@ public static void StartProgressThread(Window owner, string message, bool autoCl }); showThread.Start(); } - #endif +#endif /**Starts a console processing thread.*/ - public static void StartConsoleThread(string message, bool silent, bool compress, bool sound, Thread thread) { + public static void StartConsoleThread(string message, bool silent, bool compress, bool sound, bool premultiply, Thread thread) { #if !(CONSOLE) console = true; #endif - completionSound = sound; compressImages = compress; + premultiplyAlpha = premultiply; + completionSound = sound; Processing.silent = silent; startTime = DateTime.Now; lastUpdate = DateTime.MinValue; @@ -647,7 +655,7 @@ private static bool ConvertFile(string inputFile, string inputDirectory, string } if ((ext == ".png" || ext == ".bmp" || ext == ".jpg") && includeImages) { Helpers.CreateDirectorySafe(Path.GetDirectoryName(outputFile)); - if (PngConverter.Convert(inputFile, outputFile, true, compressImages, true)) + if (PngConverter.Convert(inputFile, outputFile, true, compressImages, true, premultiplyAlpha)) converted = true; } else if (IsAudioExtension(ext) && includeSounds) { @@ -692,7 +700,7 @@ private static bool ConvertFile2(string inputFile, string outputFile, bool compr } if (ext == ".png" || ext == ".bmp" || ext == ".jpg") { Helpers.CreateDirectorySafe(Path.GetDirectoryName(outputFile)); - if (PngConverter.Convert(inputFile, outputFile, true, compress, true)) + if (PngConverter.Convert(inputFile, outputFile, true, compress, true, premultiplyAlpha)) converted = true; } else if (IsAudioExtension(ext)) { @@ -873,7 +881,7 @@ public static Script LoadScript(string inputScript) { // Find all the files and restores if (root != null) { - LoadScriptFolder(root, files, backups, restores, "", "", compressImages, true); + LoadScriptFolder(root, files, backups, restores, "", "", compressImages, premultiplyAlpha, true); } else { LogError("Reading Script", "No root element TConvertScript."); @@ -900,9 +908,10 @@ public static Script LoadScript(string inputScript) { return new Script { Extracts=extracts, Converts=converts, Backups=backups, Restores=restores }; } /**Loads a script folder or root element.*/ - private static void LoadScriptFolder(XmlElement element, List files, List backups, List restores, string output, string path, bool compress, bool isRoot = false) { + private static void LoadScriptFolder(XmlElement element, List files, List backups, List restores, string output, string path, bool compress, bool premultiply, bool isRoot = false) { string newOutput = output; bool newCompress = compress; + bool newPremultiply = premultiply; XmlAttribute attribute; foreach (XmlNode nextNode in element) { XmlElement next = nextNode as XmlElement; @@ -922,6 +931,19 @@ private static void LoadScriptFolder(XmlElement element, List files, L LogWarning("Reading Script", "No Value attribute in Compress."); } break; + case "Premultiply": + attribute = next.Attributes["Value"]; + if (attribute != null) { + bool nextPremultiply; + if (bool.TryParse(attribute.InnerText, out nextPremultiply)) + newPremultiply = nextPremultiply; + else + LogWarning("Reading Script", "Failed to parse Value attribute in Premultiply: '" + attribute.InnerText + "'."); + } + else { + LogWarning("Reading Script", "No Value attribute in Premultiply."); + } + break; case "Backup": attribute = next.Attributes["Path"]; if (attribute != null) { @@ -986,7 +1008,7 @@ private static void LoadScriptFolder(XmlElement element, List files, L nextPath = attribute.InnerText; else nextPath = Path.Combine(path, attribute.InnerText); - LoadScriptFolder(next, files, backups, restores, newOutput, nextPath, newCompress); + LoadScriptFolder(next, files, backups, restores, newOutput, nextPath, newCompress, newPremultiply); } else { LogWarning("Reading Script", "Invalid Path attribute in Folder: '" + attribute.InnerText + "'."); @@ -1002,6 +1024,7 @@ private static void LoadScriptFolder(XmlElement element, List files, L if (Helpers.IsPathValid(attribute.InnerText)) { string nextPath; bool nextCompress = newCompress; + bool nextPremultiply = true; if (path == string.Empty) nextPath = attribute.InnerText; else @@ -1013,6 +1036,13 @@ private static void LoadScriptFolder(XmlElement element, List files, L nextCompress = newCompress; } } + attribute = next.Attributes["Premultiply"]; + if (attribute != null) { + if (!bool.TryParse(attribute.InnerText, out nextPremultiply)) { + LogWarning("Reading Script", "Failed to parse Premultiply attribute in Out: '" + attribute.InnerText + "'."); + nextPremultiply = true; + } + } attribute = next.Attributes["OutPath"]; if (attribute != null) { if (Helpers.IsPathValid(attribute.InnerText)) { @@ -1021,13 +1051,13 @@ private static void LoadScriptFolder(XmlElement element, List files, L nextOutput = Helpers.FixPathSafe(attribute.InnerText); else nextOutput = Path.Combine(newOutput, attribute.InnerText); - files.Add(new PathPair(nextPath, nextOutput, nextCompress)); + files.Add(new PathPair(nextPath, nextOutput, nextCompress, nextPremultiply)); } else { LogWarning("Reading Script", "Invalid OutPath attribute in File: '" + attribute.InnerText + "'."); ; } } - LoadScriptFile(next, files, newOutput, nextPath, nextCompress); + LoadScriptFile(next, files, newOutput, nextPath, nextCompress, nextPremultiply); } else { LogWarning("Reading Script", "Invalid Path attribute in File: '" + attribute.InnerText + "'."); @@ -1044,9 +1074,10 @@ private static void LoadScriptFolder(XmlElement element, List files, L } } /**Loads a script file.*/ - private static void LoadScriptFile(XmlElement element, List files, string output, string path, bool compress) { + private static void LoadScriptFile(XmlElement element, List files, string output, string path, bool compress, bool premultiply) { string newOutput = output; bool newCompress = compress; + bool newPremultiply = premultiply; XmlAttribute attribute; foreach (XmlNode nextNode in element) { XmlElement next = nextNode as XmlElement; @@ -1066,6 +1097,19 @@ private static void LoadScriptFile(XmlElement element, List files, str LogWarning("Reading Script", "No Value attribute in Compress."); } break; + case "Premultiply": + attribute = next.Attributes["Value"]; + if (attribute != null) { + bool nextPremultiply; + if (bool.TryParse(attribute.InnerText, out nextPremultiply)) + newPremultiply = nextPremultiply; + else + LogWarning("Reading Script", "Failed to parse Value attribute in Premultiply: '" + attribute.InnerText + "'."); + } + else { + LogWarning("Reading Script", "No Value attribute in Premultiply."); + } + break; case "Output": attribute = next.Attributes["Path"]; if (attribute != null) { @@ -1089,6 +1133,7 @@ private static void LoadScriptFile(XmlElement element, List files, str if (Helpers.IsPathValid(attribute.InnerText)) { string nextOutput; bool nextCompress = newCompress; + bool nextPremultiply = newPremultiply; if (newOutput == string.Empty) nextOutput = attribute.InnerText; else @@ -1100,7 +1145,14 @@ private static void LoadScriptFile(XmlElement element, List files, str nextCompress = newCompress; } } - files.Add(new PathPair(path, nextOutput, nextCompress)); + attribute = next.Attributes["Premultiply"]; + if (attribute != null) { + if (!bool.TryParse(attribute.InnerText, out nextPremultiply)) { + LogWarning("Reading Script", "Failed to parse Premultiply attribute in Out: '" + attribute.InnerText + "'."); + nextPremultiply = newPremultiply; + } + } + files.Add(new PathPair(path, nextOutput, nextCompress, nextPremultiply)); } else { LogWarning("Reading Script", "Invalid Path attribute in Out: '" + attribute.InnerText + "'."); diff --git a/TConvert/Properties/AssemblyInfo.cs b/TConvert/Properties/AssemblyInfo.cs index 8ef01f1..138647d 100644 --- a/TConvert/Properties/AssemblyInfo.cs +++ b/TConvert/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Trigger's Tools & Games")] [assembly: AssemblyProduct("TConvert")] -[assembly: AssemblyCopyright("Copyright © Robert Jordan 2017")] +[assembly: AssemblyCopyright("Copyright © Robert Jordan 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -55,8 +55,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.0")] -[assembly: AssemblyFileVersion("1.0.1.0")] +[assembly: AssemblyVersion("1.0.2.0")] +[assembly: AssemblyFileVersion("1.0.2.0")] [assembly: Guid("81FD8C9E-23D9-4CE3-95F7-21B735444371")] [assembly: NeutralResourcesLanguage("en-US")] diff --git a/TConvert/Properties/Resources.Designer.cs b/TConvert/Properties/Resources.Designer.cs index 368ce0b..6801747 100644 --- a/TConvert/Properties/Resources.Designer.cs +++ b/TConvert/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace TConvert.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -230,6 +230,16 @@ internal static System.Drawing.Bitmap Logo112 { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Premultiply { + get { + object obj = ResourceManager.GetObject("Premultiply", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/TConvert/Properties/Resources.resx b/TConvert/Properties/Resources.resx index 1de2603..79267d2 100644 --- a/TConvert/Properties/Resources.resx +++ b/TConvert/Properties/Resources.resx @@ -184,4 +184,7 @@ ..\Resources\Icons\Sound.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Icons\Premultiply.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/TConvert/Properties/Settings.Designer.cs b/TConvert/Properties/Settings.Designer.cs index c56c4ee..ebfca4e 100644 --- a/TConvert/Properties/Settings.Designer.cs +++ b/TConvert/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace TConvert.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -358,5 +358,17 @@ public bool ExtractAllowFonts { this["ExtractAllowFonts"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool PremultiplyAlpha { + get { + return ((bool)(this["PremultiplyAlpha"])); + } + set { + this["PremultiplyAlpha"] = value; + } + } } } diff --git a/TConvert/Properties/Settings.settings b/TConvert/Properties/Settings.settings index 5468d82..55b22c0 100644 --- a/TConvert/Properties/Settings.settings +++ b/TConvert/Properties/Settings.settings @@ -86,5 +86,8 @@ True + + True + \ No newline at end of file diff --git a/TConvert/Resources/Icons/Premultiply.png b/TConvert/Resources/Icons/Premultiply.png new file mode 100644 index 0000000..2ba0a06 Binary files /dev/null and b/TConvert/Resources/Icons/Premultiply.png differ diff --git a/TConvert/TConvert.csproj b/TConvert/TConvert.csproj index 117d5e0..5ac65ad 100644 --- a/TConvert/TConvert.csproj +++ b/TConvert/TConvert.csproj @@ -222,6 +222,9 @@ + + +