def SaveBackground(self, dc): """ Save the given dc as the new background image. @param DC dc : the dc to save """ w, h = self.GetSize() bb = self.__backgroundBitmap if (bb.GetWidth(), bb.GetHeight()) != (w, h): bb = self.__backgroundBitmap = Bitmap(w, h) mem = MemoryDC() mem.SelectObject(bb) if __version__ > "2.3.2": x, y = self.CalcUnscrolledPosition(0, 0) mem.Blit(0, 0, w, h, dc, x, y) else: mem.Blit(0, 0, w, h, dc, 0, 0) mem.SelectObject(NullBitmap)
def main(default=True): app = App() screen = ScreenDC() size = screen.GetSize() if default: size = (round(size[0] * 2.5), round(size[1] * 2.5)) bmp = Bitmap(size[0], size[1]) mem = MemoryDC(bmp) mem.Blit(0, 0, size[0], size[1], screen, 0, 0) del mem name = '{}.png'.format(str(randrange(1000))) fname = os.path.join(os.getcwd(), name) bmp.SaveFile(fname, BITMAP_TYPE_PNG) return fname
def SaveBackground(self, dc: DC): """ Args: dc: The DC to save """ w, h = self.GetSize() bb = self.__backgroundBitmap if (bb.GetWidth(), bb.GetHeight()) != (w, h): bb = self.__backgroundBitmap = Bitmap(w, h) mem = MemoryDC() mem.SelectObject(bb) x, y = self.CalcUnscrolledPosition(0, 0) mem.Blit(0, 0, w, h, dc, x, y) mem.SelectObject(NullBitmap)