mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Fix calculation of transparent region
This commit is contained in:
parent
02fc2b0858
commit
47222749f6
@ -809,21 +809,28 @@ QRect QgsImageOperation::nonTransparentImageRect( const QImage &image, QSize min
|
|||||||
// scan down till we hit something
|
// scan down till we hit something
|
||||||
for ( int y = 0; y < height; ++y )
|
for ( int y = 0; y < height; ++y )
|
||||||
{
|
{
|
||||||
|
bool found = false;
|
||||||
const QRgb* imgScanline = reinterpret_cast< const QRgb* >( image.constScanLine( y ) );
|
const QRgb* imgScanline = reinterpret_cast< const QRgb* >( image.constScanLine( y ) );
|
||||||
for ( int x = 0; x < width; ++x )
|
for ( int x = 0; x < width; ++x )
|
||||||
{
|
{
|
||||||
if ( qAlpha( imgScanline[x] ) )
|
if ( qAlpha( imgScanline[x] ) )
|
||||||
{
|
{
|
||||||
ymin = y;
|
ymin = y;
|
||||||
|
ymax = y;
|
||||||
xmin = x;
|
xmin = x;
|
||||||
xmax = x;
|
xmax = x;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( found )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//scan up till we hit something
|
//scan up till we hit something
|
||||||
for ( int y = height - 1; y > ymin; --y )
|
for ( int y = height - 1; y >= ymin; --y )
|
||||||
{
|
{
|
||||||
|
bool found = false;
|
||||||
const QRgb* imgScanline = reinterpret_cast< const QRgb* >( image.constScanLine( y ) );
|
const QRgb* imgScanline = reinterpret_cast< const QRgb* >( image.constScanLine( y ) );
|
||||||
for ( int x = 0; x < width; ++x )
|
for ( int x = 0; x < width; ++x )
|
||||||
{
|
{
|
||||||
@ -832,8 +839,12 @@ QRect QgsImageOperation::nonTransparentImageRect( const QImage &image, QSize min
|
|||||||
ymax = y;
|
ymax = y;
|
||||||
xmin = qMin( xmin, x );
|
xmin = qMin( xmin, x );
|
||||||
xmax = qMax( xmax, x );
|
xmax = qMax( xmax, x );
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( found )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//scan left to right till we hit something, using a refined y region
|
//scan left to right till we hit something, using a refined y region
|
||||||
|
Loading…
x
Reference in New Issue
Block a user