Skip to content

Commit 4afb6ea

Browse files
committed
Merge commit 'f3c83971935a89c552b251c0b10cbdc09c3a9640'
2 parents 6c68f1c + f3c8397 commit 4afb6ea

139 files changed

Lines changed: 9296 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="SkiaSharp" Version="3.119.0" />
12+
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />
13+
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.7" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\..\..\..\God\wmf\src\library\Library.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KawkaywecaljalKayjaybelfuber", "KawkaywecaljalKayjaybelfuber.csproj", "{077C992E-BB49-4CF7-A772-E8A8E0022CA5}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "..\..\..\..\..\God\wmf\src\library\Library.csproj", "{BDFFC887-321B-430B-CB61-60CD3E2894F6}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|x64.ActiveCfg = Debug|Any CPU
23+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|x64.Build.0 = Debug|Any CPU
24+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|x86.ActiveCfg = Debug|Any CPU
25+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Debug|x86.Build.0 = Debug|Any CPU
26+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|x64.ActiveCfg = Release|Any CPU
29+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|x64.Build.0 = Release|Any CPU
30+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|x86.ActiveCfg = Release|Any CPU
31+
{077C992E-BB49-4CF7-A772-E8A8E0022CA5}.Release|x86.Build.0 = Release|Any CPU
32+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|x64.ActiveCfg = Debug|Any CPU
35+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|x64.Build.0 = Debug|Any CPU
36+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|x86.ActiveCfg = Debug|Any CPU
37+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Debug|x86.Build.0 = Debug|Any CPU
38+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|x64.ActiveCfg = Release|Any CPU
41+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|x64.Build.0 = Release|Any CPU
42+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|x86.ActiveCfg = Release|Any CPU
43+
{BDFFC887-321B-430B-CB61-60CD3E2894F6}.Release|x86.Build.0 = Release|Any CPU
44+
EndGlobalSection
45+
GlobalSection(SolutionProperties) = preSolution
46+
HideSolutionNode = FALSE
47+
EndGlobalSection
48+
EndGlobal

Workbench/Wmf/KawkaywecaljalKayjaybelfuber/Program.cs

