Joslin.Chris Posted September 3, 2018 Share Posted September 3, 2018 Hi, I'm a bit confused on how to use the Image load(const Ptr<Stream> & stream) function. I want to load an image from a binary blob rather than a file on the system. As a simple test this is what i'm trying to do.. Unigine::ImagePtr _testImage; Unigine::BlobPtr _unigineBlob; _testImage = Unigine::Image::create("test_image.jpg"); _unigineBlob = Unigine::Blob::create(_testImage->getSize()); Unigine::Log::message("the image save was succesful %d\n",_testImage->save(_unigineBlob->getStream())); _testImage->load(_unigineBlob->getStream()); The output: the image save was succesful 1 ImageFileDDS::read_header(): wrong magic 0x0 Could you please point me in the right direction Kind regards, Chris Link to comment
andrey-kozlov Posted September 3, 2018 Share Posted September 3, 2018 Hello, Jostin Image is loading from current position of the stream. So once the blob is filled, its position should be reseted to the beginning. Also the image should be cleared before loading, or there will be a memory leak. Unigine::ImagePtr _testImage; Unigine::BlobPtr _unigineBlob; _testImage = Unigine::Image::create("core\\textures\\common\\white.dds"); _unigineBlob = Unigine::Blob::create(_testImage->getSize()); Unigine::Log::message("the image save was succesful %d\n", _testImage->save(_unigineBlob->getStream())); _unigineBlob->seekSet(0); _testImage->clear(); _testImage->load(_unigineBlob->getStream()); Link to comment
Recommended Posts