Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching part types in a MultiPartInputFile #1845

Open
fnordware opened this issue Sep 24, 2024 · 2 comments
Open

Switching part types in a MultiPartInputFile #1845

fnordware opened this issue Sep 24, 2024 · 2 comments

Comments

@fnordware
Copy link
Contributor

I don't know if this is really an issue, but I notice you can no longer switch from one part type to another when using MultiPartInputFile. So you get an exception doing something like this:

Imf::MultiPartInputFile multi(file);
Imf::TiledInputPart tiled(multi, 0);
Imf::InputPart scanline(multi, 0);

I had been using TiledInputPart to get some information about the tiles, even though I was using InputPart to read the pixels. Maybe I should just stop doing that.

@peterhillman
Copy link
Contributor

Try calling multi.flushPartCache() between the two calls. I'm curious what information you were getting from TIledInputPart. Ideally, it should be just as easy to get that from multi.header(0) without needing to use any Part classes, or from the header of your scanline part instead.

I was unaware that code ever worked properly. *Part types ar smart pointers to an underlying cache of part objects, and there's only one permitted for each part. flushPartCache() deletes all part pointers, so you can recreate them as different types. All Part objects you have will be invalidated by that call.

@fnordware
Copy link
Contributor Author

Ahhh, there it is. Yeah, it used to work, granted I was stuck on an old version for quite a while. I was just getting the standard tile dimensions, so no need to spin up a TiledInputPart just for that.

But now I realize that there's still a possibility I might need to switch. If I have a compatible FrameBuffer I find TiledInputPart::readTiles() to be much faster than InputPart::readPixels(), but then if a later call just has a piece of the buffer I'll have to switch back. Good to know about MultiPartInputFile::flushPartCache().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants