def generateCar(color): c = mainCar.copy() pixels = PixelArray(c) pixels.replace(Color(0,255,0, 255), color,0) surf = pixels.make_surface() del pixels surf = pygame.transform.smoothscale(surf,(30,30)) return surf
def extract_mask(img): mock = img.copy() umap = mock.unmap_rgb pxarray = PixelArray(mock) w,h = mock.get_size() alpha = mask.Mask((w, h)) for y in range(h): for x in range(w): r,g,b,a = umap(pxarray[x,y]) if a == 255: alpha.set_at([x,y],1) elif a != 0: pxarray[x,y] = r,g,b,255 render = pxarray.make_surface() return render,alpha
maxy = -1 for x, row in enumerate(array): if maxx < x: maxx = x for y, pixel in enumerate(row): if maxy < y: maxy = y dist += abs(pixel - original[x, y]) return dist / float(x / y) for i in xrange(50): img = cam.get_image() img = cam.get_image() first = PixelArray(img) while True: img = cam.get_image() pa = PixelArray(img) # compared = first.compare(pa) # img = compared.make_surface() # pygame.image.save(img, "screenshot.bmp") print pa_compare(pa, first) img = pa.make_surface() time.sleep(0.05) screen.blit(img, (0, 0)); pygame.display.flip() # time.sleep(0.25) pygame.camera.quit()
height = len(arr[0]) if width * height < len(char_list): print('The image is not large enough') sys.exit() x = 0 y = 0 for char in char_list: str_pix = str(arr[x][y]) str_pix = str_pix[:-1] + char if int(str_pix) > 16777215: new = list(str_pix) new[-2] = '0' str_pix = ''.join(new) arr[x][y] = hex_to_rgb( '#' + hex(int(str_pix))[2:] ) # this messy conversion is used because pygame doesnt work well with integers or hex numbers if y < height - 1: y += 1 else: x += 1 y = 0 s = arr.make_surface() image.save(s, 'new.png')