Loading images from memory

atob

28-03-2008 18:54:05

If I have the contents of an image (a DDS texture) in a python string, how do I load it into an Ogre image? I've tried passing an instance of a class subclassed from ogre.DataStream and StringIO, but I get the following error:

im.load(stream, 'dds')
TypeError: 'NoneType' object is not callable

bharling

29-03-2008 09:43:32

Well, I've never tried it with a DDS texture, but i think you will need to use the buffers method to write the pixel data to an ogre image. This wiki page might help you a bit, sadly though its not very fast.

http://wiki.python-ogre.org/index.php/CodeSnippits_Dynamic_Textures

you dont actually have to loop through the pixels if you have them in an array (of the same size and format as the buffer) you can do an array copy ie: buffer[:] = imgArray[:] which may be slightly faster