title: opencv read jpeg image from buffer
body: <p>I have an <code>unsigned char*</code> buffer containing data of a jpeg image. I would like to display that image using c++ and opencv. If i do:</p>
  
  <pre><code>Mat img(Size(640, 480), CV_8UC3, data);
  namedWindow("image", 1);
  imShow("image", img);
  </code></pre>
  
  <p>I get a noisy mess of pixels.</p>
  
  <p>I suppose it's because the data is jpeg (with a header). Because this works:</p>
  
  <pre><code>Mat imgbuf(Size(640, 480), CV_8UC3, data);
  Mat img = imdecode(imgbuf, CV_LOAD_IMAGE_COLOR);
  </code></pre>
  
  <p>BUT I cannot use the imdecode function as it is from highgui.h which is based upon GTK 2, and in my project I use GTK 3.</p>
  
  <p>So, how can I display the buffer data? Is there a way to decode the jpeg image other than imdecode in opencv, if that's the problem. I don't really want to have to rebuild opencv with Qt...</p>
  
  <p>Any other suggestions?</p>
  
  <p>(Using Linux)</p>