Created
December 5, 2021 20:05
-
-
Save SeyedAbdollahi/c4c831b58d25a960a45f6157415cbc26 to your computer and use it in GitHub Desktop.
Example of negative of an image with Python and Pygame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
img = pygame.image.load('F:\input1.jpg') | |
W, H = img.get_width(), img.get_height() | |
for x in range(W): | |
for y in range(H): | |
color = pygame.Surface.get_at(img, (x,y)) | |
color = ~color | |
pygame.Surface.set_at(img, (x,y), color) | |
pygame.image.save(img, 'F:\output.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment