My code allows a user to draw on a section of a pygame screen. I want to be able to extract all the RGB pixel values for this section of the screen and convert them to a 3d array, like this:
top_left = [50, 50]
bottom_right = [100, 100]
pixel_data = SomeFunctionToGetPixelData(screen, top_left, bottom_right)
# get RGB value for pixel that was at position (53, 51) on the screen
print(pixel_data[3][1])
> [255, 255, 255]
What's the best way to do this?