I'm complaining about `get_data()`, not `get_image_data()`. As I 
understand, `get_data()` is a method of the ImageData object returned by 
`get_image_data()`. The method `get_data()` returns a long string that 
contains the pixel value of each and every pixel. This string is huge, and 
doing this effectively turns my `dog.jpg` into a bitmap and stores it in 
RAM. This is as I understand how it works, which may or may not be wrong. I 
don't mind the program reading data in the image from hard disk, I just 
don't want the program to take up a lot of RAM. As far as I understand, the 
AbstractImage object returned by `pyglet.image.load()` and the ImageData 
object returned by the method `get_image_data()` don't take much memory, 
and are references to the original jpeg on my hard disk. I'm fine with 
that. What `get_data()` does is that it effectively turns the jpeg into a 
massive bitmap, and I don't want to store a massive bitmap in RAM every 
time I want to access the colour of just one pixel (and I do that a lot in 
my program). So I was thinking, this seems like using a sledge hammer to 
crack a nut, and there must be a way of accessing the colour of one pixel 
without first having to convert the whole image into a massive bitmap. Am I 
explaining myself clearly?

Dummey, your initial recommendation of using `get_region()` seems to work 
for me. Right now I'm using `get_region()` to get a sub-region containing 
just that pixel I want, and then I'm using `get_image_data().get_data()` to 
get the colour of that single pixel. As far as I can see, this method 
avoids converting the whole jpeg into a huge bitmap. At least according to 
`sys.getsizeof()`, this method doesn't create any huge objects.

Finally, what Filipe said earlier suggested to me that whatever I do, if I 
want to access the colour of one single pixel, Pyglet would have to first 
convert the whole image into a bitmap whatever happens. I was wondering if 
that's really what he's saying. I'm not at all an expert in image handling 
but it would seem strange to me if that were true.

Thank you all very much for your input by the way!

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to