Referencing a packed image file in python?


Sorry if this is an easy one but I couldn’t really find anything, how would I go about getting a packed image file in python?

image = bge.texture.ImageFFmpeg(???)

I don’t want to use a path to a file cause I will be packing all the textures anyway.

Well this is an API limitation so there isn’t much you can do about it. Though maybe there is a way with BGL but I’m not sure. Your best bet is to not pack external resources (you can publish a game without packing, packing is just an optional step for those that don’t use a proper working directory).

Welp. I was really hoping there is an actual way.

If you’re really hardcore about it you can always load any data packed in the .blend without BGE (Directy from Python). The guys from BF have already tought about it:

About using BGL I think that you may get the texture using glGetTexImage wich retiurns a bgl.Buffer that you can load from bge.texture.ImageBuff. But I wouldn’t rely on this method, I don’t have much experience with bgl so maybe it doesn’t even work, but even if it does you will probably only be able to load images that are being rendered.

Any reason you don’t want to distribute the textures with the blend?

No, particular reason just an old habit, but I won’t pack it this time.