WPF導(dǎo)出圖片具體方式介紹
作者:佚名
對(duì)于初學(xué)者來(lái)說(shuō),掌握一些WPF的基礎(chǔ)技術(shù)運(yùn)用是非常有必要的。那么,對(duì)于WPF導(dǎo)出圖片這一基礎(chǔ)技能的掌握需要我們?cè)趯?shí)踐中去不斷的鞏固。
當(dāng)我們?cè)谑褂?a >WPF的時(shí)候,如何正確的進(jìn)行圖片的導(dǎo)出是一個(gè)比較重要的基本技術(shù)。在這里我們將會(huì)學(xué)到WPF導(dǎo)出圖片的相關(guān)代碼編寫(xiě)方式。#t#
WPF導(dǎo)出圖片代碼示例:
- private void SaveToImage
(FrameworkElement p_Framework
Element,string p_FileName) - {
- System.IO.FileStream fs = new
System.IO.FileStream(p_FileName,
System.IO.FileMode.Create); - RenderTargetBitmap bmp = new
RenderTargetBitmap((int)p_
FrameworkElement.ActualWidth,
(int)p_FrameworkElement.ActualHeight,
1 / 96, 1 / 96, PixelFormats.Default); - bmp.Render(p_FrameworkElement);
- BitmapEncoder encoder =
new TiffBitmapEncoder(); - encoder.Frames.Add
(BitmapFrame.Create(bmp)); - encoder.Save(fs);
- fs.Close();
- }
希望大家通過(guò)上面這段WPF導(dǎo)出圖片的方式能夠充分掌握這一技術(shù)要點(diǎn)。
責(zé)任編輯:曹凱
來(lái)源:
博客園