diff --git a/40429294503_2b2a198be1_o.jpg b/40429294503_2b2a198be1_o.jpg new file mode 100644 index 0000000..921fa6a Binary files /dev/null and b/40429294503_2b2a198be1_o.jpg differ diff --git a/QSoft.Apng.nuspec b/QSoft.Apng.nuspec new file mode 100644 index 0000000..7aded9b --- /dev/null +++ b/QSoft.Apng.nuspec @@ -0,0 +1,22 @@ + + + + QSoft.Apng + 1.0.0.0 + Apng.NET + BEN_HSU + BEN_HSU + false + MIT + https://licenses.nuget.org/MIT + 40429294503_2b2a198be1_o.jpg + https://github.com/oven425/QSoft.APNG + Parse apng and build animation for WPF + Copyright © Ben Hsu 2021 + + + + + + + \ No newline at end of file diff --git a/QSoft.Apng/Apng.cs b/QSoft.Apng/Apng.cs index 85b2895..a6c8ed3 100644 --- a/QSoft.Apng/Apng.cs +++ b/QSoft.Apng/Apng.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; diff --git a/QSoft.Apng/BinaryReader_Litten.cs b/QSoft.Apng/BinaryReader_Litten.cs index 6fbcce7..7d9c581 100644 --- a/QSoft.Apng/BinaryReader_Litten.cs +++ b/QSoft.Apng/BinaryReader_Litten.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace QSoft.Apng { diff --git a/QSoft.Apng/DefineNET.prop b/QSoft.Apng/DefineNET.prop new file mode 100644 index 0000000..aed6d04 --- /dev/null +++ b/QSoft.Apng/DefineNET.prop @@ -0,0 +1,16 @@ + + + NET48 + NET472 + NET462 + NET461 + NET46 + NET452 + NET451 + NET45 + NET4 + NET35 + NET30 + NET20 + + \ No newline at end of file diff --git a/QSoft.Apng/PNGDefine.cs b/QSoft.Apng/PNGDefine.cs index a7e45d5..78edb32 100644 --- a/QSoft.Apng/PNGDefine.cs +++ b/QSoft.Apng/PNGDefine.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace QSoft.Apng { @@ -107,9 +104,24 @@ public class PLTE : Chunk public PLTE() { this.ChunkType = ChunkTypes.pLTE; - + + } + + +//#if NET472 || NET461 + +// //public List<(byte R, byte G, byte B)> RGBs { set; get; } = new List<(byte R, byte G, byte B)>(); +//#else +// string ss = Environment.GetEnvironmentVariable("TEMP"); +//#endif + + public class RGB + { + public byte R { set; get; } + public byte G { set; get; } + public byte B { set; get; } } - public List<(byte R, byte G, byte B)> RGBs { set; get; } = new List<(byte R, byte G, byte B)>(); + public List RGBs { set; get; } = new List(); } public class tRNS:Chunk diff --git a/QSoft.Apng/PNG_Reader.cs b/QSoft.Apng/PNG_Reader.cs index ffbb670..97ed09a 100644 --- a/QSoft.Apng/PNG_Reader.cs +++ b/QSoft.Apng/PNG_Reader.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace QSoft.Apng { @@ -219,7 +218,7 @@ public Png_Reader Open(Stream stream) { byte[] rgb_buf = br.ReadBytes(3); - plte.RGBs.Add((rgb_buf[0], rgb_buf[1], rgb_buf[2])); + plte.RGBs.Add(new PLTE.RGB() { R = rgb_buf[0], G = rgb_buf[1], B = rgb_buf[2] }); } plte.CRC = br.ReadBytes(4); diff --git a/QSoft.Apng/PNG_Writer.cs b/QSoft.Apng/PNG_Writer.cs index f20303b..fdd2cc3 100644 --- a/QSoft.Apng/PNG_Writer.cs +++ b/QSoft.Apng/PNG_Writer.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace QSoft.Apng { diff --git a/QSoft.Apng/QSoft.Apng.csproj b/QSoft.Apng/QSoft.Apng.csproj index 1a1ba7d..5efd062 100644 --- a/QSoft.Apng/QSoft.Apng.csproj +++ b/QSoft.Apng/QSoft.Apng.csproj @@ -9,18 +9,22 @@ Properties QSoft.Apng QSoft.Apng - v4.7.2 + v3.5 512 true + + true full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;NET461 prompt 4 + false + default pdbonly @@ -29,6 +33,7 @@ TRACE prompt 4 + false @@ -52,4 +57,20 @@ + + setlocal ENABLEDELAYEDEXPANSION +set word=net +set dot= +set netfolder=$(TargetFrameworkVersion) +echo %25netfolder%25 +set netfolder=%25netfolder:v=!word!%25 +set netfolder=%25netfolder:.=!dot!%25 +echo %25netfolder%25 + +echo $(TargetFrameworkVersion) +echo $(TargetPath) +mkdir $(TargetDir)\lib\%25netfolder%25 +xcopy $(TargetPath) $(TargetDir)\lib\%25netfolder%25 /Y + + \ No newline at end of file diff --git a/WPF_APNG/App.config b/WPF_APNG/App.config index 56efbc7..ecdcf8a 100644 --- a/WPF_APNG/App.config +++ b/WPF_APNG/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/WPF_APNG/MainWindow.xaml b/WPF_APNG/MainWindow.xaml index 841379c..1c36b2b 100644 --- a/WPF_APNG/MainWindow.xaml +++ b/WPF_APNG/MainWindow.xaml @@ -9,7 +9,7 @@ Loaded="Window_Loaded" Title="MainWindow" Height="450" Width="800"> - + + + + diff --git a/WPF_APNG/MainWindow.xaml.cs b/WPF_APNG/MainWindow.xaml.cs index d0446a9..76f5df1 100644 --- a/WPF_APNG/MainWindow.xaml.cs +++ b/WPF_APNG/MainWindow.xaml.cs @@ -58,10 +58,15 @@ private void Window_Loaded(object sender, RoutedEventArgs e) var file = File.OpenRead("../../testapng/SDve91m.png"); //var file = File.OpenRead("../../testapng/pyani.png"); Png_Reader pngr = new Png_Reader(); - pngr.Open(file).ToWPF(this.image_png).Begin(); - //this.m_Apng = pngr.Open(file).SpltAPng(); + //pngr.Open(file).ToWPF(this.image_png).Begin(); + var pngs = pngr.Open(file).SpltAPng(); + for(int i=0; i< pngs.Count; i++) + { + File.WriteAllBytes($"{i}.png", pngs.ElementAt(i).Value.ToArray()); + } + file.Close(); + file.Dispose(); - //var storyboard = new Storyboard(); //var keyFrames = new ObjectAnimationUsingKeyFrames(); //Storyboard.SetTarget(keyFrames, this.image_png); @@ -76,7 +81,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) // var drawingVisual = new DrawingVisual(); // using (DrawingContext dc = drawingVisual.RenderOpen()) // { - + // BitmapImage img = new BitmapImage(); // img.BeginInit(); // img.StreamSource = this.m_Apng.ElementAt(i).Value; @@ -129,7 +134,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) //storyboard.Freeze(); //storyboard.Begin(); - + diff --git a/WPF_APNG/Properties/Resources.Designer.cs b/WPF_APNG/Properties/Resources.Designer.cs index a958f3d..8f1191b 100644 --- a/WPF_APNG/Properties/Resources.Designer.cs +++ b/WPF_APNG/Properties/Resources.Designer.cs @@ -3,67 +3,59 @@ // 這段程式碼是由工具產生的。 // 執行階段版本:4.0.30319.42000 // -// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 -// 程式碼,則會遺失變更。 +// 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, +// 變更將會遺失。 // //------------------------------------------------------------------------------ -namespace WPF_APNG.Properties -{ - - +namespace WPF_APNG.Properties { + using System; + + /// - /// 用於查詢當地語系化字串等的強類型資源類別 + /// 用於查詢當地語系化字串等的強類型資源類別。 /// // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder - // 類別透過 ResGen 或 Visual Studio 這類工具產生。 + // 類別透過 ResGen 或 Visual Studio 這類工具。 // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen // (利用 /str 選項),或重建您的 VS 專案。 - [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 - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPF_APNG.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 /// 使用這個強類型資源類別的資源查閱。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/WPF_APNG/Properties/Settings.Designer.cs b/WPF_APNG/Properties/Settings.Designer.cs index d44854c..b1a916f 100644 --- a/WPF_APNG/Properties/Settings.Designer.cs +++ b/WPF_APNG/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 這段程式碼是由工具產生的。 +// 執行階段版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, +// 變更將會遺失。 // //------------------------------------------------------------------------------ -namespace WPF_APNG.Properties -{ - - +namespace WPF_APNG.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/WPF_APNG/WPF_APNG.csproj b/WPF_APNG/WPF_APNG.csproj index 80e61d8..91bd491 100644 --- a/WPF_APNG/WPF_APNG.csproj +++ b/WPF_APNG/WPF_APNG.csproj @@ -14,6 +14,7 @@ 4 true true + AnyCPU diff --git a/build nuget.bat b/build nuget.bat new file mode 100644 index 0000000..aa14ceb --- /dev/null +++ b/build nuget.bat @@ -0,0 +1 @@ +nuget pack QSoft.Apng.nuspec \ No newline at end of file