def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # Create X11 window bk = backends.x11_init(None, 0, 0, img.w, img.h, sys.argv[1], 0) assert(bk) img.blit(0, 0, bk.pixmap, 0, 0, img.w, img.h) bk.flip() # Event loop while True: ev = bk.wait_event() input.event_dump(ev) if (ev.type == input.EV_KEY): sys.exit(0) elif (ev.type == input.EV_SYS): if (ev.code == input.EV_SYS_QUIT): sys.exit(0)
def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # Create X11 window bk = backends.x11_init(None, 0, 0, img.w, img.h, sys.argv[1], 0) assert (bk) img.blit(0, 0, bk.pixmap, 0, 0, img.w, img.h) bk.flip() # Event loop while True: ev = bk.wait_event() input.event_dump(ev) if (ev.type == input.EV_KEY): sys.exit(0) elif (ev.type == input.EV_SYS): if (ev.code == input.EV_SYS_QUIT): sys.exit(0)
def getpixmap(path): img = loaders.load(path) if img.pixel_type != core.C.PIXEL_BGR888: img = img.convert(core.C.PIXEL_BGR888) qt_img = QtGui.QImage(img.to_byte_array(), img.w, img.h, img.bytes_per_row, QtGui.QImage.Format_RGB888) pix = QtGui.QPixmap.fromImage(qt_img) return pix
def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # save result img.loaders.save("out.png");
def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # save result img.loaders.save("out.png")
def __init__(self, x, y, dx, dy, path, bg_img): self.ball = loaders.load(path) assert(self.ball) self.x = x self.y = y self.dx = dx self.dy = dy self.bg_img = bg_img
def main(): if len(sys.argv) != 3: print("USAGE: %s imput_image output_image" % sys.argv[0]); sys.exit(1) # load Image src = loaders.load(sys.argv[1]) # Resize image to the half of the original res = src.filters.resize_linear_lf_int_alloc(src.w//2, src.h//2) # save Image res.loaders.save(sys.argv[2])
def main(): if len(sys.argv) != 2: print("usage: invert.py image") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # invert image in-place img.filters.invert(img); # Save result into png img.loaders.save_png("out.png")
def main(): if len(sys.argv) != 2: print("usage: dither.py image") sys.exit(1) # load Image img = loaders.load(sys.argv[1]) # Use Floyd-Steinberg dithering res = img.filters.floyd_steinberg_alloc(core.C.PIXEL_G1) # Save result into grayscale png res.loaders.save_png("out.png")
def main(): if len(sys.argv) != 3: print("usage: blur blur-radii image") sys.exit(1) radii = float(sys.argv[1]) # Load Image img = loaders.load(sys.argv[2]) # Do in-place gaussian blur filters.gaussian_blur(img, img, radii, radii) # Save result img.loaders.save_jpg("out.jpg")
def main(): if len(sys.argv) != 3: print("USAGE: %s imput_image output_image" % sys.argv[0]); sys.exit(1) # Turns on debug messages core.set_debug_level(10); # load Image src = loaders.load(sys.argv[1]) # Rotate by 90 degrees res = src.filters.rotate_90_alloc() # save Image res.loaders.save(sys.argv[2])
def main(): if len(sys.argv) != 2: print("usage: convolution.py image") sys.exit(1) # Load Image img = loaders.load(sys.argv[1]) # Box blur kernel kern = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]] res = img.filters.convolution_alloc(kern, 25); # Save result into png res.loaders.save_png("out.png")
def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) try: img = loaders.load(sys.argv[1], progress_callback1) print('') except OSError as detail: print("Failed to load image '%s': %s" % (sys.argv[1], detail)) exit(1) try: callback = (progress_callback2, "Gaussian Blur") img = img.filters.gaussian_blur_alloc(50, 50, callback) print('') except OSError: print("Filter Aborted")
def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) # load Backgroudn Image and ball sprite bg = loaders.load(sys.argv[1]) assert(bg) ball1 = Ball(bg.w//2, bg.h//2, -3, -3, 'ball_red.png', bg) ball2 = Ball(bg.w//2, bg.h//2, -2, 3, 'ball_green.png', bg) ball3 = Ball(bg.w//2, bg.h//2, 2, -3, 'ball_blue.png', bg) # Create X11 window bk = backends.x11_init(None, 0, 0, bg.w, bg.h, sys.argv[1], 0) assert(bk) bg.blit(0, 0, bk.pixmap, 0, 0, bg.w, bg.h) bk.flip() # Event loop while True: while True: ev = bk.poll_event() if (ev is None): break input.event_dump(ev) if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC): sys.exit(0) elif (ev.type == input.EV_SYS): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) if (ev.code == input.EV_SYS_RESIZE): bk.resize_ack() sleep(0.005) ball1.move(bk); ball2.move(bk); ball3.move(bk);