https://github.com/OpenImageIO/oiio/pull/265 

I posted about this pull request already, and there has been much discussion on 
the pull request comments.  But before I commit, I want to make sure people 
have seen it in the final form and there are no objections (because this 
changes a public API in an important way).

The change basically boils down to this:

1. When reading an image with ImageInput, recall the old practice of 

        ImageInput *in = ImageInput::create (filename);
        ImageSpec spec;
        in->open (filename, spec);

Now we compress this into a single step:

        ImageInput *in = ImageInput::open (filename);

(you may retrieve the spec using the in->spec(), as you always could before as 
well).

This is helpful in two ways.  First, it makes the code for reading a file a bit 
simpler, and shortens the confusing create-and-open sequence.  Second, it is 
more efficient, because create() itself must open the file (or how can it know 
what format it's in and verify that it's ok), then close it, then re-open it 
again during the call to open().  Silly.  So the new way knows it's supposed to 
return the opened file, so it only has to open it once.

The old create and open methods also exist, so the change does not break source 
compatibility with existing apps (though they will need a recompile).

2. A new method has been added to ImageInput, which is expected to be 
implemented by most format reader plugins:

        bool valid_file (const std::string &filename) const;

It's not really intended that this be called from client programs, but by 
implementing this method, various internals can figure out whether the file is 
of the given format more efficiently than calling a full open(), which may 
needlessly read full headers and whatnot, in cases where it just needs to read 
enough to verify magic numbers.  It's optional; a plugin that doesn't supply it 
will inherit an implementation that calls open/close to determine if it's of 
the right type.

I'll let this sit just a bit, and if nobody objects strenuously within a couple 
days, I will squash it down to a single commit and merge into the master (1.1) 
branch.

--
Larry Gritz
[email protected]


_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to