class_docstr: Wrapper for the FI bitmap object.
class_docstr_tok: ["Wrapper","for","the","FI","bitmap","object","."]
code: def set_image_data(self, array):
      # Prepare array
      assert isinstance(array, numpy.ndarray)
      shape = array.shape
      dtype = array.dtype
      with self._fi as lib:
          isle = lib.FreeImage_IsLittleEndian()
  
      # Calculate shape and channels
      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:
          n_channels = shape[0]
  
      def n(arr):  # normalise to freeimage's in-memory format
          return arr[::-1].T
  
      wrapped_array = self._wrap_bitmap_bits_in_array(
          w_shape, dtype, True
      )
      # swizzle the color components and flip the scanlines to go to
      # FreeImage's BGR[A] and upside-down internal memory format
      # The BGR[A] order is only used for 8bits per channel images
      # on little endian machines. For everything else RGB[A] is
      # used.
      if len(shape) == 3 and isle and dtype.type == numpy.uint8:
          R = array[:, :, 0]
          G = array[:, :, 1]
          B = array[:, :, 2]
          wrapped_array[0] = n(B)
          wrapped_array[1] = n(G)
          wrapped_array[2] = n(R)
          if shape[2] == 4:
              A = array[:, :, 3]
              wrapped_array[3] = n(A)
      else:
          wrapped_array[:] = n(array)
      if self._need_finish:
          self._finish_wrapped_array(wrapped_array)
  
      if len(shape) == 2 and dtype.type == numpy.uint8:
          with self._fi as lib:
              palette = lib.FreeImage_GetPalette(self._bitmap)
          palette = ctypes.c_void_p(palette)
          if not palette:
              raise RuntimeError("Could not get image palette")
          try:
              palette_data = GREY_PALETTE.ctypes.data
          except Exception:  # pragma: no cover - IS_PYPY
              palette_data = GREY_PALETTE.__array_interface__["data"][0]
          ctypes.memmove(palette, palette_data, 1024)
  
imports: import os
  import sys
  import ctypes
  import threading
  import logging
  import numpy
  from ..core import get_remote_file, load_lib, Dict, resource_dirs, IS_PYPY, get_platform, InternetNotAllowedError, NeedDownloadError
label_desc: Use image node_id 5 for calling the FIBitmap obj's underlying member method code with example usage: obj.set_image_data(array) and returns: arr