ex_image_histogram_plots

所属分类:C#编程
开发工具:C#
文件大小:99KB
下载次数:31
上传日期:2008-06-03 17:08:56
上 传 者dzm_ddb
说明:  使用IDL的强大功能进行图像处理,使用IDL的BRIDGES在C#和IDL之间进行数据交换。
(The use of IDL)

文件列表:
ex_image_histogram_plots\ex_image_histogram_plots.ocx (225280, 2006-11-06)
ex_image_histogram_plots\ex_image_histogram_plots.tlb (9240, 2006-11-06)
ex_image_histogram_plots\ex_image_histogram_plots_com_wrapdef.sav (103424, 2006-11-06)
ex_image_histogram_plots\ex_image_histogram_plots__define.pro (14330, 2006-11-06)

Unzip the attached files into a parent directory that is in the IDL search path. It will unzip all files into a subdirectory named 'ex_image_histogram_plots'. Your goal should be to replace the attached '.sav', '.ocx' and '.tlb' files with your own compilations. They are included here just in case the reader does not currently have the 'idl_assistant' license feature needed to generate these three files. Below are the steps for learning how to interface an IDL Export Com object library/control with a Visual C# program. The steps are probably very similar for accomplishing the interface to Visual Basic and Visual C++. (The 'IDL Connectivity Bridges' manual actually provides many examples specific to Visual Basic.) STEP 1: Create an IDL Object-syntax program with at least an 'Init' constructor method. For this example, we demonstrate with the attached 'ex_image_histogram_plots__define.pro' IDL class definition. A few points about this example procedure: - It calculates histograms for each channel of any JPEG, PNG, TIFF or DICOM image and displays a distinct plot line for each histogram. It has a simple method for changing the linestyle of the plot lines on display. - Comments in the file explains its details. - Its function is identical to the 'export_grwindow_doc__define.pro'. I use a distinct '.pro' because I wanted to comment the original example more thoroughly and remove unused and redundant code lines in the original example. Because the function is identical, you could follow the remaining steps in this procedure using 'export_grwindow_doc__define.pro' instead of 'ex_image_histogram_plots__define.pro. STEP2: Use the IDL Export Bridge Assistant to create the three critical COM interface files, 'ex_image_histogram_plots.sav', 'ex_image_histogram_plots.ocx' and 'ex_image_histogram_plots.tlb'.I repeat here just the same steps shown in 'IDL Connectivity Bridges -> Part II: Exporting from IDL -> Creating Custom COM Export Objects -> Drawable COM Export Examples -> COM IDLgrWindow Based Histogram Plot Generator' step 4. The steps are: 2a) IDL> IDLEXBR_ASSISTANT. (If you do not have the 'idl_assistant' add-on license, then this command will throw a licensing error. In this case use the '.sav', '.ocx', and '.tlb' from the downloaded '.zip' and proceed to STEP 3.) 2b) File -> New Project -> COM... 2c) Select the 'ex_image_histogram_plots__define.pro' file. The IDL Export Bridge Assistant file will populate with information it parses from this IDL object class definition procedure. 2d) Use the chart below to make your settings in the IDL Export Bridge Assistant dialog. Note that whenever multiple targets share the same property, you can CTRL-click to select the multiple targets for simulatneous property setting. Tree View Item Property Configuration -------------- ---------------------- - IDL Export Bridge Project Accept defaults. - export_grwindow_doc Default. Drawable object = True - Properties OMODEL, OVIEW, Type = IUnknown* OXAXIS, OXTEXT, OYAXIS, Array = False OYTEXT - Property OPLOTCOLL Type = IUnknown* Array = True - Property SFILE Type = BSTR Array = False - Methods CHANGELINE, Export = True CREATEPLOTS and OPEN - Parameters LINESTYLE, Mutability = In NROWS, NCOLS, ISRGB Type = short Array = False - Parameter IMAGE Mutability = In Type = VARIANT Array = True Convert Majority = False - Parameter FILE Mutability = In Type = BSTR Array = False 2e) File -> Save Project to this same directory where all other files for this application are saved. This creates the IDL binary SAVEfile 'ex_image_histogram_plots_com_wrapdef.sav'. 2f) Build -> Build object. This will create the 'ex_image_histogram_plots.ocx' and 'ex_image_histogram_plots.tlb' files that Visual Studio/Visual C# will need. STEP 3: Microsoft Visual Studio will not find the 'ex_image_histogram_plots.ocx' library until it is registered by the Windows O.S. To do this open a DOS prompt and type: C:\Docum...> cd C:\your\path\to\ex_image_histogram_plots C:\Docum...> regsvr32 ex_image_histogram_plots.ocx A MessageBox should pop up saying that your registration succeeded. Now it's time to make the Visual Studio C# app. This step is needed for the benefit of STEP 5 below. STEP 4: Make a new Visual C# project for this application: - Start -> Microsoft Visual Studio .NET (or Visual C#). - File -> New Project -> Visual C# Projects -> Windows Application, specifying: Name = ex_image_histogram_plots Location = C:\your\path\to\ex_image_histogram_plots\ STEP 5: Add the .ocx you created above to your project's widget toolbox: - Tools -> Add/Remove Toolbox Items -> COM Components tab page - Click on 'ex_image_histogram_plots Class' - Click OK. STEP 6: Use the Toolbox and the Properties form in Visual Studio to set up 'Form1.cs[Design]' with the following widgets: Widget Property Settings ------ ----------------- Form1 Text = IDL Export Bridge Histogram Example Size = 824, 544 Label1 Text = Histogram Generator Size = 168, 23 Location = 0, 8 Font = Verdana, 9.75pt, style=Bold TabIndex = 3 Label2 Text = Change Linestyle: Location = 16, 72 TabIndex = 4 btnOpen Name = btnOpen Button Text = Open New Image Size = 104, 23 Location = 24, 224 TabIndex = 1 lstLinestyle Name = lstLinestyle Listbox DisplayMember = 0 Size = 120, 95 Location = 16, 96 TabIndex = 2 ex_image_ Name = [Default] axex_image_histogram_plots1 histogram_ Size = ***0, 512 plots Class Location = 176, 8 TabIndex = 0 STEP 7: Set up the Listbox options - Highlight the top-level Form1 base widget on 'Form1.cs[Design]' and double-click. - Add the following source code lines to function 'Form1_Load': // Populate the listbox with its options lstLinestyle.Items.Add("Solid (default)") lstLinestyle.Items.Add("Dotted") lstLinestyle.Items.Add("Dashed") lstLinestyle.Items.Add("Dash dot") lstLinestyle.Items.Add("Dash dot dot dot") lstLinestyle.Items.Add("Long dash") lstLinestyle.Items.Add("No line drawn") STEP 8: Make a handler for the Button - Highlight the button on 'Form1.cs[Design]' and double-click. - Add the following source code lines to function 'btnOpen_Click': // Call the IDL class's OPEN method with no specific file // and reset the default plot linestyle. axex_image_histogram_plots1.OPEN(""); lstLinestyle.SetSelected(0, true); STEP 9: Make a handler for the Listbox - Highlight the listbox on 'Form1.cs[Design]' and double-click. - Add the following source code lines to function 'lstLinestyle_SelectedIndexChanged': // Change the plot linestyle based on user selection try { axex_image_histogram_plots1.CHANGELINE( (short)lstLinestyle.SelectedIndex); } catch (Exception ex) { Console.WriteLine("Caught exception {0}", ex); Console.WriteLine(axex_image_histogram_plots1.GetLastError()); } STEP 10: Build and Run the application, i.e. - Build -> Build Solution - Debug -> Start

近期下载者

相关文件


收藏者