Skip to content

Conversation

@johnhaddon
Copy link
Member

Using IECoreImage.ImageReader was leading to the Color space 'sRGB' could not be found error documented in #5695. This in turn was down to changes in OIIO that prevented it using an internal fallback sRGB->linear conversion when the OCIO config didn't contain one - see AcademySoftwareFoundation/OpenImageIO#4165.

Although AcademySoftwareFoundation/OpenImageIO#4166 fixes this for the config in #5695 by adding more synonyms for sRGB, it's not clear that it is a fix for all configs, because the fallback code path we relied on in the past is not active any more. And since we want to deprecate and remove IECoreImage.ImagePrimitive and IECoreImage.ImageReader in the long run anyway, it seems worth taking the opportunity to do some of that now.

@danieldresser-ie
Copy link
Contributor

I definitely like this direction. I agree that if we wanted to bring back constructing pointers from a memory buffer, OIIO::ImageBuf would probably be reasonable. I'm totally happy with keeping things simple with QtPixmap for icons instead of using OIIO there.

Code all looks good to me.

@danieldresser-ie
Copy link
Contributor

Oh, I am a bit confused though by the test failure on Windows - not sure how this PR is different from others that are passing to get a compile error on PlugAdder?

The TextureLoader came with several problems :

- It contained a hack to apply a simple sRGB->linear transform to all `.png` images, but that stopped working with OIIO 2.5 and certain custom OCIO configs. See GafferHQ#5695.
- It returned non-const textures, even though they were potentially shared between multiple clients who had loaded the same thing.

We now just do our own loading using an LRUCache and direct calls to OIIO.
We want to phase ImagePrimitive out over time, and this is a small step in that direction. This does leave us only being able to create ImagePrimitives from filenames, but that is the only constructor we've ever used anyway.

If we did want to construct from arbitrary in-memory data, I'm not sure what we'd choose. We wouldn't want to use `QPixmap` because the goal of GafferUI is to entirely hide Qt from the public API. So maybe `OIIO::ImageBuf`? That's for another day though since we don't need it at the moment.
This fixes GafferHQ#5695, by avoiding the colour conversions done by `IECoreImage::ImageReader` which were failing due to AcademySoftwareFoundation/OpenImageIO#4165. We want to phase `IECoreImage` out completely anyway, so this represents good progress in that direction.

Although `_qtPixmapFromImagePrimitive()` and the `Image( ImagePrimitive )` constructor are now completely unused in Gaffer itself, we can't remove them just yet because they are used in extension code at IE.

There's a reasonable case for using OpenImageIO here instead of Qt, to get access to a broader range of image formats and to match exactly the capabilities of ImageGadget. I tried implementing that but OpenImageIO isn't really usable from Python without `numpy`, and we don't ship with that module at present. It would be possible to implement an ImageBuf->QPixmap conversion in C++ and then bind that to Python if we consider this important. But practically speaking I think we only really care about common icon formats here, and Qt does fine with those, so I've gone with the simple option for now.
@johnhaddon johnhaddon merged commit a9466c1 into GafferHQ:main Mar 12, 2024
@johnhaddon johnhaddon deleted the srgbFiasco branch March 15, 2024 14:08
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

Successfully merging this pull request may close these issues.

2 participants