title: bytearray to numpy array in Python for displaying in pyqt5 GUI
body: <p>I'm new to Python and have sorta c++ style coding background.</p>
  <p>In short:</p>
  <ul>
  <li>tring to display 16 bit grayscale images in my GUI(pyqt6)</li>
  <li>have the stored the image data in bytearray, that is, 1024 by 768 (the total size of the byte array would be 1024 x 768 x 2 since it's 16 bit).</li>
  <li>having difficulties with using this data = bytearray(1572864) for displaying.</li>
  </ul>
  <p>The following code is what I have used for displaying the same image (but downscaled to 8-bit).
  What I'm now trying to do is use the 16-bit data and have it converted to QPixmap in order to display.</p>
  <p>The code for displaying 8-bit raw image is ( I have used rawpy for this, please feel free to get rid of the rawpy section if you could come up with a better way to do this)</p>
  <pre class="lang-py prettyprint-override"><code>raw = np.array( binary data read from file)
  src = raw.postprocess()
  buf = src.data.tobytes()
  h, w, ch = src.shape
  bytesperline = ch * w
  image = QImage(buf, 1024, 768, bytesperline, QImage.Format_RGB888)
  self.DisplayRect.setPixmap(QPixmap.fromImage(image))
  self.DisplayRect.show()
  </code></pre>
  <p>Hope I explained my question without causing any confusion. In summary:</p>
  <ul>
  <li>trying to use data in bytearray(1572864) to display in my GUI</li>
  <li>in need of help with manipulating the binary data from/to different data structures</li>
  </ul>
  <p>What I would have done if it were c++:</p>
  <pre class="lang-cpp prettyprint-override"><code>//declare a Mat with 16UC1 format
  //easily memcpy(mat.data, source, size);
  //stretchDiBits(dc, where_to_draw_imgs, mat.data);
  </code></pre>
  <p>Thank you very much in advance.</p>