def saveScreen(self, filename): wp, hp = (ctypes.c_int)(), (ctypes.c_int)() assert sdl2.SDL_GetRendererOutputSize(self.renderer, ctypes.pointer(wp), ctypes.pointer(hp)) == 0, \ "Could not get renderer size: %s" % sdl2.SDL_GetError() w, h = wp.value, hp.value render_target = sdl2.SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000) assert render_target is not None, "Could not create RGB surface for screenshot: %s" % sdl2.SDL_GetError() try: assert sdl2.SDL_RenderReadPixels(self.renderer, sdl2.SDL_Rect(0, 0, w, h), sdl2.SDL_PIXELFORMAT_ARGB8888, render_target.contents.pixels, render_target.contents.pitch) == 0, "Could not read screenshot: %s" % sdl2.SDL_GetError() image.saveImage(image.wrapSurface(render_target), filename) finally: sdl2.SDL_FreeSurface(render_target)
def saveImage(multi=False): """Save an image to file. This will show the Save Image dialog, with the multisave mode checked if multi = True. Then, depending on the user's selection, it will either: - save the current Canvas/Window to file - start the multisave/autosave mode - do nothing """ pat = map(utils.fileDescription, ['img','icon','all']) dia = widgets.SaveImageDialog(GD.cfg['workdir'],pat,multi=multi) opt = dia.getResult() if opt: GD.cfg['workdir'] = os.path.dirname(opt.fn) image.saveImage(filename=opt.fn, window=opt.wi, multi=opt.mu, hotkey=opt.hk, autosave=opt.as, border=opt.bo, rootcrop=opt.rc )
def stopMultiSave(): """Stop multisave mode.""" image.saveImage()