2014-02-05 32 views
2

我隨着Windows Phone 8的工作/ C#Silverlight和使用類似的代碼來渲染文本:的TextBlock呈現在WriteableBitmap的Windows Phone上是不是清脆

TextBlock drawStringInstance = new TextBlock(); 
drawStringInstance.Text = str; 
drawStringInstance.Opacity = 1; 

drawStringInstance.Measure(new Size(1000000, 1000000)); 
WriteableBitmap wb = new WriteableBitmap((int)drawStringInstance.ActualWidth, height);       
wb.Render(drawStringInstance, null); 
wb.Invalidate(); 

請注意,我不救圖像並直接繪製,所以不應該有任何保存文物。如果我只是把文本塊我得到很多更清晰的文本用更少的失真本身(左邊是「好」的渲染):

enter image description here

有什麼我可以做些什麼來改善這個或者這是一個固有的問題與WriteableBitmap.Render()的方法?

+1

我不知道有一種方法可以解決這個問題,因爲清晰的消除鋸齒文字渲染是顯示的僞影,並且在渲染到位圖時效果不佳。您可以嘗試設置「TextHintingMode」(http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/system.windows.media.textoptions.texthintingmode(v=vs.105).aspx ) – WiredPrairie

+0

謝謝,我會嘗試,儘管它看起來已經是可讀性的默認值。 –

+0

也許問題是'drawStringInstance.Measure(new Size(1000000,1000000));' – Alberto

回答

1

我認爲你不應該渲染不在視覺樹中的元素。事實上,你的代碼不會在我的模擬器上渲染任何東西。

只需在頁面上的某處添加文本塊(也許將邊距設置爲-1000以使其不顯示),然後進行渲染。

+0

謝謝。這對我有效,但我認爲這個問題與我在這裏所做的修復有關:http://stackoverflow.com/questions/21582742/how-to-work-with-pixels-in-windows-phone-c –

相關問題