Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
1. test preprocessor of net version
1. build nuget
  • Loading branch information
oven425 committed Sep 28, 2021
1 parent 8343508 commit 1c8b10f
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 78 deletions.
Binary file added 40429294503_2b2a198be1_o.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions QSoft.Apng.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>QSoft.Apng</id>
<version>1.0.0.0</version>
<title>Apng.NET</title>
<authors>BEN_HSU</authors>
<owners>BEN_HSU</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>40429294503_2b2a198be1_o.jpg</icon>
<projectUrl>https://github.com/oven425/QSoft.APNG</projectUrl>
<description>Parse apng and build animation for WPF</description>
<copyright>Copyright © Ben Hsu 2021</copyright>
<repository type="git" url="https://github.com/oven425/QSoft.APNG" />
</metadata>
<files>
<file src="QSoft.Apng\bin\Release\lib\" target="lib" />
<file src="40429294503_2b2a198be1_o.jpg" target="40429294503_2b2a198be1_o.jpg"/>
</files>
</package>
4 changes: 0 additions & 4 deletions QSoft.Apng/Apng.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 0 additions & 4 deletions QSoft.Apng/BinaryReader_Litten.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
16 changes: 16 additions & 0 deletions QSoft.Apng/DefineNET.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.8' ">NET48</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.7.2' ">NET472</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.6.2' ">NET462</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.6.1' ">NET461</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.6' ">NET46</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5.2' ">NET452</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5.1' ">NET451</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5' ">NET45</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.0' ">NET4</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v3.5' ">NET35</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v3.0' ">NET30</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v2.0' ">NET20</DefineConstants>
</PropertyGroup>
</Project>
22 changes: 17 additions & 5 deletions QSoft.Apng/PNGDefine.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QSoft.Apng
{
Expand Down Expand Up @@ -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<RGB> RGBs { set; get; } = new List<RGB>();
}

public class tRNS:Chunk
Expand Down
3 changes: 1 addition & 2 deletions QSoft.Apng/PNG_Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QSoft.Apng
{
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions QSoft.Apng/PNG_Writer.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
25 changes: 23 additions & 2 deletions QSoft.Apng/QSoft.Apng.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QSoft.Apng</RootNamespace>
<AssemblyName>QSoft.Apng</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;NET461</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>default</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
Expand All @@ -52,4 +57,20 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>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</PostBuildEvent>
</PropertyGroup>
<!-- <Import Project="DefineNET.prop" /> -->
</Project>
6 changes: 3 additions & 3 deletions WPF_APNG/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
</configuration>
8 changes: 5 additions & 3 deletions WPF_APNG/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Loaded="Window_Loaded"
Title="MainWindow" Height="450" Width="800">

<Grid>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
Expand All @@ -24,6 +24,8 @@
</ComboBox.ItemTemplate>
</ComboBox>
<local:ApngImage Source="elephant.png"/>
</Grid>

</Grid>-->

<Image x:Name="image_png" Stretch="None">
</Image>
</Window>
15 changes: 10 additions & 5 deletions WPF_APNG/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -129,7 +134,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
//storyboard.Freeze();
//storyboard.Begin();





Expand Down
52 changes: 22 additions & 30 deletions WPF_APNG/Properties/Resources.Designer.cs

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

30 changes: 13 additions & 17 deletions WPF_APNG/Properties/Settings.Designer.cs

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

1 change: 1 addition & 0 deletions WPF_APNG/WPF_APNG.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
1 change: 1 addition & 0 deletions build nuget.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nuget pack QSoft.Apng.nuspec

0 comments on commit 1c8b10f

Please sign in to comment.