def load_png(path): """Load an image and return the image object. Args: path (str): The image file path to load. Returns: Surface: The loaded image. """ try: image = pygame.image.load(path) if image.get_alpha() is None: image.convert() else: image.convert_alpha() except pygame.error as message: print('Cannot load image: ', path) raise SystemExit(message) return image
def load_img(name): """Load an image as surface and convert it. Return an image and rect object""" path = os.path.join(IMG_DIR, name) image = pygame.image.load(path) if image.get_alpha is None: image = image.convert() else: image = image.convert_alpha() image_rect = image.get_rect() return image, image_rect
def load_png(name): """ Load image and return image object""" fullname = os.path.join('images', name) try: image = pygame.image.load(fullname) if image.get_alpha() is None: image = image.convert() else: image = image.convert_alpha() except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message
def run(image, config): rects = config['rects'] centers = config['centers'] names = list(rects.keys()) pg.display.init() screen = pg.display.set_mode(image.get_size(), 0, 32) image = image.convert_alpha() R = 5 circle = pg.Surface((R * 2 + 1, R * 2 + 1)).convert_alpha() circle.fill((255, 255, 255, 0)) pg.draw.circle(circle, (0, 255, 0, 255), (R + 1, R + 1), R, 1) circle.set_at((R + 1, R + 1), (0, 255, 0, 255)) tm = pg.time.Clock() quit = False while not quit: for e in pg.event.get(): if e.type == pg.QUIT: quit = True elif e.type == pg.MOUSEBUTTONDOWN: x1, y1 = e.pos for name in names: x, y, w, h = rects[name] if x <= x1 < x + w and y <= y1 < y + h: centers[name] = x1 - x, y1 - y print(name, centers[name]) break screen.fill((255, 255, 255, 255)) screen.blit(image, (0, 0)) for name in names: x, y, w, h = rects[name] cx, cy = centers[name] screen.blit(circle, (x + cx - R - 1, y + cy - R - 1)) pg.display.update() tm.tick(30) return config
def loadImage(name): image = pygame.image.load( os.path.join(SolSet.image_path, name + SolSet.image_type)) return image.convert_alpha()
def loadImage(name): image = pygame.image.load(os.path.join(Stillingar.mynd_path, str(name) + Stillingar.mynd_gerd)) return image.convert_alpha()
def load(self): self._image = pygame.image.load(self._name) if self._image.get_alpha() is None: self._image = image.convert() else: self._image = image.convert_alpha()
def HladaMynd(nafn_spils) : mynd = pygame.image.load(nafn_spils.path) return image.convert_alpha()
def loadImage(name) : image = pygame.image.load(os.path.join(SolSet.image_path, name + SolSet.image_type)) return image.convert_alpha()