Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageTransform : Fix empty data window rotation bug #2932

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions python/GafferImageTest/ImageTransformTest.py
Expand Up @@ -298,5 +298,16 @@ def testNegativeScale( self ) :
self.assertEqual( sampler.sample( 0, 1 ), 1 )
self.assertEqual( sampler.sample( 1, 1 ), 0 )

def testRotateEmptyDataWindow( self ) :

r = GafferImage.ImageReader()
self.assertEqual( r["out"]["dataWindow"].getValue(), imath.Box2i() )

t = GafferImage.ImageTransform()
t["in"].setInput( r["out"] )
t["transform"]["rotate"].setValue( 1 )

self.assertEqual( t["out"]["dataWindow"].getValue(), imath.Box2i() )

if __name__ == "__main__":
unittest.main()
4 changes: 4 additions & 0 deletions src/GafferImage/ImageTransform.cpp
Expand Up @@ -262,6 +262,10 @@ Imath::Box2i ImageTransform::computeDataWindow( const Gaffer::Context *context,
else
{
const Box2i in = inPlug()->dataWindowPlug()->getValue();
if( BufferAlgo::empty( in ) )
{
return in;
}
return box2fToBox2i( transform( Box2f( V2f( in.min ), V2f( in.max ) ), matrix ) );
}
}
Expand Down