原創|使用教程|編輯:郝浩|2013-09-13 14:03:51.000|閱讀 1041 次
概述:ImageGear for .NET提供了目前最先進的用于創建、控制、更加安全、高質量的成像應用程序。本文將講解如何使用ImageGear for .NET創建一個簡單的C# WPF應用程序,這個應用程序將會實現加載、顯示、保存圖像的功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
在前面的《圖像處理控件ImageGear for .NET教程: C# WPF應用程序創建示例(1)》一文中已經講解了如何在中對于C# WPF應用程序創建了項目,本文將繼續前文。
一、創建在窗體中的菜單
二、在窗體中添加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;
三、如果你使用的是運行時授權,調用InitializeComponent之前,添加授權初始化代碼到Form1構造函數(Form1())。如果你使用的是評估或開發(工具包)授權的話,就不需要。
//***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...");
四、在之前代碼的下面,添加下面的調用來初始化引用的格式。
// Support for common formats:
五、現在在導入頁面菜單控制器中添加下面的代碼:
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(); } } }
開發應用程序的其他步驟敬請期待下文。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件