原創(chuàng)|使用教程|編輯:郝浩|2013-09-13 14:03:51.000|閱讀 1041 次
概述:ImageGear for .NET提供了目前最先進的用于創(chuàng)建、控制、更加安全、高質(zhì)量的成像應用程序。本文將講解如何使用ImageGear for .NET創(chuàng)建一個簡單的C# WPF應用程序,這個應用程序?qū)崿F(xiàn)加載、顯示、保存圖像的功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
在前面的《圖像處理控件ImageGear for .NET教程: C# WPF應用程序創(chuàng)建示例(1)》一文中已經(jīng)講解了如何在中對于C# WPF應用程序創(chuàng)建了項目,本文將繼續(xù)前文。
一、創(chuàng)建在窗體中的菜單
二、在窗體中添加ImageGear Page View控件
一、首先,添加必要的using語句
using System.IO; using System.Diagnostics; using ImageGear; using ImageGear.Core; using ImageGear.Windows.Forms; using ImageGear.Display; using ImageGear.Processing; using ImageGear.Formats;
二、添加下面的域到Form1:
// holds the image data private ImGearPage imGearPage = null; // controls how the page is displayed private ImGearPageDisplay imGearPageDisplay = null;
三、如果你使用的是運行時授權(quán),調(diào)用InitializeComponent之前,添加授權(quán)初始化代碼到Form1構(gòu)造函數(shù)(Form1())。如果你使用的是評估或開發(fā)(工具包)授權(quán)的話,就不需要。
//***The SetSolutionName, SetSolutionKey and possibly the SetOEMLicenseKey //methods must be called to distribute the runtime.*** //ImGearLicense.SetSolutionName("YourSolutionName"); //ImGearLicense.SetSolutionKey(12345, 12345, 12345, 12345); //Manually Reported Runtime licenses also require the following method //call to SetOEMLicenseKey. //ImGearLicense.SetOEMLicenseKey("2.0.AStringForOEMLicensing...");
四、在之前代碼的下面,添加下面的調(diào)用來初始化引用的格式。
// Support for common formats:
五、現(xiàn)在在導入頁面菜單控制器中添加下面的代碼:
private void loadPageToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = ImGearFileFormats.GetSavingFilter(ImGearSavingFormats.UNKNOWN); if (DialogResult.OK == openFileDialog1.ShowDialog()) { using (FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { try { // Load the image into the page imGearPage = ImGearFileFormats.LoadPage(stream, 0); } catch (ImGearException ex) { Debug.WriteLine(ex.Message); } } if (null != imGearPage && null != imGearPage.DIB && !imGearPage.DIB.IsEmpty()) { // create a new page display imGearPageDisplay = new ImGearPageDisplay(imGearPage); // associate the page display with the page view imGearPageView1.Display = imGearPageDisplay; // cause the page view to repaint imGearPageView1.Invalidate(); } } }
開發(fā)應用程序的其他步驟敬請期待下文。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件