@staticmethod
def write_png(filename, image):
    ' image must be numpy array H X W X channels\n        '
    import zlib, struct
    buf = image.flatten().tobytes()
    width = image.shape[1]
    height = image.shape[0]
    width_byte_4 = (width * 4)
    raw_data = b''.join(((b'\x00' + buf[span:(span + width_byte_4)]) for span in range(((height - 1) * width_byte_4), (- 1), (- width_byte_4))))

    def png_pack(png_tag, data):
        chunk_head = (png_tag + data)
        return ((struct.pack('!I', len(data)) + chunk_head) + struct.pack('!I', (4294967295 & zlib.crc32(chunk_head))))
    png_bytes = b''.join([b'\x89PNG\r\n\x1a\n', png_pack(b'IHDR', struct.pack('!2I5B', width, height, 8, 6, 0, 0, 0)), png_pack(b'IDAT', zlib.compress(raw_data, 9)), png_pack(b'IEND', b'')])
    AirSimClientBase.write_file(filename, png_bytes)
image must be numpy array H X W X channels
@staticmethod
def write_png(filename, image):
    ' \n        '
    import zlib, struct
    buf = image.flatten().tobytes()
    width = image.shape[1]
    height = image.shape[0]
    width_byte_4 = (width * 4)
    raw_data = b.join(((b'\x00' + buf[span:(span + width_byte_4)]) for span in range(((height - 1) * width_byte_4), (- 1), (- width_byte_4))))

    def png_pack(png_tag, data):
        chunk_head = (png_tag + data)
        return ((struct.pack('!I', len(data)) + chunk_head) + struct.pack('!I', (4294967295 & zlib.crc32(chunk_head))))
    png_bytes = b.join([b'\x89PNG\r\n\x1a\n', png_pack(b'IHDR', struct.pack('!2I5B', width, height, 8, 6, 0, 0, 0)), png_pack(b'IDAT', zlib.compress(raw_data, 9)), png_pack(b'IEND', b)])
    AirSimClientBase.write_file(filename, png_bytes)