code: def _array_to_bitmap(array):
      """Allocate a FreeImage bitmap and copy a numpy array into it."""
      shape = array.shape
      dtype = array.dtype
      r, c = shape[:2]
      if len(shape) == 2:
          n_channels = 1
          w_shape = (c, r)
      elif len(shape) == 3:
          n_channels = shape[2]
          w_shape = (n_channels, c, r)
      else:
          raise ValueError(
              "mahotas.freeimage: cannot handle image of 4 dimensions"
          )
      try:
          fi_type = FI_TYPES.fi_types[(dtype.type, n_channels)]
      except KeyError:
          raise ValueError(
              "mahotas.freeimage: cannot write arrays of given type and shape."
          )
  
      itemsize = array.dtype.itemsize
      bpp = 8 * itemsize * n_channels
      bitmap = _FI.FreeImage_AllocateT(fi_type, c, r, bpp, 0, 0, 0)
      if not bitmap:
          raise RuntimeError(
              "mahotas.freeimage: could not allocate image for storage"
          )
      try:
  
          def n(arr):  # normalise to freeimage's in-memory format
              return arr.T[:, ::-1]
  
          wrapped_array = _wrap_bitmap_bits_in_array(
              bitmap, w_shape, dtype
          )
          # swizzle the color components and flip the scanlines to go to
          # FreeImage's BGR[A] and upside-down internal memory format
          if (
              len(shape) == 3
              and _FI.FreeImage_IsLittleEndian()
              and dtype.type == np.uint8
          ):
              wrapped_array[0] = n(array[:, :, 2])
              wrapped_array[1] = n(array[:, :, 1])
              wrapped_array[2] = n(array[:, :, 0])
              if shape[2] == 4:
                  wrapped_array[3] = n(array[:, :, 3])
          else:
              wrapped_array[:] = n(array)
  
          return bitmap, fi_type
      except:
          _FI.FreeImage_Unload(bitmap)
          raise
  
imports: import sys
  import os
  import ctypes
  import ctypes.util
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: _array_to_bitmap(array) and returns: bitmap,  fi_type, arr