summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/bitmap3.cxx
diff options
context:
space:
mode:
authorMark Page <aptitude@btconnect.com>2016-12-05 09:59:25 +0000
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-12-05 19:23:06 +0000
commit7006568138b5b2d2c11dd558049cd4085c449c9e (patch)
tree7138ef172ffd1d7fa72cbfaac71225a9bbc29151 /vcl/source/gdi/bitmap3.cxx
parent8725c011de34206a91aa4d422a0b67a845cf2e1c (diff)
Change Read/Write access to Scoped Read/Write access
Change-Id: I2259af0d169f850ceb39f22424197912dfd20171 Reviewed-on: https://gerrit.libreoffice.org/31624 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/gdi/bitmap3.cxx')
-rw-r--r--vcl/source/gdi/bitmap3.cxx116
1 files changed, 56 insertions, 60 deletions
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index faaa65315e36..3fd517379d05 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -346,13 +346,13 @@ bool Bitmap::Convert( BmpConversion eConversion )
bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold )
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
bool bRet = false;
if( pReadAcc )
{
Bitmap aNewBmp( GetSizePixel(), 1 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
{
@@ -395,11 +395,11 @@ bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold )
}
}
- ReleaseAccess( pWriteAcc );
+ pWriteAcc.reset();
bRet = true;
}
- ReleaseAccess( pReadAcc );
+ pReadAcc.reset();
if( bRet )
{
@@ -418,13 +418,13 @@ bool Bitmap::ImplMakeMono( sal_uInt8 cThreshold )
bool Bitmap::ImplMakeMonoDither()
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
bool bRet = false;
if( pReadAcc )
{
Bitmap aNewBmp( GetSizePixel(), 1 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
{
@@ -470,11 +470,11 @@ bool Bitmap::ImplMakeMonoDither()
}
}
- ReleaseAccess( pWriteAcc );
+ pWriteAcc.reset();
bRet = true;
}
- ReleaseAccess( pReadAcc );
+ pReadAcc.reset();
if( bRet )
{
@@ -495,7 +495,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
{
SAL_WARN_IF( nGreys != 16 && nGreys != 256, "vcl", "Only 16 or 256 greyscales are supported!" );
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
bool bRet = false;
if( pReadAcc )
@@ -510,7 +510,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
if( bPalDiffers )
{
Bitmap aNewBmp( GetSizePixel(), ( nGreys == 16 ) ? 4 : 8, &rPal );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
{
@@ -576,11 +576,11 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
pWriteAcc->SetPixelIndex( nY, nX, (pReadAcc->GetPixel( nY, nX ) ).GetLuminance() >> nShift );
}
- ReleaseAccess( pWriteAcc );
+ pWriteAcc.reset();
bRet = true;
}
- ReleaseAccess( pReadAcc );
+ pReadAcc.reset();
if( bRet )
{
@@ -595,7 +595,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
}
else
{
- ReleaseAccess( pReadAcc );
+ pReadAcc.reset();
bRet = true;
}
}
@@ -810,7 +810,7 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color* pExtColor)
bool Bitmap::ImplConvertGhosted()
{
Bitmap aNewBmp;
- BitmapReadAccess* pR = AcquireReadAccess();
+ ScopedReadAccess pR(*this);
bool bRet = false;
if( pR )
@@ -828,12 +828,11 @@ bool Bitmap::ImplConvertGhosted()
}
aNewBmp = Bitmap( GetSizePixel(), GetBitCount(), &aNewPal );
- BitmapWriteAccess* pW = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pW(aNewBmp);
if( pW )
{
pW->CopyBuffer( *pR );
- ReleaseAccess( pW );
bRet = true;
}
}
@@ -841,7 +840,7 @@ bool Bitmap::ImplConvertGhosted()
{
aNewBmp = Bitmap( GetSizePixel(), 24 );
- BitmapWriteAccess* pW = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pW(aNewBmp);
if( pW )
{
@@ -859,12 +858,11 @@ bool Bitmap::ImplConvertGhosted()
}
}
- ReleaseAccess( pW );
bRet = true;
}
}
- ReleaseAccess( pR );
+ pR.reset();
}
if( bRet )
@@ -1082,12 +1080,12 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY )
if( nNewWidth && nNewHeight )
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
if(pReadAcc)
{
Bitmap aNewBmp( Size( nNewWidth, nNewHeight ), GetBitCount(), &pReadAcc->GetPalette() );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
{
@@ -1128,9 +1126,9 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY )
bRet = true;
}
- ReleaseAccess( pWriteAcc );
+ pWriteAcc.reset();
}
- ReleaseAccess( pReadAcc );
+ pReadAcc.reset();
if( bRet )
ImplAssignWithSize( aNewBmp );
@@ -1149,13 +1147,13 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
if( ( nNewWidth > 1 ) && ( nNewHeight > 1 ) )
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
if( pReadAcc )
{
long nWidth = pReadAcc->Width();
long nHeight = pReadAcc->Height();
Bitmap aNewBmp( Size( nNewWidth, nHeight ), 24 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
{
@@ -1232,8 +1230,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
bRet = true;
}
- ReleaseAccess( pReadAcc );
- ReleaseAccess( pWriteAcc );
+ pReadAcc.reset();
+ pWriteAcc.reset();
if( bRet )
{
@@ -1241,8 +1239,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
const Bitmap aOriginal(*this);
*this = aNewBmp;
aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 );
- pReadAcc = AcquireReadAccess();
- pWriteAcc = aNewBmp.AcquireWriteAccess();
+ pReadAcc = ScopedReadAccess(*this);
+ pWriteAcc = ScopedWriteAccess(aNewBmp);
if( pReadAcc && pWriteAcc )
{
@@ -1305,8 +1303,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
bRet = true;
}
- ReleaseAccess( pReadAcc );
- ReleaseAccess( pWriteAcc );
+ pReadAcc.reset();
+ pWriteAcc.reset();
if( bRet )
{
@@ -1345,9 +1343,9 @@ bool Bitmap::Dither( BmpDitherFlags nDitherFlags )
bool Bitmap::ImplDitherMatrix()
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
Bitmap aNewBmp( GetSizePixel(), 8 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
bool bRet = false;
if( pReadAcc && pWriteAcc )
@@ -1394,8 +1392,8 @@ bool Bitmap::ImplDitherMatrix()
bRet = true;
}
- ReleaseAccess( pReadAcc );
- ReleaseAccess( pWriteAcc );
+ pReadAcc.reset();
+ pWriteAcc.reset();
if( bRet )
{
@@ -1418,9 +1416,9 @@ bool Bitmap::ImplDitherFloyd()
if( ( aSize.Width() > 3 ) && ( aSize.Height() > 2 ) )
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
Bitmap aNewBmp( GetSizePixel(), 8 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
if( pReadAcc && pWriteAcc )
{
@@ -1529,8 +1527,8 @@ bool Bitmap::ImplDitherFloyd()
bRet = true;
}
- ReleaseAccess( pReadAcc );
- ReleaseAccess( pWriteAcc );
+ pReadAcc.reset();
+ pWriteAcc.reset();
if( bRet )
{
@@ -1549,9 +1547,9 @@ bool Bitmap::ImplDitherFloyd()
bool Bitmap::ImplDitherFloyd16()
{
- BitmapReadAccess* pReadAcc = AcquireReadAccess();
+ ScopedReadAccess pReadAcc(*this);
Bitmap aNewBmp( GetSizePixel(), 24 );
- BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBmp);
bool bRet = false;
if( pReadAcc && pWriteAcc )
@@ -1620,8 +1618,8 @@ bool Bitmap::ImplDitherFloyd16()
bRet = true;
}
- ReleaseAccess( pReadAcc );
- ReleaseAccess( pWriteAcc );
+ pReadAcc.reset();
+ pWriteAcc.reset();
if( bRet )
{
@@ -1661,7 +1659,7 @@ bool Bitmap::ReduceColors( sal_uInt16 nColorCount, BmpReduce eReduce )
bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount )
{
Bitmap aNewBmp;
- BitmapReadAccess* pRAcc = AcquireReadAccess();
+ ScopedReadAccess pRAcc(*this);
const sal_uInt16 nColCount = std::min( nColorCount, (sal_uInt16) 256 );
sal_uInt16 nBitCount;
bool bRet = false;
@@ -1677,10 +1675,9 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount )
{
Octree aOct( *pRAcc, nColCount );
const BitmapPalette& rPal = aOct.GetPalette();
- BitmapWriteAccess* pWAcc;
aNewBmp = Bitmap( GetSizePixel(), nBitCount, &rPal );
- pWAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWAcc(aNewBmp);
if( pWAcc )
{
@@ -1700,11 +1697,11 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount )
pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>(aOct.GetBestPaletteIndex( pRAcc->GetPixel( nY, nX ) )) );
}
- ReleaseAccess( pWAcc );
+ pWAcc.reset();
bRet = true;
}
- ReleaseAccess( pRAcc );
+ pRAcc.reset();
}
if( bRet )
@@ -1742,7 +1739,7 @@ extern "C" int SAL_CALL ImplPopularCmpFnc( const void* p1, const void* p2 )
bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
- BitmapReadAccess* pRAcc = AcquireReadAccess();
+ ScopedReadAccess pRAcc(*this);
sal_uInt16 nBitCount;
bool bRet = false;
@@ -1821,7 +1818,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
}
Bitmap aNewBmp( GetSizePixel(), nBitCount, &aNewPal );
- BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWAcc(aNewBmp);
if( pWAcc )
{
@@ -1862,12 +1859,12 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
}
}
- ReleaseAccess( pWAcc );
+ pWAcc.reset();
bRet = true;
}
pCountTable.reset();
- ReleaseAccess( pRAcc );
+ pRAcc.reset();
if( bRet )
{
@@ -1885,7 +1882,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
{
- BitmapReadAccess* pRAcc = AcquireReadAccess();
+ ScopedReadAccess pRAcc(*this);
sal_uInt16 nBitCount;
bool bRet = false;
@@ -1903,7 +1900,7 @@ bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
if( pRAcc )
{
Bitmap aNewBmp( GetSizePixel(), nBitCount );
- BitmapWriteAccess* pWAcc = aNewBmp.AcquireWriteAccess();
+ ScopedWriteAccess pWAcc(aNewBmp);
if( pWAcc )
{
@@ -1952,11 +1949,11 @@ bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
pWAcc->SetPixelIndex( nY, nX, static_cast<sal_uInt8>( aMap.GetBestPaletteIndex( pRAcc->GetColor( nY, nX ) )) );
rtl_freeMemory( pColBuf );
- ReleaseAccess( pWAcc );
+ pWAcc.reset();
bRet = true;
}
- ReleaseAccess( pRAcc );
+ pRAcc.reset();
if( bRet )
{
@@ -2131,7 +2128,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
}
else
{
- BitmapWriteAccess* pAcc = AcquireWriteAccess();
+ ScopedWriteAccess pAcc(*this);
if( pAcc )
{
@@ -2254,7 +2251,7 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
}
}
- ReleaseAccess( pAcc );
+ pAcc.reset();
bRet = true;
}
}
@@ -2267,7 +2264,7 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc,
if (!pReadAcc)
return false;
- BitmapWriteAccess* pWriteAcc = aNewBitmap.AcquireWriteAccess();
+ ScopedWriteAccess pWriteAcc(aNewBitmap);
if (!pWriteAcc)
return false;
@@ -2311,7 +2308,6 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess* pReadAcc,
pWriteAcc->SetPixel(nDestY, nDestX, aResultColor);
}
}
- ReleaseAccess( pWriteAcc );
return true;
}