Skip to content

Commit

Permalink
ImageGadget : Convert ImageBuf to 8 bit before upload to OpenGL
Browse files Browse the repository at this point in the history
We need to conform it to the format that we're telling OpenGL we're providing. Although in theory the ImageBuf might convert automatically using the hint we passed to the constructor, in practice it doesn't seem to. So do a post conversion when necessary. This fixes corruption of 16 bit node icons in the GraphEditor.
  • Loading branch information
johnhaddon committed Jul 5, 2024
1 parent 699af45 commit f963611
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Fixes
- PrimitiveInspector : Fixed bug which claimed "Location does not exist" for objects without any primitive variables.
- OpenColorIO : Fixed the display transform used to show colours in popups.
- SceneInspector : Fixed "Show History" menu items.
- ImageGadget : Fixed loading of non-8-bit images. Among other things, this fixes the display of 16 bit node icons in the GraphEditor.

API
---
Expand Down
6 changes: 5 additions & 1 deletion src/GafferUI/ImageGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ using TextureCache = IECorePreview::LRUCache<TextureCacheKey, ConstTexturePtr>;

IECoreGL::ConstTexturePtr textureGetter( const TextureCacheKey &key, size_t &cost, const IECore::Canceller *canceller )
{
const OIIO::ImageSpec config( OIIO::TypeDesc::UCHAR );
const OIIO::ImageSpec config( OIIO::TypeDesc::UINT8 );
const std::string fileName = resolvedFileName( key.fileName );
OIIO::ImageBuf imageBuf( fileName, /* subimage = */ 0, /* miplevel = */ 0, /* imagecache = */ nullptr, &config );
imageBuf = OIIO::ImageBufAlgo::flip( imageBuf );
Expand All @@ -153,6 +153,10 @@ IECoreGL::ConstTexturePtr textureGetter( const TextureCacheKey &key, size_t &cos
);

imageBuf = OIIO::ImageBufAlgo::colorconvert( imageBuf, colorProcessor.get(), true );
if( imageBuf.spec().format != OIIO::TypeDesc::UINT8 )
{
imageBuf = imageBuf.copy( OIIO::TypeDesc::UINT8 );
}

GLint pixelFormat;
switch( imageBuf.nchannels() )
Expand Down

0 comments on commit f963611

Please sign in to comment.