title: Return Bitmap with C++/CLI Wrapper
body: <p>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:</p>
  
  <pre><code>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));
  }
  </code></pre>
  
  <p>My C# code contains the following code to store the image back:</p>
  
  <pre><code>Bitmap Test = Wrapper.GetImage();
  Test.Save(@"C:\temp\Bla.bmp");
  </code></pre>
  
  <p>After executing the code, I´ve got this exception:</p>
  
  <p><a href="https://i.stack.imgur.com/79lqW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/79lqW.png" alt="http://i.stack.imgur.com/79lqW.png"></a></p>
  
  <p>How can I fix it? What is the reason for this exception?</p>