code: def _array_from_bitmap(bitmap):
      """Convert a FreeImage bitmap pointer to a numpy array"""
      dtype, shape = FI_TYPES.get_type_and_shape(bitmap)
      if type(dtype) == str and dtype == "bit":
          bitmap8 = _FI.FreeImage_ConvertToGreyscale(bitmap)
          try:
              return _array_from_bitmap(bitmap8).astype(bool)
          finally:
              _FI.FreeImage_Unload(bitmap8)
      array = _wrap_bitmap_bits_in_array(bitmap, shape, dtype)
  
      # swizzle the color components and flip the scanlines to go from
      # FreeImage's BGR[A] and upside-down internal memory format to something
      # more normal
      def n(arr):
          return arr[..., ::-1].T
  
      if (
          len(shape) == 3
          and _FI.FreeImage_IsLittleEndian()
          and dtype.type == np.uint8
      ):
          b = n(array[0])
          g = n(array[1])
          r = n(array[2])
          if shape[0] == 3:
              return np.dstack((r, g, b))
          elif shape[0] == 4:
              a = n(array[3])
              return np.dstack((r, g, b, a))
          else:
              raise ValueError(
                  "mahotas.freeimage: cannot handle images of"
                  " this shape (%s)" % shape
              )
  
      # We need to copy because array does *not* own its memory
      # after bitmap is freed.
      return n(array).copy()
  
imports: import sys
  import os
  import ctypes
  import ctypes.util
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: _array_from_bitmap(bitmap) and returns: n, arr, _array_from_bitmap, np, np