creating images and checking pixel in python
Author |
Message |
shaon
|
Posted: Mon Jan 07, 2008 7:34 pm Post subject: creating images and checking pixel in python |
|
|
In turing it's possible to create an image and save it in memory with Pic.new(x,y,x1,y1) <--- the program would hold whatever is in this rectangle and memory and you could use it like any other image. I was wondering if Python or Pygame has any built-in function like that lets users create images by holding parts of the screen in memory.
My 2nd question is what is the function in Pygame that lets users check the colour value of a pixel? Im sure most likely it has one. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Ultrahex
|
Posted: Mon Jan 07, 2008 7:51 pm Post subject: Re: creating images and checking pixel in python |
|
|
1st Question: Check Pygame Documentation, I think Images are Surfaces in Pygame? If i am incorrect .... well my bad...
2nd Question: If My Assumption is correct .... if the entire screen is a Surface then you use Surface.get_at((x, y)): return Color
Pygame Documentation For Surfaces: http://pygame.org/docs/ref/surface.html
Pygame Documentation For Images: http://pygame.org/docs/ref/surface.html |
|
|
|
|
![](images/spacer.gif) |
McKenzie
![](http://www.wizards.com/global/images/swtcg_article_27_pic3_en.gif)
|
Posted: Mon Jan 07, 2008 9:16 pm Post subject: Re: creating images and checking pixel in python |
|
|
I think hex is right that the answer is in the surface documentation. You can take a subsurface, but it will actually share pixels with the original (i.e. changes to one affect both). To stop it from sharing use copy(). Hex is right about get_at(). |
|
|
|
|
![](images/spacer.gif) |
|
|