資源簡(jiǎn)介
c++里通過opencv讀取圖片后考入內(nèi)存?zhèn)鞒鲋羔樈oc#,并在picturebox里顯示

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.Runtime.InteropServices;
using?System.Threading;
using?System.IO;
using?System.Drawing.Imaging;
namespace?_1108_2
{
????public?partial?class?Form1?:?Form
????{
????????class?CPPDLL
????????{
????????????[DllImport(“dll.dll“?CharSet?=?CharSet.Ansi)]
????????????public?static?extern?unsafe?byte*?initZed(?out?int?widthout?int?heightout?int?channels);
???????????//?public?static?extern?unsafe?Byte*?initZed();
????????????//[DllImport(“111.dll“?CharSet?=?CharSet.Ansi)]
????????????//public?static?extern?unsafe?int?initZed();
????????????////[DllImport(“1107.dll“?CharSet?=?CharSet.Ansi)]
????????????////public?static?extern?unsafe?int?test();
????????????//[DllImport(“1107.dll“?CharSet?=?CharSet.Ansi)]
????????????//public?static?extern?unsafe?float*?getImage();
????????????////[DllImport(“111.dll“?CharSet?=?CharSet.Ansi)]
????????????////public?static?extern?unsafe?int?test();
????????}
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?float[]?cross(float[]?A?float[]?B?float[]?C)
????????{
????????????float[]?AB?=?new?float[3];
????????????float[]?BC?=?new?float[3];
????????????AB[0]?=?B[0]?-?A[0];
????????????AB[1]?=?B[1]?-?A[1];
????????????AB[2]?=?B[2]?-?A[2];
????????????BC[0]?=?C[0]?-?B[0];
????????????BC[1]?=?C[1]?-?B[1];
????????????BC[2]?=?C[2]?-?B[2];
????????????float[]?arr?=?new?float[3];
????????????float?crs1?=?AB[1]?*?BC[2]?-?AB[2]?*?BC[1];
????????????float?crs2?=?BC[0]?*?AB[2]?-?BC[2]?*?AB[0];
????????????float?crs3?=?AB[0]?*?BC[1]?-?AB[1]?*?BC[0];
????????????arr[0]?=?crs1;
????????????arr[1]?=?crs2;
????????????arr[2]?=?crs3;
????????????return?arr;
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
???????????//?int?key?=?CPPDLL.initZed();
????????}
????????public?static?Bitmap?BytesToBmp(byte[]?bmpBytes?Size?imageSize)
????????{
????????????Bitmap?bmp?=?new?Bitmap(imageSize.Width?imageSize.Height);
????????????BitmapData?bData?=?bmp.LockBits(new?Rectangle(0?0?imageSize.Width?imageSize.Height)
????????????ImageLockMode.ReadWrite
????????????PixelFormat.Format24bppRgb);?//24bit?rgb???Format24bppRgb
????????????//?Copy?the?bytes?to?the?bitmap?object
????????????System.Runtime.InteropServices.Marshal.Copy(bmpBytes?0?bData.Scan0?bmpBytes.Length);
????????????bmp.UnlockBits(bData);
????????????return?bmp;
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
??????????
????????????unsafe
????????????{
????????????????int??width??heightchannels;
????????????????byte?*?ptr_image_data?;
????????????????//byte?image_data?=?new?byte();
???????????????
????????????????ptr_image_data?=?CPPDLL.in
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????5921??2018-12-11?10:23??dll讀取圖片到c#\Form1.cs
?????文件?????????980??2018-12-11?10:26??dll讀取圖片到c#\MyDll.cpp
?????目錄???????????0??2018-12-11?10:27??dll讀取圖片到c#\
評(píng)論
共有 條評(píng)論