[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: Out of memory loading very large image



On 29/09/2016 18:43, mspaintmaestro@xxxxxxxxx wrote:
From the programming side, what is the use case for an image that size? I'm imagining a background that pans with a sprite, which if it were me, I would personally slice the image into large chunks and lazy-load them on an as-needed basis. This would possibly lead to a better overall user experience as it doesn't consume lots of memory at once (assuming you clean up a cache) and generally doesn't cause noticeable pauses to load large images. But such a solution may or may not be doable depending on your use case.

Another hybrid option is slicing the image file and then aggregating it after it's been decoded. If the JPEG decoder of pygame.image.load() is to blame, loading individual tiles into pygame.Surfaces and then creating one giant Surface and blitting them all onto it may get around this constraint. 

But I would personally do the lazy-load approach.
That's the "Tell me what you need, and I'll tell you how to get along without it"... i like that joke. sorry.

hervé