python - How can a Pygame surface be converted to an image file say a jpeg or a png WITHOUT writing the file to disk? Say after a screen grab? -
this usual code.
get_screen = screen.subsurface(0, 0, screenw, screenh) pygame.image.save(get_screen, image_filename) # save file jpeg ## reopen image , base64 encode open(image_filename, "rb") imagefile: imagestr = base64.b64encode(imagefile.read()) ## save imagestr(image textfle) disk open(text_filename, "wb") f: f.write(imagestr) what convert get_screen jpeg image without first writing disk in second line. kind of conversion in memory. there way that?
Comments
Post a Comment