Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pygame how to change a pictures hue

blue_rgb = (0,0,255)
red_rgb = (255,0,0)
img = pygame.image.load("sky_picture.png") # loads the picture from the path given
var = pygame.PixelArray(img)
# var.replace(([Colour you want to replace]), [Colour you want])
var.replace((blue_rgb), (red_rgb)) # replaces all blue in the picture to red
del var 
# if the picture has some unchanged pixels left it's probably because they are not EXACTLY the rgb given for example (254,0,0) is not (255,0,0) and won't be changed (to fix this you will have to calculate the approx number ot just change the main picture)
Comment

PREVIOUS NEXT
Code Example
Python :: python roll a die 
Python :: how to send audio with inline telebot 
Python :: import file to colab 
Python :: csv from string python 
Python :: python discord discord.py disable remove help command 
Python :: remove scientific notation python matplotlib 
Python :: flash messages django 
Python :: linux uninstall python 
Python :: converting parquet to csv python 
Python :: input stdout python 
Python :: try datetime python 
Python :: get channel from id discord.py 
Python :: age calculator in python 
Python :: discard vs remove python 
Python :: how to take user input in a list in python 
Python :: calculator in one line in python 
Python :: 1 day ago python datetime 
Python :: python cv2 resize keep aspect ratio 
Python :: python max absolute value 
Python :: pandas dataframe hist title 
Python :: taking string input from user in python 
Python :: runner up score hackerrank 
Python :: Goal Perser 
Python :: choose random index from list python 
Python :: how to view the whole dataset in jupyternotebook 
Python :: how to add a column to a pandas df 
Python :: first openfaas python function 
Python :: google translate python 
Python :: python export console output to file 
Python :: number of rows or columns in numpy ndarray python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =