code: def test_ndarray_from_qimage():
      # for QImages created w/o specifying bytesPerLine, Qt will pad
      # each line to a multiple of 4-bytes.
      # test that we can handle such QImages.
      h = 10
  
      fmt = QtGui.QImage.Format.Format_RGB888
      for w in [5, 6, 7, 8]:
          qimg = QtGui.QImage(w, h, fmt)
          qimg.fill(0)
          arr = pg.functions.ndarray_from_qimage(qimg)
          assert arr.shape == (h, w, 3)
  
      fmt = QtGui.QImage.Format.Format_Grayscale8
      for w in [5, 6, 7, 8]:
          qimg = QtGui.QImage(w, h, fmt)
          qimg.fill(0)
          arr = pg.functions.ndarray_from_qimage(qimg)
          assert arr.shape == (h, w)
  
imports: from collections import OrderedDict
  from copy import deepcopy
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal
  import pyqtgraph
  from pyqtgraph.functions import arrayToQPath, eq
  from pyqtgraph.Qt import QtGui
label_desc: Use image node_id 13 for calling a global function with example usage: test_ndarray_from_qimage() without return types