parameters: (self,img,format='auto',rows='auto',mode='stretch')
docstring: Sets an image to go underneath the OpenGL rendering.
  
          ``img`` must be a list of bytes or numpy array.  If bytes, then
          ``format`` can be either 'rgb' (same as 'auto'), 'bgr', 'rgba', or 
          'bgra', corresponding to the OpenGL format constant.  In this case,
          ``rows`` must be an integer.
  
          If img is a numpy array with shape w x h x 3, it is assumed to have rgb
          information as channels.  If dtype=uint8, they are assumed to be
          bytes, and otherwise they are assumed to be floats in the range [0,1]
  
          If img has shape w x h, it is assumed to have rgb information as 
          integers 0x00rrggbb by default.  If format='bgr', then the rgb
          information is assumed to be integers 0xbbggrr.
  
          If ``img == None``, then the background image is cleared.
  
          ``mode`` controls how the image is resized to the screen size. 
  
          - 'stretch' resizes the image to the screen.
          - 'scale' resizes the image with a uniform scale to take up either the
            full width or height of the screen.
          - 'fixed' keeps the image size constant and matched to the upper left.
          - 'center' keeps the image size constant and fixed to the center.
          - 'tile' uses the image as a repeating texture.
docstring_summary: Sets an image to go underneath the OpenGL rendering.
docstring_tokens: Sets an image to go underneath the OpenGL rendering .
function: def setBackgroundImage(self,img,format='auto',rows='auto',mode='stretch'):
          """Sets an image to go underneath the OpenGL rendering.
  
          ``img`` must be a list of bytes or numpy array.  If bytes, then
          ``format`` can be either 'rgb' (same as 'auto'), 'bgr', 'rgba', or 
          'bgra', corresponding to the OpenGL format constant.  In this case,
          ``rows`` must be an integer.
  
          If img is a numpy array with shape w x h x 3, it is assumed to have rgb
          information as channels.  If dtype=uint8, they are assumed to be
          bytes, and otherwise they are assumed to be floats in the range [0,1]
  
          If img has shape w x h, it is assumed to have rgb information as 
          integers 0x00rrggbb by default.  If format='bgr', then the rgb
          information is assumed to be integers 0xbbggrr.
  
          If ``img == None``, then the background image is cleared.
  
          ``mode`` controls how the image is resized to the screen size. 
  
          - 'stretch' resizes the image to the screen.
          - 'scale' resizes the image with a uniform scale to take up either the
            full width or height of the screen.
          - 'fixed' keeps the image size constant and matched to the upper left.
          - 'center' keeps the image size constant and fixed to the center.
          - 'tile' uses the image as a repeating texture.
  
          """
          global _globalLock
          if img is None:
              with _globalLock:
                  self.backgroundImage = None
                  self.backgroundImageUploaded = False
              return
              
          pixformat = GL_RGBA
          if hasattr(img,'shape'):
              import numpy as np
              if len(img.shape) == 3:
                  rows = img.shape[0]
                  cols = img.shape[1]
                  assert img.shape[2] == 3
                  if img.dtype == np.uint8:
                      img = img.tobytes()
                  else:
                      img = (img*255.0).convert(dtype=np.uint8).tobytes()
                  pixformat = GL_RGB
              else:
                  assert len(img.shape)==2
                  rows = img.shape[0]
                  cols = img.shape[1]
                  if img.dtype != np.uint32:
                      img = img.astype(np.uint32)
                  img = img.tobytes()
                  if format == 'bgr':
                      pixformat = GL_BGRA
          else:
              if not isinstance(rows,int):
                  raise ValueError("rows must be an integer, not 'auto'")
              pixformat = GL_RGB
              pixsize = 3
              if format == 'bgr':
                  pixformat = GL_BGR
              elif format == 'rgba':
                  pixsize = 4
                  pixformat = GL_RGBA
              elif format == 'bgra':
                  pixsize = 4
                  pixformat = GL_BGRA
              cols = len(img) // (rows*pixsize)
  
          with _globalLock:
              self.backgroundImage = (img,rows,cols,pixformat)
              self.backgroundImageUploaded = False
              if self.backgroundImageDisplayList is None:
                  self.backgroundImageDisplayList = glcommon.CachedGLObject()
              else:
                  self.backgroundImageDisplayList.markChanged()
              self.backgroundImageMode = mode
function_tokens: def setBackgroundImage ( self , img , format = 'auto' , rows = 'auto' , mode = 'stretch' ) : global _globalLock if img is None : with _globalLock : self . backgroundImage = None self . backgroundImageUploaded = False return pixformat = GL_RGBA if hasattr ( img , 'shape' ) : import numpy as np if len ( img . shape ) == 3 : rows = img . shape [ 0 ] cols = img . shape [ 1 ] assert img . shape [ 2 ] == 3 if img . dtype == np . uint8 : img = img . tobytes ( ) else : img = ( img * 255.0 ) . convert ( dtype = np . uint8 ) . tobytes ( ) pixformat = GL_RGB else : assert len ( img . shape ) == 2 rows = img . shape [ 0 ] cols = img . shape [ 1 ] if img . dtype != np . uint32 : img = img . astype ( np . uint32 ) img = img . tobytes ( ) if format == 'bgr' : pixformat = GL_BGRA else : if not isinstance ( rows , int ) : raise ValueError ( "rows must be an integer, not 'auto'" ) pixformat = GL_RGB pixsize = 3 if format == 'bgr' : pixformat = GL_BGR elif format == 'rgba' : pixsize = 4 pixformat = GL_RGBA elif format == 'bgra' : pixsize = 4 pixformat = GL_BGRA cols = len ( img ) // ( rows * pixsize ) with _globalLock : self . backgroundImage = ( img , rows , cols , pixformat ) self . backgroundImageUploaded = False if self . backgroundImageDisplayList is None : self . backgroundImageDisplayList = glcommon . CachedGLObject ( ) else : self . backgroundImageDisplayList . markChanged ( ) self . backgroundImageMode = mode