title: Convert Bitmap to Mat
body: <p>I need to convert Gdiplus::Bitmap to cv::Map format.
  I'm using this code to do this:</p>
  
  <pre><code>Gdiplus::Bitmap* enhanced = ...; // some Bitmap
  Gdiplus::BitmapData bmp_data = {};
  Gdiplus::Rect rect(0, 0, enhanced-&gt;GetWidth(), enhanced-&gt;GetHeight());
  
  enhanced-&gt;LockBits(&amp;rect, Gdiplus::ImageLockModeRead, enhanced-&gt;GetPixelFormat(), &amp;bmp_data);
  
  Mat imageMap(enhanced-&gt;GetHeight(), enhanced-&gt;GetWidth(), CV_8UC3, bmp_data.Scan0, std::abs(bmp_data.Stride)); // construct Map from Bitmap data. The problem is probably here
  
  cvNamedWindow("w", 1);
  cvShowImage("w", &amp;imageMap); // runtime error (access violation)
  cvWaitKey(0);
  </code></pre>
  
  <p>I have an runtime error, as <em>imageMap</em> wasn't properly constructed. What am I doing wrong here? I will be gratefull for your explanation.</p>