Giter Site home page Giter Site logo

Comments (3)

mosra avatar mosra commented on May 22, 2024

Hi,

sorry, should have told you about this limitation sooner -- I completely forgot that this would hit you very early in the process of creating the converter plugin. It's on my TODO list (and currently also part of mosra/magnum#108). Yes, you are basically on the right path, there's unfortunately some missing parts that I need to put into the plugin manager in order for it to work. The workflow should be then like this (in case of the stb_image_write plugin):

  1. There's just one plugin binary, named StbImageConverter, and it has aliases like StbPngImageConverter, StbTgaImageConverter etc.
    • For the general "any converter" case it would of course also provide aliases like PngImageConverter etc. The StbPngImageConverter alias is there in case you want to explicitly use this plugin without any other aliases mixing in (more on that in my reply to #25).
  2. The StbImageConverter class has a constructor that takes either a std::string (in case the plugin is loaded through plugin manager) or some enum that specifies which format the plugin should convert to (in case the plugin is linked in the executable and instantiated directly).
  3. The enum constructor is obvious, the std::string constructor gets a name under which the plugin was instantiated via PluginManager::Manager::instance() / PluginManager::Manager::loadAndInstantiate(). So in case it was instantiated as StbPngImageConverter or PngImageConverter, it would provide conversion to PNG.
  4. In order to output to a different type than PNG, you would load another instance with another alias name.

I think this design is pretty usable, though it has a limitation that you need to have different plugin instances in order to output to different file types. But on the other hand this could be exploited to squeeze some additional performance out (for example precalculating some compressor state in the constructor and then reusing it for the whole plugin lifetime instead of recreating it from scratch in every doConvert*() implementation). So I would keep it this way.

What needs to be done in the plugin manager is:

  • The std::string passed to the constructor is currently the real name of the plugin, not the alias. It should be the alias in order to make this feature work, but I have to check that this doesn't clash with any other use case.
  • It should be also possible to create every instance with a different alias passed to the constructor. Also not sure, maybe there is something that prevents this.
  • For convenience the alias name should be available through some function. The plugin manager code dates back to 2007 and I have a blurry memory that there once was such function, but then I removed it because (as you discovered) it was also available through the metadata and thus seemed redundant. Now it wouldn't be redundant anymore.

Another thing is -- the user might want to specify some options to the converters (such as compression quality). I have an idea how that could be done in a general way, I'll open another issue for that in the corrade repo.

Will keep you updated on the progress (though as I said in other place, I don't have much time right now).

from magnum-plugins.

mosra avatar mosra commented on May 22, 2024

Okay. Done! Sorry it took so long.

The required change in the PluginManager library is done in mosra/corrade@834ea41 and the StbImageImporter plugin was reworked to handle also other formats in 332ba6c, you can look there to see how I tried to handle the format distinction. Nothing (except time, hah) should prevent creating the DevIL image converter now :)

from magnum-plugins.

 avatar commented on May 22, 2024

@mosra I'll probably get to it in due time, maybe closer to Valentines day or something. Thanks a lot!

from magnum-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.