#NEWLINE# def write_png( filename , width , height , rgb_func ) : #NEWLINE# #INDENT# out = open ( filename , 'wb' ) #NEWLINE# out . write ( struct . pack ( '8B' , 137 , 80 , 78 , 71 , 13 , 10 , 26 , 10 ) ) #NEWLINE# output_chunk ( out , 'IHDR' , struct . pack ( '!2I5B' , width , height , 8 , 2 , 0 , 0 , 0 ) ) #NEWLINE# output_chunk ( out , 'IDAT' , get_data ( width , height , rgb_func ) ) #NEWLINE# output_chunk ( out , 'IEND' , '' ) #NEWLINE# out . close ( )