Skip to content

Commit

Permalink
Image : Prefer Qt's image reading to IECoreImage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johnhaddon committed Mar 8, 2024
1 parent ca16dc6 commit e094c16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Fixes
- Fixed hangs and crashes when using non-default session modes such as SVM shading.
- Fixed failure to render background light in batch renders (#5234).
- Fixed failure to update when reverting a background shader to previous values.
- GafferUI :
- Fixed `Color space 'sRGB' could not be found` errors when running with certain custom OCIO configs (#5695).
- Fixed icon colours when running with an ACES OCIO config.

Breaking Changes
----------------
Expand Down
9 changes: 1 addition & 8 deletions python/GafferUI/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,7 @@ def __cacheGetter( cls, fileName ) :
if not resolvedFileName :
raise Exception( "Unable to find file \"%s\"" % fileName )

reader = IECore.Reader.create( resolvedFileName )

image = reader.read()
if not isinstance( image, IECoreImage.ImagePrimitive ) :
raise Exception( "File \"%s\" is not an image file" % resolvedFileName )

result = cls._qtPixmapFromImagePrimitive( image )

result = QtGui.QPixmap( resolvedFileName )
cost = result.width() * result.height() * ( 4 if result.hasAlpha() else 3 )

return ( result, cost )

0 comments on commit e094c16

Please sign in to comment.