title: wxWidgets + OpenCV: wxBitmap does not draw wxImage correctly
body: <p>I'm trying to make a <code>wxImage</code> out of a <code>cv::Mat</code> raw data, and have a <code>wxBitmap</code> draw it out on a <code>wxPanel</code>-derived class (this <code>bmImage</code> class).</p>
  
  <p>Here's the code for loading the <code>cv::Mat</code> data into the <code>wxImage</code>.</p>
  
  <pre><code>cv::Mat asCvMat = cv::imread("something.png", 1);
  cv::imshow("preview", asCvMat);
  cv::Mat cvtResult;
  aswxImage = wxImage(asCvMat.cols, asCvMat.rows, asCvMat.data, true);
  wxLogMessage(wxT("%s"), std::string((char*)asCvMat.data));
  </code></pre>
  
  <p>And here's the code for drawing the <code>wxBitmap</code> out.</p>
  
  <pre><code>void bmImage::render(wxDC&amp; dc) {
      wxBitmap bitmap = wxBitmap(aswxImage);
      dc.DrawBitmap(bitmap, wxPoint(0, 0), false);
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/YhtpW.png" alt="enter image description here"></p>
  
  <p>The little image on the left is the image I try to load and showed with <code>cv::imshow</code>, and the one on the right is the resulting <code>wxBitmap</code>. It doesn't show the image correctly. How should I fix this to show the image properly?</p>
  
  <p>Plus, what's confusing me is the (null) value of <code>asCvMat.data</code>. Does this mean that <code>wxImage()</code> has finished loading all the pixel data from it so it has reached the end (<code>\0</code>)?</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <pre><code>cv::Mat asCvMat = cv::imread("something.png", 1);
  cv::imshow("preview", asCvMat);
  void *mdata = malloc((size_t)(asCvMat.dataend - asCvMat.datastart));
  std::memcpy(mdata, asCvMat.data, (size_t)(asCvMat.dataend - asCvMat.datastart));
  
  cv::Mat cvtResult;
  aswxImage = wxImage(asCvMat.cols, asCvMat.rows, (unsigned char*)mdata, false);
  
  wxLogMessage(wxT("%s"), std::string((char*)mdata));
  </code></pre>
  
  <p>yet it's the same thing... sometimes it throws an unhandled memory exception if I load a large image.</p>