Lines changed: 318 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5D20AA90-6969-D8BD-9DCD-8634F4692FDA}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "samples\sample\Sample.csproj", "{82A7729F-37E7-459A-880D-B369D002D159}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wieslawsoltes-wmf", "wieslawsoltes-wmf", "{D144BB0A-C7AF-AD14-AAB6-277D09411108}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "src\wieslawsoltes-wmf\src\library\Library.csproj", "{37C31B24-6793-4298-B68F-7A9E94932DD9}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaWmfRenderer", "src\SkiaWmfRenderer\SkiaWmfRenderer.csproj", "{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}"
17+
EndProject
18+
Global
19+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
20+
Debug|Any CPU = Debug|Any CPU
21+
Debug|x64 = Debug|x64
22+
Debug|x86 = Debug|x86
23+
Release|Any CPU = Release|Any CPU
24+
Release|x64 = Release|x64
25+
Release|x86 = Release|x86
26+
EndGlobalSection
27+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
28+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|x64.ActiveCfg = Debug|Any CPU
31+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|x64.Build.0 = Debug|Any CPU
32+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|x86.ActiveCfg = Debug|Any CPU
33+
{82A7729F-37E7-459A-880D-B369D002D159}.Debug|x86.Build.0 = Debug|Any CPU
34+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|Any CPU.Build.0 = Release|Any CPU
36+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|x64.ActiveCfg = Release|Any CPU
37+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|x64.Build.0 = Release|Any CPU
38+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|x86.ActiveCfg = Release|Any CPU
39+
{82A7729F-37E7-459A-880D-B369D002D159}.Release|x86.Build.0 = Release|Any CPU
40+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|x64.ActiveCfg = Debug|Any CPU
43+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|x64.Build.0 = Debug|Any CPU
44+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|x86.ActiveCfg = Debug|Any CPU
45+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Debug|x86.Build.0 = Debug|Any CPU
46+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|Any CPU.Build.0 = Release|Any CPU
48+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|x64.ActiveCfg = Release|Any CPU
49+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|x64.Build.0 = Release|Any CPU
50+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|x86.ActiveCfg = Release|Any CPU
51+
{37C31B24-6793-4298-B68F-7A9E94932DD9}.Release|x86.Build.0 = Release|Any CPU
52+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
54+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|x64.ActiveCfg = Debug|Any CPU
55+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|x64.Build.0 = Debug|Any CPU
56+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|x86.ActiveCfg = Debug|Any CPU
57+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Debug|x86.Build.0 = Debug|Any CPU
58+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|Any CPU.Build.0 = Release|Any CPU
60+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|x64.ActiveCfg = Release|Any CPU
61+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|x64.Build.0 = Release|Any CPU
62+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|x86.ActiveCfg = Release|Any CPU
63+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC}.Release|x86.Build.0 = Release|Any CPU
64+
EndGlobalSection
65+
GlobalSection(SolutionProperties) = preSolution
66+
HideSolutionNode = FALSE
67+
EndGlobalSection
68+
GlobalSection(NestedProjects) = preSolution
69+
{82A7729F-37E7-459A-880D-B369D002D159} = {5D20AA90-6969-D8BD-9DCD-8634F4692FDA}
70+
{D144BB0A-C7AF-AD14-AAB6-277D09411108} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
71+
{37C31B24-6793-4298-B68F-7A9E94932DD9} = {D144BB0A-C7AF-AD14-AAB6-277D09411108}
72+
{34500DA8-76D4-4CE5-ADA3-9482FECF7DEC} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
73+
EndGlobalSection
74+
GlobalSection(ExtensibilityGlobals) = postSolution
75+
SolutionGuid = {CC7896A5-C341-469C-8996-F6E2BA9724FE}
76+
EndGlobalSection
77+
EndGlobal
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// See https://aka.ms/new-console-template for more information
2+
3+
using DocSharp.Markdown;
4+
5+
using Markdig;
6+
7+
using Oxage.Wmf;
8+
using Oxage.Wmf.Records;
9+
10+
using SkiaSharp;
11+
12+
using SkiaWmfRenderer;
13+
14+
using System.Diagnostics;
15+
using System.Drawing;
16+
using System.Drawing.Imaging;
17+
using System.Text;
18+
using DocSharp;
19+
using Markdig.Extensions.Figures;
20+
using Markdig.Syntax;
21+
22+
var markdownText = new StringBuilder();
23+
var outputFolder = Path.Join(AppContext.BaseDirectory, $"Output_{Path.GetRandomFileName()}");
24+
Directory.CreateDirectory(outputFolder);
25+
26+
//var testFile = @"C:\lindexi\wmf公式\sample.wmf";
27+
//ConvertImageFile(testFile);
28+
29+
var folder = @"C:\lindexi\wmf公式\";
30+
31+
foreach (var file in Directory.EnumerateFiles(folder, "*.wmf"))
32+
{
33+
ConvertImageFile(file);
34+
}
35+
36+
var markdownFile = Path.Join(outputFolder, "README.md");
37+
var markdown = markdownText.ToString();
38+
File.WriteAllText(markdownFile, markdown);
39+
40+
var docxFile = Path.Join(outputFolder, "README.docx");
41+
var markdownConverter = new MarkdownConverter
42+
{
43+
ImagesBaseUri = outputFolder
44+
};
45+
46+
MarkdownSource markdownSource = MarkdownSource.FromMarkdownString(markdown);
47+
markdownConverter.ToDocx(markdownSource, docxFile);
48+
49+
Console.WriteLine("Hello, World!");
50+
51+
void ConvertImageFile(string file)
52+
{
53+
Console.WriteLine($"Start convert '{file}'");
54+
55+
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
56+
var gdiFileName = $"GDI_{fileNameWithoutExtension}.png";
57+
var gdiFile = Path.Join(outputFolder, gdiFileName);
58+
59+
if (OperatingSystem.IsWindowsVersionAtLeast(6, 1))
60+
{
61+
var image = Image.FromFile(file);
62+
image.Save(gdiFile, ImageFormat.Png);
63+
}
64+
65+
var wmfFileName = $"WMF_{fileNameWithoutExtension}.png";
66+
var testOutputFile = Path.Join(outputFolder, wmfFileName);
67+
var stopwatch = Stopwatch.StartNew();
68+
69+
var success = SkiaWmfRenderHelper.TryConvertToPng(new FileInfo(file), new FileInfo(testOutputFile));
70+
stopwatch.Stop();
71+
72+
Console.WriteLine($"SkiaWmfRenderHelper.TryConvertToPng success={success}");
73+
74+
markdownText.AppendLine
75+
(
76+
$$"""
77+
## {{fileNameWithoutExtension}}
78+
79+
**GDI:**
80+
81+
![](./{{gdiFileName}}){width=250 height=120}
82+
83+
**WMF:**
84+
85+
"""
86+
);
87+
88+
if (success)
89+
{
90+
markdownText.AppendLine($"![](./{wmfFileName})"+ "{width=250 height=120}");
91+
}
92+
else
93+
{
94+
markdownText.AppendLine("Rendering failed.");
95+
}
96+
97+
markdownText.AppendLine();
98+
markdownText.AppendLine($"Rendering time: {stopwatch.ElapsedMilliseconds} ms");
99+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<PublishAot>true</PublishAot>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\..\src\SkiaWmfRenderer\SkiaWmfRenderer.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="SkiaSharp" Version="3.119.0" />
17+
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />
18+
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.7" />
19+
<PackageReference Include="DocSharp.Markdown" Version="0.8.5" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Oxage.Wmf;
2+
3+
using SkiaSharp;
4+
5+
using System.Text;
6+
using Oxage.Wmf.Primitive;
7+
8+
namespace SkiaWmfRenderer.Rendering;
9+
10+
static class Converters
11+
{
12+
public static Encoding CharacterSetToEncoding(this CharacterSet characterSet)
13+
{
14+
var codePageId = characterSet switch
15+
{
16+
CharacterSet.ANSI_CHARSET
17+
// DEFAULT_CHARSET: Specifies a character set based on the current system locale; for example, when the system locale is United States English, the default character set is ANSI_CHARSET.
18+
or CharacterSet.DEFAULT_CHARSET => 1252,
19+
CharacterSet.OEM_CHARSET => 437,
20+
CharacterSet.SHIFTJIS_CHARSET => 932,
21+
CharacterSet.HANGUL_CHARSET => 949,
22+
CharacterSet.JOHAB_CHARSET => 1361,
23+
CharacterSet.GB2312_CHARSET => 936,
24+
CharacterSet.CHINESEBIG5_CHARSET => 950,
25+
CharacterSet.HEBREW_CHARSET => 1255,
26+
CharacterSet.ARABIC_CHARSET => 1256,
27+
CharacterSet.GREEK_CHARSET => 1253,
28+
CharacterSet.TURKISH_CHARSET => 1254,
29+
CharacterSet.BALTIC_CHARSET => 1257,
30+
CharacterSet.EASTEUROPE_CHARSET => 1250,
31+
CharacterSet.RUSSIAN_CHARSET => 1251,
32+
CharacterSet.THAI_CHARSET => 874,
33+
CharacterSet.VIETNAMESE_CHARSET => 1258,
34+
CharacterSet.SYMBOL_CHARSET => 42, // Symbol font is not a code page, but 42 is often used for Symbol font
35+
_ => 1252,
36+
};
37+
38+
return Encoding.GetEncoding(codePageId);
39+
}
40+
41+
public static SKColor ToSKColor(this WmfColor color)
42+
{
43+
return new SKColor(color.R, color.G, color.B, color.A);
44+
}
45+
46+
public static SKPoint ToSKPoint(this WmfPoint point)
47+
{
48+
return new SKPoint(point.X, point.Y);
49+
}
50+
}

0 commit comments

Comments
 (0)