#65 Callbacks support

open
nobody
None
5
2013-03-29
2010-12-07
No

Supplied here is:
- Callbacks implementation;
- Full implemetation of callbacks for FIF_TIFF, FIF_JPEG Loading and FreeImage_Rotate utility function.
- Helper class (wraps the callback struct) for easy adding callbacks to any loading or utility function inside FreeImage.

Discussion

  • Mihail Naydenov

    Mihail Naydenov - 2010-12-07

    Callbacks support + simple test

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-12-07

    Forgot to mention the Rotate function also has improved performance because the use of AssignPixel instead of memcpy and for loops.

    The gain is considerable mainly for big, higher depth images (up to 40%).

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-12-17

    Adds TARGA support, Save to JPEG, TIFF, modules enum

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-12-17

    Added modules enumeration. (In future it can, together with callbacks, be used for better error report)

    Added Load and Save callback to TGA, Save callback for JPEG and TIFF.
    (As it is evident form the code, it is extremely easy thing to do.)

    For now I put development on hold, until some feedback is given.

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-12-17

    A quick note:
    CallbackHelper::reportStepProgress()

    should check for _cb first, not after the % check, otherwise if _gran == 0 it will crash.

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-02

    Another quick note after using the patch for a while.

    The loading functions is probably better to return NULL instead of partially loaded dib. There is nothing wrong in current impl, and is a bit easier, but in the real world it is hard to track if the dib returned is a result of loading or cancellation.
    It is not impossible to workaround this, but, considering the dib will be discarded in 99.99% of the cases, it is better and simpler to just return null (we need to unload first of course).

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-02

    Add patch, implementing the last two comments issues.

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-02

    All previous + fixed issues from comments

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-07

    fix dib=NULL return; for rle cancel

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-07

    Added patch for PluginTARGA to fix a bug regarding return-null-on-cancel

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-01-13

    PluginTARGA : line: 857 are missing the brackets for CB.reportStepProgress.

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-04-27

    New version (selfcontained, incompatible with prev) - added message callback. JPEG, updated test, new threads test (Qt based)

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-05-27

    a stupid bug in PluginJPEG jpeg_output_message:

    cb->onMessage must also be checked for NULL, not only the cb object itself.

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-05-27

    aaand the same goes for the Plugin.cpp FreeImage_LoadCB* functions...

    Very sloppy on my part.

     
  • Mihail Naydenov

    Mihail Naydenov - 2011-08-08

    New complete version

     
  • Mihail Naydenov

    Mihail Naydenov - 2012-03-30

    Updated to 3.15.3, Complete version.

     
  • Mihail Naydenov

    Mihail Naydenov - 2012-03-30

    Updated to 3.15.3

    The path is more or less feature-complete, and I am not advancing it any further for now, but I will keep it updated.

     
  • Anonymous - 2013-02-02

    file: PluginTARGA.cpp line 1067:

    before "read in the bitmap bits" add:

        if(!CB.reportProgress(0.05)) {
                    FreeImage_Unload(dib);
                    return NULL;
                }
                else
                    CB.setupStepProgress(header.is_height, 0.99);
    

    to initialize the step progress, otherwise the app may crash on reportStepProgress!

    I will update the patch to current version soon.

     
  • Anonymous - 2013-03-29

    OK, after years of using this patch I hit a significant drawback.

    The fact that the dib can not be shared between workers if both need progress reports and/or cancellation. This is, you cant use one dib as a (read only) source of multiple operations.

    So, the only possible clean solution is to break the API and separate callbacks from the dib itself.

    This implementation is trivial to modify to workaround the said limitation - just dont store FreeImageCB object in the dib, but pass it every time into the functions.

    Drolon, any thoughts on the topic in general?

    Any specific wishes/concerns?
    Sooner or later we have to implement a solution and this one is very feature rich and also trivial to expand without breaking the API again (all callbacks and options to them are passed as one struct, which can be extended).

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks