如果没有numpy模块,我怎么能这样做? 它绘制一个白色方块256x256
rows = [[255 for element in xrange(4) for number_of_pixles in xrange(256)] for number_of_rows in xrange(256)]
import numpy # Using numpy is much faster
rows = numpy.zeros((256, 256 * 4), dtype = 'int')
rows[:] = 255
png_writer = png.Writer(width = 256, height = 256, alpha = 'RGBA')
png_writer.write(open('white_panel.png', 'wb'), rows)
答案 0 :(得分:0)
你已经创造了一个没有numpy的广场。所以只需使用它:
rows = [[255]* 4 * 256] * 256
png_writer = png.Writer(width=256, height=256, alpha='RGBA')
with open('white_panel.png', 'wb') img:
png_writer.write(img, rows)