C# 使用C将XPS图示符渲染为位图#
我想从C# 使用C将XPS图示符渲染为位图#,c#,wpf,xps,C#,Wpf,Xps,我想从XPS文档中提取Glyphs,并在其位置渲染它们,并将其格式化为位图。因此,我可以加载XPS文档并迭代其页面,然后迭代所有元素,现在我可以获取Glyphs元素并读取它们的属性。 我不熟悉WPF,但我了解到我可以使用Glyphs、GlyphsRun和GlyphsRunDrawing来绘制Glyphs,我对Glyphs和GlyphsRun类的属性相似感到困惑,另外,我对索引感到困惑,我不知道如何将from属性加载到一个整数列表属性 <Glyphs FontUri="../Resource
XPS
文档中提取Glyphs
,并在其位置渲染它们,并将其格式化为位图。因此,我可以加载XPS
文档并迭代其页面,然后迭代所有元素,现在我可以获取Glyphs
元素并读取它们的属性。
我不熟悉WPF,但我了解到我可以使用Glyphs
、GlyphsRun
和GlyphsRunDrawing
来绘制Glyphs,我对Glyphs和GlyphsRun类的属性相似感到困惑,另外,我对索引感到困惑,我不知道如何将from属性加载到一个整数列表属性
<Glyphs
FontUri="../Resources/Fonts/latha.ttf"
UnicodeString="போது"
Indices="(2:3)94;76;88;(2:1)162"
OriginX="10" OriginY="120"
FontRenderingEmSize="40"
Fill="#000000"/>
阅读了吗?创建GlyphRun后,您可以将其绘制到DrawingVisual by中,然后将DrawingVisual渲染到RenderTargetBitmap中。@Clemens是的,我正在处理windows窗体并加载XPSdocument@MohamedMoussa:嗨,你知道这件事吗?我还需要glyph位置。您阅读了吗?创建GlyphRun后,您可以将其绘制到DrawingVisual by中,然后将DrawingVisual渲染到RenderTargetBitmap中。@Clemens是的,我正在处理windows窗体并加载XPSdocument@MohamedMoussa:嗨,你知道这件事吗?我也需要字形的位置
Glyphs glyphs = new Glyphs();
GlyphRun glyphRun = new GlyphRun();
glyphs.UnicodeString = pageContentReader.GetAttribute("UnicodeString");
glyphs.BidiLevel= Int32.Parse(pageContentReader.GetAttribute("BidiLevel"));
glyphRun.Characters = pageContentReader.GetAttribute("UnicodeString").ToList();
glyphRun.AdvanceWidths = pageContentReader.GetAttribute("AdvanceWidth").Split(';').Select(o => Double.Parse(o)).ToList();
glyphRun.BaselineOrigin = new System.Windows.Point(Int32.Parse(pageContentReader.GetAttribute("OriginX"))
, Int32.Parse(pageContentReader.GetAttribute("OriginY")));
glyphRun.FontRenderingEmSize = Double.Parse(pageContentReader.GetAttribute("FontRenderingEmSize"));
glyphRun.BidiLevel = Int32.Parse(pageContentReader.GetAttribute("BidiLevel"));