C++dll 源码:
void _startLedCheck(byte *ImageBuffer, int imageWedth, int imageHeight)
{
Mat src = cv::Mat(imageHeight, imageWedth, CV_8UC3, ImageBuffer);
}
C#源码:
[DllImport(“LedCheck.dll”, EntryPoint = “_startLedCheck”, CallingConvention = CallingConvention.Cdecl)]
static extern void _startLedCheck(byte[] ImageBuffer, int imageWedth, int imageHeight);
private void buttonLoadImage_Click(object sender, EventArgs e)
{
Bitmap bmp = (Bitmap)Image.FromFile(“1.jpg”);
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
int bytes = Math.Abs(bmp