Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find the width of a image pygame

width = surface.get_size()[0]
height = surface.get_size()[1]
Comment

get height of image in pygame

import pygame as pg
pg.init()

rect = pg.Rect(x,y,width = 100, height = 50)
# method 1, returns a tuple of width and height
>>> print(rect.get_size())
(100,50)
# method 2, returns a specific value
>>> print(rect.get_width())
100
>>> print(rect.get_height())
50
Comment

pygame image get height

width = surface.get_width()
height = surface.get_height()

#Example
import pygame

imageInput = pygame.image.load("test.png")

#Loop through every pixel in the image, and print the colour at that position
for y in range(imageInput.get_height()):
    for x in range(imageInput.get_width()):
        print (imageInput.get_at((x, y)))
Comment

PREVIOUS NEXT
Code Example
Python :: subprocess the system cannot find the file specifie 
Python :: python comment header 
Python :: add text to jpg python 
Python :: how to get wikipedia page link in python 
Python :: fonts in python 
Python :: unity python 
Python :: fillna pandas inplace 
Python :: python 3 docs 
Python :: User.objects.first() get specific id user in django 
Python :: How to plot Feature importance of any model in python 
Python :: pandas select only columns with na 
Python :: how to call a class from another class python? 
Python :: upload folder to s3 bucket python 
Python :: pytest snapshot update 
Python :: seaborn heatmap center xticks 
Python :: activate venv environment 
Python :: rotate existing labels python 
Python :: Power Crisis 
Python :: python emoji convert 
Python :: keras sequential layer without input shape 
Python :: check pd.NaT python 
Python :: query first 5 element in django 
Python :: input a number and print even numbers up to that number in python 
Python :: how to do formatting in python with format function 
Python :: Removing Elements from Python Dictionary Using del keyword 
Python :: how to loop function until true python 
Python :: mistborn order to read 
Python :: How to calculate accuracy with two lists in python 
Python :: smallest possible number in python 
Python :: how to create a function in python 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =