vsg-dev / vsgXchange

Utility library for converting data+materials to/from VulkanSceneGraph
MIT License
65 stars 40 forks source link

[ADDED] stbi write(ostream&) support #110

Closed siystar closed 2 years ago

siystar commented 2 years ago

For testing:

vsg::ref_ptr<vsg::Data> test_write_read (vsg::ref_ptr<vsg::Data> data)                                                      {                                                                 vsg::info("before=", data->dataSize());
    auto stbi = vsgXchange::stbi::create();
    auto options = vsg::Options::create();                        options->extensionHint = ".png";
    std::stringstream stream;                                     bool writeResult = stbi->write(data, stream, options);        vsg::info("writeResult=", writeResult);                       data = {};                                                    auto obj = stbi->read(stream, options);                       vsg::info("readResult=", obj.get());                          if (obj)                                                      {
        data = obj->cast<vsg::Data>();                                if (data)                                                         vsg::info("after=", data->dataSize());                }                                                             return data;
}
robertosfield commented 2 years ago

Thank for the changes and example and created a branch from this PR. I used the example code for testing and made a couple of refinements to the code to hopefully make it easier to follow. The changes were:

73dc67cb5282f7ec0eb69cf3cd491f09141157fb 40bc8955405c47de2a833a2d85108cc2f71de64e

I will now merge this work with master.