Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Improvements
- TypeId : Added `format_as` overload, so that TypeIds can be passed to `fmt::format()`.
- PrimitiveVariable : Added `format_as` overload for `Interpolation`, so that it can be passed to `fmt::format()`.

Fixes
-----

- ImageReader, TextureLoader : Removed special case for colorspaces when opening pngs.

Build
-----

Expand Down
24 changes: 4 additions & 20 deletions src/IECoreGL/TextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,14 @@ TexturePtr TextureLoader::load( const std::string &name, int maximumResolution )
}

// This logic feels pretty broken - why do we ask the current color config's
// display transform to decide what colorspace a file is stored in? Why special
// case just png. But I've currently copied this logic from ImageReader in the
// display transform to decide what colorspace a file is stored in?
// But I've currently copied this logic from ImageReader in the
// name of backwards compatibility
std::string linearColorSpace;
std::string currentColorSpace;
OIIO::string_view fileFormat = imageBuf.file_format_name();
if( fileFormat == "png" )
{
// The most common use for loading PNGs via Cortex is for icons in Gaffer.
// If we were to use the OCIO config to guess the colorspaces as below, we
// would get it spectacularly wrong. For instance, with an ACES config the
// resulting icons are so washed out as to be illegible. Instead, we hardcode
// the rudimentary colour spaces much more likely to be associated with a PNG.
// These are supported by OIIO regardless of what OCIO config is in use.
/// \todo Should this apply to other formats too? Can we somehow fix
/// `OpenImageIOAlgo::colorSpace` instead?
linearColorSpace = "linear";
currentColorSpace = "sRGB";
}
else
{
linearColorSpace = IECoreImage::OpenImageIOAlgo::colorSpace( "", imageBuf.spec() );
currentColorSpace = IECoreImage::OpenImageIOAlgo::colorSpace( fileFormat, imageBuf.spec() );
}
linearColorSpace = IECoreImage::OpenImageIOAlgo::colorSpace( "", imageBuf.spec() );
currentColorSpace = IECoreImage::OpenImageIOAlgo::colorSpace( fileFormat, imageBuf.spec() );

if( !OIIO::ImageBufAlgo::colorconvert( imageBuf, imageBuf, currentColorSpace, linearColorSpace ) )
{
Expand Down
20 changes: 2 additions & 18 deletions src/IECoreImage/ImageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,24 +479,8 @@ class ImageReader::Implementation
OIIO::TypeString, &fileFormat
);

if( strcmp( fileFormat, "png" ) == 0 )
{
// The most common use for loading PNGs via Cortex is for icons in Gaffer.
// If we were to use the OCIO config to guess the colorspaces as below, we
// would get it spectacularly wrong. For instance, with an ACES config the
// resulting icons are so washed out as to be illegible. Instead, we hardcode
// the rudimentary colour spaces much more likely to be associated with a PNG.
// These are supported by OIIO regardless of what OCIO config is in use.
/// \todo Should this apply to other formats too? Can we somehow fix
/// `OpenImageIOAlgo::colorSpace` instead?
m_linearColorSpace = "linear";
m_currentColorSpace = "sRGB";
}
else
{
m_linearColorSpace = OpenImageIOAlgo::colorSpace( "", *spec );
m_currentColorSpace = OpenImageIOAlgo::colorSpace( fileFormat, *spec );
}
m_linearColorSpace = OpenImageIOAlgo::colorSpace( "", *spec );
m_currentColorSpace = OpenImageIOAlgo::colorSpace( fileFormat, *spec );

return true;
}
Expand Down
Loading