Kaydet (Commit) 61f9aa61 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible resource leaks by boost::scoped_array

Change-Id: If9b4a70895ae22ef40d9d1fa83ecbf9131c836af
üst 3e2cda22
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <impbmp.hxx> #include <impbmp.hxx>
#include <salbmp.hxx> #include <salbmp.hxx>
#include <boost/scoped_array.hpp>
Bitmap::Bitmap() : Bitmap::Bitmap() :
mpImpBmp( NULL ) mpImpBmp( NULL )
...@@ -584,19 +585,18 @@ bool Bitmap::Mirror( sal_uLong nMirrorFlags ) ...@@ -584,19 +585,18 @@ bool Bitmap::Mirror( sal_uLong nMirrorFlags )
if( pAcc ) if( pAcc )
{ {
const long nScanSize = pAcc->GetScanlineSize(); const long nScanSize = pAcc->GetScanlineSize();
sal_uInt8* pBuffer = new sal_uInt8[ nScanSize ]; boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[ nScanSize ]);
const long nHeight = pAcc->Height(); const long nHeight = pAcc->Height();
const long nHeight1 = nHeight - 1L; const long nHeight1 = nHeight - 1L;
const long nHeight_2 = nHeight >> 1L; const long nHeight_2 = nHeight >> 1L;
for( long nY = 0L, nOther = nHeight1; nY < nHeight_2; nY++, nOther-- ) for( long nY = 0L, nOther = nHeight1; nY < nHeight_2; nY++, nOther-- )
{ {
memcpy( pBuffer, pAcc->GetScanline( nY ), nScanSize ); memcpy( pBuffer.get(), pAcc->GetScanline( nY ), nScanSize );
memcpy( pAcc->GetScanline( nY ), pAcc->GetScanline( nOther ), nScanSize ); memcpy( pAcc->GetScanline( nY ), pAcc->GetScanline( nOther ), nScanSize );
memcpy( pAcc->GetScanline( nOther ), pBuffer, nScanSize ); memcpy( pAcc->GetScanline( nOther ), pBuffer.get(), nScanSize );
} }
delete[] pBuffer;
ReleaseAccess( pAcc ); ReleaseAccess( pAcc );
bRet = true; bRet = true;
} }
...@@ -726,10 +726,10 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) ...@@ -726,10 +726,10 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor )
long nRotY; long nRotY;
long nSinY; long nSinY;
long nCosY; long nCosY;
long* pCosX = new long[ nNewWidth ]; boost::scoped_array<long> pCosX(new long[ nNewWidth ]);
long* pSinX = new long[ nNewWidth ]; boost::scoped_array<long> pSinX(new long[ nNewWidth ]);
long* pCosY = new long[ nNewHeight ]; boost::scoped_array<long> pCosY(new long[ nNewHeight ]);
long* pSinY = new long[ nNewHeight ]; boost::scoped_array<long> pSinY(new long[ nNewHeight ]);
for ( nX = 0; nX < nNewWidth; nX++ ) for ( nX = 0; nX < nNewWidth; nX++ )
{ {
...@@ -764,11 +764,6 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) ...@@ -764,11 +764,6 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor )
} }
} }
delete[] pSinX;
delete[] pCosX;
delete[] pSinY;
delete[] pCosY;
aNewBmp.ReleaseAccess( pWriteAcc ); aNewBmp.ReleaseAccess( pWriteAcc );
} }
...@@ -925,7 +920,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, ...@@ -925,7 +920,7 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst,
if( pReadAcc->HasPalette() && pWriteAcc->HasPalette() ) if( pReadAcc->HasPalette() && pWriteAcc->HasPalette() )
{ {
const sal_uInt16 nCount = pReadAcc->GetPaletteEntryCount(); const sal_uInt16 nCount = pReadAcc->GetPaletteEntryCount();
sal_uInt8* pMap = new sal_uInt8[ nCount ]; boost::scoped_array<sal_uInt8> pMap(new sal_uInt8[ nCount ]);
// Create index map for the color table, as the bitmap should be copied // Create index map for the color table, as the bitmap should be copied
// retaining it's color information relatively well // retaining it's color information relatively well
...@@ -935,8 +930,6 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst, ...@@ -935,8 +930,6 @@ bool Bitmap::CopyPixel( const Rectangle& rRectDst,
for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ ) for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ )
for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ )
pWriteAcc->SetPixelIndex( nDstY, nDstX, pMap[ pReadAcc->GetPixelIndex( nSrcY, nSrcX ) ] ); pWriteAcc->SetPixelIndex( nDstY, nDstX, pMap[ pReadAcc->GetPixelIndex( nSrcY, nSrcX ) ] );
delete[] pMap;
} }
else if( pReadAcc->HasPalette() ) else if( pReadAcc->HasPalette() )
{ {
...@@ -1403,10 +1396,10 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) ...@@ -1403,10 +1396,10 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor )
} }
else else
{ {
bool* pFlags = new bool[ nMaxColors ]; boost::scoped_array<bool> pFlags(new bool[ nMaxColors ]);
// Set all entries to false // Set all entries to false
std::fill( pFlags, pFlags+nMaxColors, false ); std::fill( pFlags.get(), pFlags.get()+nMaxColors, false );
for( long nY = 0L; nY < nHeight; nY++ ) for( long nY = 0L; nY < nHeight; nY++ )
for( long nX = 0L; nX < nWidth; nX++ ) for( long nX = 0L; nX < nWidth; nX++ )
...@@ -1421,8 +1414,6 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) ...@@ -1421,8 +1414,6 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor )
aReplace = BitmapColor( (sal_uInt8) i ); aReplace = BitmapColor( (sal_uInt8) i );
} }
} }
delete[] pFlags;
} }
} }
} }
...@@ -1561,12 +1552,12 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, ...@@ -1561,12 +1552,12 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors,
if( pAcc ) if( pAcc )
{ {
long* pMinR = new long[ nColorCount ]; boost::scoped_array<long> pMinR(new long[ nColorCount ]);
long* pMaxR = new long[ nColorCount ]; boost::scoped_array<long> pMaxR(new long[ nColorCount ]);
long* pMinG = new long[ nColorCount ]; boost::scoped_array<long> pMinG(new long[ nColorCount ]);
long* pMaxG = new long[ nColorCount ]; boost::scoped_array<long> pMaxG(new long[ nColorCount ]);
long* pMinB = new long[ nColorCount ]; boost::scoped_array<long> pMinB(new long[ nColorCount ]);
long* pMaxB = new long[ nColorCount ]; boost::scoped_array<long> pMaxB(new long[ nColorCount ]);
long* pTols; long* pTols;
sal_uLong i; sal_uLong i;
...@@ -1612,7 +1603,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, ...@@ -1612,7 +1603,7 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors,
else else
{ {
BitmapColor aCol; BitmapColor aCol;
BitmapColor* pReplaces = new BitmapColor[ nColorCount ]; boost::scoped_array<BitmapColor> pReplaces(new BitmapColor[ nColorCount ]);
for( i = 0UL; i < nColorCount; i++ ) for( i = 0UL; i < nColorCount; i++ )
pReplaces[ i ] = pAcc->GetBestMatchingColor( pReplaceColors[ i ] ); pReplaces[ i ] = pAcc->GetBestMatchingColor( pReplaceColors[ i ] );
...@@ -1635,19 +1626,11 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors, ...@@ -1635,19 +1626,11 @@ bool Bitmap::Replace( const Color* pSearchColors, const Color* pReplaceColors,
} }
} }
} }
delete[] pReplaces;
} }
if( !_pTols ) if( !_pTols )
delete[] pTols; delete[] pTols;
delete[] pMinR;
delete[] pMaxR;
delete[] pMinG;
delete[] pMaxG;
delete[] pMinB;
delete[] pMaxB;
ReleaseAccess( pAcc ); ReleaseAccess( pAcc );
bRet = true; bRet = true;
} }
......
...@@ -680,9 +680,9 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor ) ...@@ -680,9 +680,9 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
InverseColorMap aColorMap( aPal = aOctree.GetPalette() ); InverseColorMap aColorMap( aPal = aOctree.GetPalette() );
BitmapColor aColor; BitmapColor aColor;
ImpErrorQuad aErrQuad; ImpErrorQuad aErrQuad;
ImpErrorQuad* pErrQuad1 = new ImpErrorQuad[ nWidth ]; boost::scoped_array<ImpErrorQuad> pErrQuad1(new ImpErrorQuad[ nWidth ]);
ImpErrorQuad* pErrQuad2 = new ImpErrorQuad[ nWidth ]; boost::scoped_array<ImpErrorQuad> pErrQuad2(new ImpErrorQuad[ nWidth ]);
ImpErrorQuad* pQLine1 = pErrQuad1; ImpErrorQuad* pQLine1 = pErrQuad1.get();
ImpErrorQuad* pQLine2 = 0; ImpErrorQuad* pQLine2 = 0;
long nX, nY; long nX, nY;
long nYTmp = 0L; long nYTmp = 0L;
...@@ -707,7 +707,7 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor ) ...@@ -707,7 +707,7 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
for( nY = 0L; nY < std::min( nHeight, 2L ); nY++, nYTmp++ ) for( nY = 0L; nY < std::min( nHeight, 2L ); nY++, nYTmp++ )
{ {
for( nX = 0L, pQLine2 = !nY ? pErrQuad1 : pErrQuad2; nX < nWidth; nX++ ) for( nX = 0L, pQLine2 = !nY ? pErrQuad1.get() : pErrQuad2.get(); nX < nWidth; nX++ )
{ {
if( pReadAcc->HasPalette() ) if( pReadAcc->HasPalette() )
pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nYTmp, nX ) ); pQLine2[ nX ] = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nYTmp, nX ) );
...@@ -742,7 +742,7 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor ) ...@@ -742,7 +742,7 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
// Refill/copy row buffer // Refill/copy row buffer
pQLine1 = pQLine2; pQLine1 = pQLine2;
pQLine2 = ( bQ1 = !bQ1 ) ? pErrQuad2 : pErrQuad1; pQLine2 = ( bQ1 = !bQ1 ) ? pErrQuad2.get() : pErrQuad1.get();
if( nYTmp < nHeight ) if( nYTmp < nHeight )
{ {
...@@ -756,10 +756,6 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor ) ...@@ -756,10 +756,6 @@ bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
} }
} }
// Delete row buffer
delete[] pErrQuad1;
delete[] pErrQuad2;
aNewBmp.ReleaseAccess( pWriteAcc ); aNewBmp.ReleaseAccess( pWriteAcc );
bRet = true; bRet = true;
} }
...@@ -1047,8 +1043,8 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) ...@@ -1047,8 +1043,8 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY )
const long nNewHeight1 = nNewHeight - 1L; const long nNewHeight1 = nNewHeight - 1L;
const long nWidth = pReadAcc->Width(); const long nWidth = pReadAcc->Width();
const long nHeight = pReadAcc->Height(); const long nHeight = pReadAcc->Height();
long* pLutX = new long[ nNewWidth ]; boost::scoped_array<long> pLutX(new long[ nNewWidth ]);
long* pLutY = new long[ nNewHeight ]; boost::scoped_array<long> pLutY(new long[ nNewHeight ]);
if( nNewWidth1 && nNewHeight1 ) if( nNewWidth1 && nNewHeight1 )
{ {
...@@ -1078,9 +1074,6 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY ) ...@@ -1078,9 +1074,6 @@ bool Bitmap::ImplScaleFast( const double& rScaleX, const double& rScaleY )
bRet = true; bRet = true;
aNewBmp.ReleaseAccess( pWriteAcc ); aNewBmp.ReleaseAccess( pWriteAcc );
} }
delete[] pLutX;
delete[] pLutY;
} }
ReleaseAccess( pReadAcc ); ReleaseAccess( pReadAcc );
...@@ -1106,8 +1099,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ...@@ -1106,8 +1099,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
long nHeight = pReadAcc->Height(); long nHeight = pReadAcc->Height();
Bitmap aNewBmp( Size( nNewWidth, nHeight ), 24 ); Bitmap aNewBmp( Size( nNewWidth, nHeight ), 24 );
BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess(); BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
long* pLutInt;
long* pLutFrac;
long nX, nY; long nX, nY;
long lXB0, lXB1, lXG0, lXG1, lXR0, lXR1; long lXB0, lXB1, lXG0, lXG1, lXR0, lXR1;
double fTemp; double fTemp;
...@@ -1119,8 +1110,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ...@@ -1119,8 +1110,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
const long nWidth1 = pReadAcc->Width() - 1L; const long nWidth1 = pReadAcc->Width() - 1L;
const double fRevScaleX = (double) nWidth1 / nNewWidth1; const double fRevScaleX = (double) nWidth1 / nNewWidth1;
pLutInt = new long[ nNewWidth ]; boost::scoped_array<long> pLutInt(new long[ nNewWidth ]);
pLutFrac = new long[ nNewWidth ]; boost::scoped_array<long> pLutFrac(new long[ nNewWidth ]);
for( nX = 0L, nTemp = nWidth - 2L; nX < nNewWidth; nX++ ) for( nX = 0L, nTemp = nWidth - 2L; nX < nNewWidth; nX++ )
{ {
...@@ -1182,8 +1173,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ...@@ -1182,8 +1173,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
} }
} }
delete[] pLutInt;
delete[] pLutFrac;
bRet = true; bRet = true;
} }
...@@ -1205,8 +1194,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ...@@ -1205,8 +1194,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
const long nHeight1 = pReadAcc->Height() - 1L; const long nHeight1 = pReadAcc->Height() - 1L;
const double fRevScaleY = (double) nHeight1 / nNewHeight1; const double fRevScaleY = (double) nHeight1 / nNewHeight1;
pLutInt = new long[ nNewHeight ]; boost::scoped_array<long> pLutInt(new long[ nNewHeight ]);
pLutFrac = new long[ nNewHeight ]; boost::scoped_array<long> pLutFrac(new long[ nNewHeight ]);
for( nY = 0L, nTemp = nHeight - 2L; nY < nNewHeight; nY++ ) for( nY = 0L, nTemp = nHeight - 2L; nY < nNewHeight; nY++ )
{ {
...@@ -1254,8 +1243,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ...@@ -1254,8 +1243,6 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
} }
} }
delete[] pLutInt;
delete[] pLutFrac;
bRet = true; bRet = true;
} }
...@@ -2551,10 +2538,10 @@ bool Bitmap::ImplDitherFloyd() ...@@ -2551,10 +2538,10 @@ bool Bitmap::ImplDitherFloyd()
long nW2 = nW - 3L; long nW2 = nW - 3L;
long nRErr, nGErr, nBErr; long nRErr, nGErr, nBErr;
long nRC, nGC, nBC; long nRC, nGC, nBC;
long* p1 = new long[ nW ]; boost::scoped_array<long> p1(new long[ nW ]);
long* p2 = new long[ nW ]; boost::scoped_array<long> p2(new long[ nW ]);
long* p1T = p1; long* p1T = p1.get();
long* p2T = p2; long* p2T = p2.get();
long* pTmp; long* pTmp;
bool bPal = pReadAcc->HasPalette(); bool bPal = pReadAcc->HasPalette();
...@@ -2644,8 +2631,6 @@ bool Bitmap::ImplDitherFloyd() ...@@ -2644,8 +2631,6 @@ bool Bitmap::ImplDitherFloyd()
pWriteAcc->SetPixelIndex( nYAcc, nWidth1, static_cast<sal_uInt8>(nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ]) ); pWriteAcc->SetPixelIndex( nYAcc, nWidth1, static_cast<sal_uInt8>(nVCLBLut[ nBC ] + nVCLGLut[nGC ] + nVCLRLut[nRC ]) );
} }
delete[] p1;
delete[] p2;
bRet = true; bRet = true;
} }
...@@ -2682,16 +2667,16 @@ bool Bitmap::ImplDitherFloyd16() ...@@ -2682,16 +2667,16 @@ bool Bitmap::ImplDitherFloyd16()
BitmapColor aColor; BitmapColor aColor;
BitmapColor aBestCol; BitmapColor aBestCol;
ImpErrorQuad aErrQuad; ImpErrorQuad aErrQuad;
ImpErrorQuad* pErrQuad1 = new ImpErrorQuad[ nWidth ]; boost::scoped_array<ImpErrorQuad> pErrQuad1(new ImpErrorQuad[ nWidth ]);
ImpErrorQuad* pErrQuad2 = new ImpErrorQuad[ nWidth ]; boost::scoped_array<ImpErrorQuad> pErrQuad2(new ImpErrorQuad[ nWidth ]);
ImpErrorQuad* pQLine1 = pErrQuad1; ImpErrorQuad* pQLine1 = pErrQuad1.get();
ImpErrorQuad* pQLine2 = 0; ImpErrorQuad* pQLine2 = 0;
long nX, nY; long nX, nY;
long nYTmp = 0L; long nYTmp = 0L;
bool bQ1 = true; bool bQ1 = true;
for( nY = 0L; nY < std::min( nHeight, 2L ); nY++, nYTmp++ ) for( nY = 0L; nY < std::min( nHeight, 2L ); nY++, nYTmp++ )
for( nX = 0L, pQLine2 = !nY ? pErrQuad1 : pErrQuad2; nX < nWidth; nX++ ) for( nX = 0L, pQLine2 = !nY ? pErrQuad1.get() : pErrQuad2.get(); nX < nWidth; nX++ )
pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX ); pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX );
for( nY = 0L; nY < nHeight; nY++, nYTmp++ ) for( nY = 0L; nY < nHeight; nY++, nYTmp++ )
...@@ -2726,16 +2711,13 @@ bool Bitmap::ImplDitherFloyd16() ...@@ -2726,16 +2711,13 @@ bool Bitmap::ImplDitherFloyd16()
// Refill/copy row buffer // Refill/copy row buffer
pQLine1 = pQLine2; pQLine1 = pQLine2;
pQLine2 = ( bQ1 = !bQ1 ) ? pErrQuad2 : pErrQuad1; pQLine2 = ( bQ1 = !bQ1 ) ? pErrQuad2.get() : pErrQuad1.get();
if( nYTmp < nHeight ) if( nYTmp < nHeight )
for( nX = 0L; nX < nWidth; nX++ ) for( nX = 0L; nX < nWidth; nX++ )
pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX ); pQLine2[ nX ] = pReadAcc->GetPixel( nYTmp, nX );
} }
// Destroy row buffer
delete[] pErrQuad1;
delete[] pErrQuad2;
bRet = true; bRet = true;
} }
...@@ -2884,10 +2866,10 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) ...@@ -2884,10 +2866,10 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
const sal_uInt32 nTotalColors = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent; const sal_uInt32 nTotalColors = nColorsPerComponent * nColorsPerComponent * nColorsPerComponent;
const long nWidth = pRAcc->Width(); const long nWidth = pRAcc->Width();
const long nHeight = pRAcc->Height(); const long nHeight = pRAcc->Height();
PopularColorCount* pCountTable = new PopularColorCount[ nTotalColors ]; boost::scoped_array<PopularColorCount> pCountTable(new PopularColorCount[ nTotalColors ]);
long nX, nY, nR, nG, nB, nIndex; long nX, nY, nR, nG, nB, nIndex;
memset( pCountTable, 0, nTotalColors * sizeof( PopularColorCount ) ); memset( pCountTable.get(), 0, nTotalColors * sizeof( PopularColorCount ) );
for( nR = 0, nIndex = 0; nR < 256; nR += nColorOffset ) for( nR = 0, nIndex = 0; nR < 256; nR += nColorOffset )
{ {
...@@ -2930,7 +2912,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) ...@@ -2930,7 +2912,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
BitmapPalette aNewPal( nColCount ); BitmapPalette aNewPal( nColCount );
qsort( pCountTable, nTotalColors, sizeof( PopularColorCount ), ImplPopularCmpFnc ); qsort( pCountTable.get(), nTotalColors, sizeof( PopularColorCount ), ImplPopularCmpFnc );
for( sal_uInt16 n = 0; n < nColCount; n++ ) for( sal_uInt16 n = 0; n < nColCount; n++ )
{ {
...@@ -2946,7 +2928,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) ...@@ -2946,7 +2928,7 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
if( pWAcc ) if( pWAcc )
{ {
BitmapColor aDstCol( (sal_uInt8) 0 ); BitmapColor aDstCol( (sal_uInt8) 0 );
sal_uInt8* pIndexMap = new sal_uInt8[ nTotalColors ]; boost::scoped_array<sal_uInt8> pIndexMap(new sal_uInt8[ nTotalColors ]);
for( nR = 0, nIndex = 0; nR < 256; nR += nColorOffset ) for( nR = 0, nIndex = 0; nR < 256; nR += nColorOffset )
for( nG = 0; nG < 256; nG += nColorOffset ) for( nG = 0; nG < 256; nG += nColorOffset )
...@@ -2982,12 +2964,11 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) ...@@ -2982,12 +2964,11 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
} }
} }
delete[] pIndexMap;
aNewBmp.ReleaseAccess( pWAcc ); aNewBmp.ReleaseAccess( pWAcc );
bRet = true; bRet = true;
} }
delete[] pCountTable; pCountTable.reset();
ReleaseAccess( pRAcc ); ReleaseAccess( pRAcc );
if( bRet ) if( bRet )
...@@ -3256,9 +3237,9 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, ...@@ -3256,9 +3237,9 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
BitmapColor aCol; BitmapColor aCol;
const long nW = pAcc->Width(); const long nW = pAcc->Width();
const long nH = pAcc->Height(); const long nH = pAcc->Height();
sal_uInt8* cMapR = new sal_uInt8[ 256 ]; boost::scoped_array<sal_uInt8> cMapR(new sal_uInt8[ 256 ]);
sal_uInt8* cMapG = new sal_uInt8[ 256 ]; boost::scoped_array<sal_uInt8> cMapG(new sal_uInt8[ 256 ]);
sal_uInt8* cMapB = new sal_uInt8[ 256 ]; boost::scoped_array<sal_uInt8> cMapB(new sal_uInt8[ 256 ]);
long nX, nY; long nX, nY;
double fM, fROff, fGOff, fBOff, fOff; double fM, fROff, fGOff, fBOff, fOff;
...@@ -3359,9 +3340,6 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, ...@@ -3359,9 +3340,6 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
} }
} }
delete[] cMapR;
delete[] cMapG;
delete[] cMapB;
ReleaseAccess( pAcc ); ReleaseAccess( pAcc );
bRet = true; bRet = true;
} }
......
Markdown is supported
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