I try to write a CLI wrapper for OpenCV, which returns a bitmap from a given OpenCV matrix. I use a function with a fix image inside the wrapper to test it:
Bitmap^ GetImage()
{
Mat frame = imread("Image.png", 0);
return gcnew Bitmap(frame.cols, frame.rows, 4 * frame.rows, System::Drawing::Imaging::PixelFormat::Format24bppRgb, IntPtr(frame.data));
}
My C# code contains the following code to store the image back:
Bitmap Test = Wrapper.GetImage();
Test.Save(@"C:\temp\Bla.bmp");
After executing the code, I´ve got this exception:
How can I fix it? What is the reason for this exception?