Commit 628fe64d authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Bug fix in the SelectionManagerImageTexels.

When recovering texels in a SelectionProcessor, their ordering was flipped vertically.
parent 2438c83b
......@@ -129,13 +129,13 @@ void SelectionManagerImageTexels::onUpdatingSelection( SelectionTool *tool )
fbo.Bind();
glBegin( GL_QUADS );
glTexCoord2i( 0, 1 );
glTexCoord2i( 0, 0 );
glVertex2i( t->x , t->y );
glTexCoord2i( 1, 1 );
glVertex2i( t->x+t->w, t->y );
glTexCoord2i( 1, 0 );
glVertex2i( t->x+t->w, t->y );
glTexCoord2i( 1, 1 );
glVertex2i( t->x+t->w, t->y+t->h );
glTexCoord2i( 0, 0 );
glTexCoord2i( 0, 1 );
glVertex2i( t->x , t->y+t->h );
glEnd();
glFlush();
......@@ -162,13 +162,13 @@ void SelectionManagerImageTexels::onDisplay( GLViewer *viewer,
{
t->tex.Bind( 0 );
glBegin( GL_QUADS );
glTexCoord2i( 0, 1 );
glTexCoord2i( 0, 0 );
glVertex2i( t->x , t->y );
glTexCoord2i( 1, 1 );
glVertex2i( t->x+t->w, t->y );
glTexCoord2i( 1, 0 );
glVertex2i( t->x+t->w, t->y );
glTexCoord2i( 1, 1 );
glVertex2i( t->x+t->w, t->y+t->h );
glTexCoord2i( 0, 0 );
glTexCoord2i( 0, 1 );
glVertex2i( t->x , t->y+t->h );
glEnd();
t->tex.Unbind();
......@@ -199,15 +199,21 @@ bool SelectionManagerImageTexels::getSelectionMask( std::vector<uint8_t> &mask )
{
t->tex.DumpTo( selectionBuffer, GL_RED, GL_UNSIGNED_BYTE );
for( int i=t->y+t->h-1, n=0; i>=t->y; --i )
for( int i=t->y, n=0; i<t->y+t->h; ++i )
{
int row = (m_ImageHeight-i-1)*m_ImageWidth;
for( int j=t->x; j<t->x+t->w; ++j, ++n )
mask[ i*m_ImageWidth + j ] = selectionBuffer[n];
mask[ row + j ] = selectionBuffer[n];
}
}
else
{
for( int i=t->y; i<t->y+t->h; ++i )
{
int row = (m_ImageHeight-i-1)*m_ImageWidth;
for( int j=t->x; j<t->x+t->w; ++j )
mask[ i*m_ImageWidth + j ] = 0;
mask[ row + j ] = 0;
}
}
delete[] selectionBuffer;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment