parameters: (filename, data, resolution, write_async=True)
docstring: Write the linearized RGB image in `data` to a PNG/EXR/.. file with
      resolution `resolution`.
docstring_summary: Write the linearized RGB image in `data` to a PNG/EXR/.. file with
      resolution `resolution`.
docstring_tokens: Write the linearized RGB image in data to a PNG / EXR / .. file with resolution resolution .
function: def write_bitmap(filename, data, resolution, write_async=True):
      """
      Write the linearized RGB image in `data` to a PNG/EXR/.. file with
      resolution `resolution`.
      """
      import numpy as np
      from mitsuba.core import Bitmap, Struct
  
      if type(data).__name__ == 'Tensor':
          data = data.detach().cpu()
  
      data = np.array(data.numpy())
      data = data.reshape(resolution[1], resolution[0], -1)
      bitmap = Bitmap(data)
      if filename.endswith('.png') or \
         filename.endswith('.jpg') or \
         filename.endswith('.jpeg'):
          bitmap = bitmap.convert(Bitmap.PixelFormat.RGB,
                                  Struct.Type.UInt8, True)
      quality = 0 if filename.endswith('png') else -1
  
      if write_async:
          bitmap.write_async(filename, quality=quality)
      else:
          bitmap.write(filename, quality=quality)
function_tokens: def write_bitmap ( filename , data , resolution , write_async = True ) : import numpy as np from mitsuba . core import Bitmap , Struct if type ( data ) . __name__ == 'Tensor' : data = data . detach ( ) . cpu ( ) data = np . array ( data . numpy ( ) ) data = data . reshape ( resolution [ 1 ] , resolution [ 0 ] , - 1 ) bitmap = Bitmap ( data ) if filename . endswith ( '.png' ) or filename . endswith ( '.jpg' ) or filename . endswith ( '.jpeg' ) : bitmap = bitmap . convert ( Bitmap . PixelFormat . RGB , Struct . Type . UInt8 , True ) quality = 0 if filename . endswith ( 'png' ) else - 1 if write_async : bitmap . write_async ( filename , quality = quality ) else : bitmap . write ( filename , quality = quality )