|
12 | 12 | using System.Drawing.Imaging; |
13 | 13 | using System.Text; |
14 | 14 |
|
15 | | -var file = @"C:\lindexi\wmf公式\image17.wmf"; |
| 15 | +var folder = @"C:\lindexi\wmf公式\"; |
| 16 | +var outputFolder = Path.Join(AppContext.BaseDirectory, $"Output_{Path.GetRandomFileName()}"); |
| 17 | +Directory.CreateDirectory(outputFolder); |
16 | 18 |
|
17 | | -SkiaWmfRenderHelper.TryConvertToPng(new FileInfo(file), new FileInfo("foo.png")); |
| 19 | +var markdownText = new StringBuilder(); |
| 20 | + |
| 21 | +foreach (var file in Directory.EnumerateFiles(folder, "*.wmf")) |
| 22 | +{ |
| 23 | + var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file); |
| 24 | + var gdiFileName = $"GDI_{fileNameWithoutExtension}.png"; |
| 25 | + var gdiFile = Path.Join(outputFolder, gdiFileName); |
| 26 | + |
| 27 | + var image = Image.FromFile(file); |
| 28 | + image.Save(gdiFile, ImageFormat.Png); |
| 29 | + |
| 30 | + var wmfFileName = $"WMF_{fileNameWithoutExtension}.png"; |
| 31 | + var testOutputFile = Path.Join(outputFolder, wmfFileName); |
| 32 | + var success = SkiaWmfRenderHelper.TryConvertToPng(new FileInfo(file), new FileInfo(testOutputFile)); |
| 33 | + |
| 34 | + markdownText.AppendLine |
| 35 | + ( |
| 36 | + $""" |
| 37 | + ## {fileNameWithoutExtension} |
| 38 | + |
| 39 | + **GDI:** |
| 40 | + |
| 41 | +  |
| 42 | + |
| 43 | + **WMF:** |
| 44 | + |
| 45 | + """ |
| 46 | + ); |
| 47 | + |
| 48 | + if(success) |
| 49 | + { |
| 50 | + markdownText.AppendLine($""); |
| 51 | + } |
| 52 | + else |
| 53 | + { |
| 54 | + markdownText.AppendLine("Rendering failed."); |
| 55 | + } |
| 56 | + |
| 57 | + markdownText.AppendLine(""); |
| 58 | +} |
| 59 | + |
| 60 | +var markdownFile = Path.Join(outputFolder, "README.md"); |
| 61 | +File.WriteAllText(markdownFile, markdownText.ToString()); |
18 | 62 |
|
19 | 63 | Console.WriteLine("Hello, World!"); |
0 commit comments