
Delegate為委派,Invoke表示要呼叫所指定的方法(method),第二個為傳入參數陣列 MyFormControl繼承Form 1. Line 3: 宣告委派:delegate void AddListItem(String myString),表示需要傳入一字串無回傳值。 2. Line4: 宣告委派:delegate void ClearListItem(),表示無參數輸入且無回傳值。



1: public Mat ConvertBitmapToMat(Bitmap bmp)
2: {3: // Lock the bitmap's bits.
4: Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
5: 6: System.Drawing.Imaging.BitmapData bmpData = 7: bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, 8: bmp.PixelFormat); 9: 10: // data = scan0 is a pointer to our memory block.
11: IntPtr data = bmpData.Scan0; 12: 13: // step = stride = amount of bytes for a single line of the image
14: int step = bmpData.Stride;
15: 16: // So you can try to get you Mat instance like this:
17: Mat mat = new Mat(bmp.Height, bmp.Width, Emgu.CV.CvEnum.DepthType.Cv32F, 4, data, step);
18: 19: // Unlock the bits.
20: bmp.UnlockBits(bmpData); 21: 22: return mat;
23: }