Skip to content

Commit

Permalink
OpenImageIOReader Black mode returns default dataWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkaufman committed Nov 21, 2015
1 parent 823e82e commit d9215da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion python/GafferImageTest/ImageReaderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def assertMatch() :
with context :
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"].image )
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"]["format"].getValue )
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"]["dataWindow"].getValue )
self.assertEqual( reader["out"]["dataWindow"].getValue(), oiio["out"]["dataWindow"].getValue() )
self.assertEqual( reader["out"]["metadata"].getValue(), oiio["out"]["metadata"].getValue() )
self.assertEqual( reader["out"]["channelNames"].getValue(), oiio["out"]["channelNames"].getValue() )
self.assertEqual( reader["out"].channelData( "R", IECore.V2i( 0 ) ), oiio["out"].channelData( "R", IECore.V2i( 0 ) ) )
Expand Down
9 changes: 4 additions & 5 deletions python/GafferImageTest/OpenImageIOReaderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def testMissingFrameMode( self ) :
with context :
self.assertNotEqual( reader["out"].image(), f1Image )
self.assertEqual( reader["out"]["format"].getValue(), f1Format )
self.assertEqual( reader["out"]["dataWindow"].getValue(), f1DataWindow )
self.assertEqual( reader["out"]["dataWindow"].getValue(), reader["out"]["dataWindow"].defaultValue() )
self.assertEqual( reader["out"]["metadata"].getValue(), reader["out"]["metadata"].defaultValue() )
self.assertEqual( reader["out"]["channelNames"].getValue(), reader["out"]["channelNames"].defaultValue() )
self.assertEqual( reader["out"].channelData( "R", IECore.V2i( 0 ) ), blackTile )
Expand Down Expand Up @@ -412,9 +412,8 @@ def testMissingFrameMode( self ) :
reader["missingFrameMode"].setValue( GafferImage.OpenImageIOReader.MissingFrameMode.Black )
with context :
self.assertNotEqual( reader["out"]["format"].getValue(), f1Format )
self.assertNotEqual( reader["out"]["dataWindow"].getValue(), f1DataWindow )
self.assertEqual( reader["out"]["format"].getValue(), f3Format )
self.assertEqual( reader["out"]["dataWindow"].getValue(), f3DataWindow )
self.assertEqual( reader["out"]["dataWindow"].getValue(), reader["out"]["dataWindow"].defaultValue() )
self.assertEqual( reader["out"]["metadata"].getValue(), reader["out"]["metadata"].defaultValue() )
self.assertEqual( reader["out"]["channelNames"].getValue(), reader["out"]["channelNames"].defaultValue() )
self.assertEqual( reader["out"].channelData( "R", IECore.V2i( 0 ) ), blackTile )
Expand All @@ -435,7 +434,7 @@ def testMissingFrameMode( self ) :
reader["missingFrameMode"].setValue( GafferImage.OpenImageIOReader.MissingFrameMode.Black )
with context :
self.assertEqual( reader["out"]["format"].getValue(), f1Format )
self.assertEqual( reader["out"]["dataWindow"].getValue(), f1DataWindow )
self.assertEqual( reader["out"]["dataWindow"].getValue(), reader["out"]["dataWindow"].defaultValue() )
self.assertEqual( reader["out"]["metadata"].getValue(), reader["out"]["metadata"].defaultValue() )
self.assertEqual( reader["out"]["channelNames"].getValue(), reader["out"]["channelNames"].defaultValue() )
self.assertEqual( reader["out"].channelData( "R", IECore.V2i( 0 ) ), blackTile )
Expand All @@ -455,7 +454,7 @@ def testMissingFrameMode( self ) :
with context :
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"].image )
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"]["format"].getValue )
self.assertRaisesRegexp( RuntimeError, ".*incompleteSequence.*.exr.*", reader["out"]["dataWindow"].getValue )
self.assertEqual( reader["out"]["dataWindow"].getValue(), reader["out"]["dataWindow"].defaultValue() )
self.assertEqual( reader["out"]["metadata"].getValue(), reader["out"]["metadata"].defaultValue() )
self.assertEqual( reader["out"]["channelNames"].getValue(), reader["out"]["channelNames"].defaultValue() )
self.assertEqual( reader["out"].channelData( "R", IECore.V2i( 0 ) ), blackTile )
Expand Down
8 changes: 2 additions & 6 deletions src/GafferImage/OpenImageIOReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,10 @@ void OpenImageIOReader::hashDataWindow( const GafferImage::ImagePlug *output, co
Imath::Box2i OpenImageIOReader::computeDataWindow( const Gaffer::Context *context, const ImagePlug *parent ) const
{
std::string fileName = fileNamePlug()->getValue();
// when we're in MissingFrameMode::Black we still want to
// match the data window of the Hold frame.
MissingFrameMode mode = (MissingFrameMode)missingFrameModePlug()->getValue();
mode = ( mode == Black ) ? Hold : mode;
const ImageSpec *spec = imageSpec( fileName, mode, this, context );
const ImageSpec *spec = imageSpec( fileName, (MissingFrameMode)missingFrameModePlug()->getValue(), this, context );
if( !spec )
{
return Box2i();
return parent->dataWindowPlug()->defaultValue();
}

Format format( Imath::Box2i( Imath::V2i( spec->full_x, spec->full_y ), Imath::V2i( spec->full_width + spec->full_x, spec->full_height + spec->full_y ) ) );
Expand Down

0 comments on commit d9215da

Please sign in to comment.