This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0399a9fdaf Fixed typos, removed whitespace
0399a9fdaf is described below
commit 0399a9fdaf9a50397f1c64f11d2eab3459cab875
Author: mseidel <[email protected]>
AuthorDate: Sun Aug 13 16:55:38 2023 +0200
Fixed typos, removed whitespace
---
main/vcl/source/gdi/bitmap.cxx | 228 +++---
main/vcl/source/gdi/bitmap3.cxx | 1522 +++++++++++++++++++-------------------
main/vcl/source/gdi/bitmap4.cxx | 95 ++-
main/vcl/source/gdi/bitmapex.cxx | 1235 ++++++++++++++++---------------
4 files changed, 1542 insertions(+), 1538 deletions(-)
diff --git a/main/vcl/source/gdi/bitmap.cxx b/main/vcl/source/gdi/bitmap.cxx
index 4325b513b1..7f529d053d 100644
--- a/main/vcl/source/gdi/bitmap.cxx
+++ b/main/vcl/source/gdi/bitmap.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -55,9 +55,9 @@ Bitmap::Bitmap( const ResId& rResId ) :
mpImpBmp( NULL )
{
const BitmapEx aBmpEx( rResId );
-
+
if( !aBmpEx.IsEmpty() )
- *this = aBmpEx.GetBitmap();
+ *this = aBmpEx.GetBitmap();
}
// ------------------------------------------------------------------
@@ -76,10 +76,10 @@ Bitmap::Bitmap( const Bitmap& rBitmap ) :
Bitmap::Bitmap( SalBitmap* pSalBitmap )
{
- mpImpBmp = new ImpBitmap();
- mpImpBmp->ImplSetSalBitmap( pSalBitmap );
- maPrefMapMode = MapMode( MAP_PIXEL );
- maPrefSize = mpImpBmp->ImplGetSize();
+ mpImpBmp = new ImpBitmap();
+ mpImpBmp->ImplSetSalBitmap( pSalBitmap );
+ maPrefMapMode = MapMode( MAP_PIXEL );
+ maPrefSize = mpImpBmp->ImplGetSize();
}
// ------------------------------------------------------------------
@@ -236,10 +236,10 @@ bool BitmapPalette::IsGreyPalette() const
// see above: only certain entry values will result in a valid call to
GetGreyPalette
if( nEntryCount == 2 || nEntryCount == 4 || nEntryCount == 16 ||
nEntryCount == 256 )
{
- const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette(
nEntryCount );
- if( rGreyPalette == *this )
- return true;
- }
+ const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette(
nEntryCount );
+ if( rGreyPalette == *this )
+ return true;
+ }
// TODO: is it worth to compare the entries?
return false;
}
@@ -291,10 +291,10 @@ Size Bitmap::GetSizePixel() const
void Bitmap::SetSizePixel( const Size& rNewSize, sal_uInt32 nScaleFlag )
{
- if(GetSizePixel() != rNewSize)
- {
- Scale( rNewSize, nScaleFlag );
- }
+ if(GetSizePixel() != rNewSize)
+ {
+ Scale( rNewSize, nScaleFlag );
+ }
}
// ------------------------------------------------------------------
@@ -332,17 +332,17 @@ sal_Bool Bitmap::HasGreyPalette() const
if( pRAcc )
{
- const BitmapColor& rCol0( pRAcc->GetPaletteColor( 0 ) );
- const BitmapColor& rCol1( pRAcc->GetPaletteColor( 1 ) );
- if( rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() ==
rCol0.GetBlue() &&
- rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() ==
rCol1.GetBlue() )
- {
- bRet = sal_True;
- }
+ const BitmapColor& rCol0( pRAcc->GetPaletteColor( 0 ) );
+ const BitmapColor& rCol1( pRAcc->GetPaletteColor( 1 ) );
+ if( rCol0.GetRed() == rCol0.GetGreen() &&
rCol0.GetRed() == rCol0.GetBlue() &&
+ rCol1.GetRed() == rCol1.GetGreen() &&
rCol1.GetRed() == rCol1.GetBlue() )
+ {
+ bRet = sal_True;
+ }
( (Bitmap*) this )->ReleaseAccess( pRAcc );
}
else
- bRet = sal_True;
+ bRet = sal_True;
}
else if( 4 == nBitCount || 8 == nBitCount )
{
@@ -352,7 +352,7 @@ sal_Bool Bitmap::HasGreyPalette() const
{
if( pRAcc->HasPalette() && ( (BitmapPalette&)
pRAcc->GetPalette() == GetGreyPalette( 1 << nBitCount ) ) )
bRet = sal_True;
-
+
( (Bitmap*) this )->ReleaseAccess( pRAcc );
}
}
@@ -398,7 +398,7 @@ sal_uLong Bitmap::GetChecksum() const
UInt32ToSVBT32(
pRAcc->GetColorMask().GetBlueMask(), aBT32 );
nCrc = rtl_crc32( nCrc, aBT32, 4 );
-
+
if( pRAcc->HasPalette() )
{
nCrc = rtl_crc32( nCrc,
pRAcc->GetPalette().ImplGetColorBuffer(),
@@ -406,7 +406,7 @@ sal_uLong Bitmap::GetChecksum() const
}
nCrc = rtl_crc32( nCrc, pRAcc->GetBuffer(),
pRAcc->GetScanlineSize() * pRAcc->Height() );
-
+
mpImpBmp->ImplSetChecksum( nRet = nCrc );
}
@@ -532,7 +532,7 @@ sal_Bool Bitmap::Erase( const Color& rFillColor )
{
if( !(*this) )
return sal_True;
-
+
BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
sal_Bool bRet = sal_False;
@@ -1394,17 +1394,17 @@ Region Bitmap::CreateRegion( const Color& rColor, const
Rectangle& rRect ) const
const long nBottom = aRect.Bottom();
const BitmapColor aMatch( pReadAcc->GetBestMatchingColor(
rColor ) );
- //RectangleVector aRectangles;
+ //RectangleVector aRectangles;
//aRegion.ImplBeginAddRect();
- std::vector< long > aLine;
- long nYStart(nTop);
- long nY(nTop);
+ std::vector< long > aLine;
+ long nYStart(nTop);
+ long nY(nTop);
for( ; nY <= nBottom; nY++ )
{
//aSubRect.Top() = aSubRect.Bottom() = nY;
- std::vector< long > aNewLine;
- long nX(nLeft);
+ std::vector< long > aNewLine;
+ long nX(nLeft);
for( ; nX <= nRight; )
{
@@ -1413,65 +1413,65 @@ Region Bitmap::CreateRegion( const Color& rColor, const
Rectangle& rRect ) const
if( nX <= nRight )
{
- aNewLine.push_back(nX);
+ aNewLine.push_back(nX);
//aSubRect.Left() = nX;
while( ( nX <= nRight ) && ( aMatch ==
pReadAcc->GetPixel( nY, nX ) ) )
nX++;
//aSubRect.Right() = nX - 1L;
- aNewLine.push_back(nX - 1);
+ aNewLine.push_back(nX - 1);
//aRegion.ImplAddRect( aSubRect );
- //aRectangles.push_back(aSubRect);
- //aRegion.Union(aSubRect);
+ //aRectangles.push_back(aSubRect);
+ //aRegion.Union(aSubRect);
}
}
- if(aNewLine != aLine)
- {
- // need to write aLine, it's different from the next line
- if(aLine.size())
- {
- Rectangle aSubRect;
-
- // enter y values and proceed ystart
- aSubRect.Top() = nYStart;
- aSubRect.Bottom() = nY ? nY - 1 : 0;
-
- for(sal_uInt32 a(0); a < aLine.size();)
- {
- aSubRect.Left() = aLine[a++];
- aSubRect.Right() = aLine[a++];
- aRegion.Union(aSubRect);
- }
- }
-
- // copy line as new line
- aLine = aNewLine;
- nYStart = nY;
- }
+ if(aNewLine != aLine)
+ {
+ // need to write aLine, it's different from the
next line
+ if(aLine.size())
+ {
+ Rectangle aSubRect;
+
+ // enter y values and proceed ystart
+ aSubRect.Top() = nYStart;
+ aSubRect.Bottom() = nY ? nY - 1 : 0;
+
+ for(sal_uInt32 a(0); a < aLine.size();)
+ {
+ aSubRect.Left() = aLine[a++];
+ aSubRect.Right() = aLine[a++];
+ aRegion.Union(aSubRect);
+ }
+ }
+
+ // copy line as new line
+ aLine = aNewLine;
+ nYStart = nY;
+ }
}
- // write last line if used
- if(aLine.size())
- {
- Rectangle aSubRect;
+ // write last line if used
+ if(aLine.size())
+ {
+ Rectangle aSubRect;
- // enter y values
- aSubRect.Top() = nYStart;
- aSubRect.Bottom() = nY ? nY - 1 : 0;
+ // enter y values
+ aSubRect.Top() = nYStart;
+ aSubRect.Bottom() = nY ? nY - 1 : 0;
- for(sal_uInt32 a(0); a < aLine.size();)
- {
- aSubRect.Left() = aLine[a++];
- aSubRect.Right() = aLine[a++];
- aRegion.Union(aSubRect);
- }
- }
+ for(sal_uInt32 a(0); a < aLine.size();)
+ {
+ aSubRect.Left() = aLine[a++];
+ aSubRect.Right() = aLine[a++];
+ aRegion.Union(aSubRect);
+ }
+ }
//aRegion.ImplEndAddRect();
- //aRegion.SetRegionRectangles(aRectangles);
+ //aRegion.SetRegionRectangles(aRectangles);
( (Bitmap*) this )->ReleaseAccess( pReadAcc );
}
@@ -1504,7 +1504,7 @@ sal_Bool Bitmap::Replace( const Bitmap& rMask, const
Color& rReplaceColor )
// default to the nearest color
aReplace = pAcc->GetBestMatchingColor( rReplaceColor );
- // for paletted images without a matching palette entry
+ // for paletted images without a matching palette entry
// look for an unused palette entry (NOTE: expensive!)
if( pAcc->GetPaletteColor( aReplace.GetIndex() ) !=
BitmapColor( rReplaceColor ) )
{
@@ -1548,7 +1548,7 @@ sal_Bool Bitmap::Replace( const Bitmap& rMask, const
Color& rReplaceColor )
if( pMaskAcc->GetPixel( nY, nX ) == aMaskWhite )
pAcc->SetPixel( nY, nX, aReplace );
- bRet = sal_True;
+ bRet = sal_True;
}
( (Bitmap&) rMask ).ReleaseAccess( pMaskAcc );
@@ -1798,23 +1798,23 @@ Bitmap Bitmap::CreateDisplayBitmap( OutputDevice*
pDisplay )
Bitmap Bitmap::GetColorTransformedBitmap( BmpColorMode eColorMode ) const
{
- Bitmap aRet;
-
+ Bitmap aRet;
+
if( BMP_COLOR_HIGHCONTRAST == eColorMode )
{
- Color* pSrcColors = NULL;
- Color* pDstColors = NULL;
- sal_uLong nColorCount = 0;
-
+ Color* pSrcColors = NULL;
+ Color* pDstColors = NULL;
+ sal_uLong nColorCount = 0;
+
aRet = *this;
- Image::GetColorTransformArrays( (ImageColorTransform) eColorMode,
pSrcColors, pDstColors, nColorCount );
+ Image::GetColorTransformArrays( (ImageColorTransform)
eColorMode, pSrcColors, pDstColors, nColorCount );
- if( nColorCount && pSrcColors && pDstColors )
- aRet.Replace( pSrcColors, pDstColors, nColorCount );
+ if( nColorCount && pSrcColors && pDstColors )
+ aRet.Replace( pSrcColors, pDstColors, nColorCount );
- delete[] pSrcColors;
- delete[] pDstColors;
+ delete[] pSrcColors;
+ delete[] pDstColors;
}
else if( BMP_COLOR_MONOCHROME_BLACK == eColorMode ||
BMP_COLOR_MONOCHROME_WHITE == eColorMode )
@@ -1822,8 +1822,8 @@ Bitmap Bitmap::GetColorTransformedBitmap( BmpColorMode
eColorMode ) const
aRet = *this;
aRet.MakeMono( BMP_COLOR_MONOCHROME_THRESHOLD );
}
-
- return aRet;
+
+ return aRet;
}
// ------------------------------------------------------------------
@@ -1956,7 +1956,7 @@ sal_Bool Bitmap::CombineSimple( const Bitmap& rMask,
BmpCombine eCombine )
break;
}
- bRet = sal_True;
+ bRet = sal_True;
}
( (Bitmap&) rMask ).ReleaseAccess( pMaskAcc );
@@ -1969,13 +1969,13 @@ sal_Bool Bitmap::CombineSimple( const Bitmap& rMask,
BmpCombine eCombine )
sal_Bool Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor
)
{
- // TODO: Have a look at OutputDevice::ImplDrawAlpha() for some
- // optimizations. Might even consolidate the code here and there.
+ // TODO: Have a look at OutputDevice::ImplDrawAlpha() for some
+ // optimizations. Might even consolidate the code here and there.
- // convert to a truecolor bitmap, if we're a paletted one. There's
- // room for tradeoff decision here, maybe later for an overload (or a flag)
- if( GetBitCount() <= 8 )
- Convert( BMP_CONVERSION_24BIT );
+ // convert to a truecolor bitmap, if we're a paletted one. There's
+ // room for tradeoff decision here, maybe later for an overload (or a
flag)
+ if( GetBitCount() <= 8 )
+ Convert( BMP_CONVERSION_24BIT );
BitmapReadAccess* pAlphaAcc =
const_cast<AlphaMask&>(rAlpha).AcquireReadAccess();
BitmapWriteAccess* pAcc = AcquireWriteAccess();
@@ -1988,11 +1988,11 @@ sal_Bool Bitmap::Blend( const AlphaMask& rAlpha, const
Color& rBackgroundColor )
for( long nY = 0L; nY < nHeight; ++nY )
for( long nX = 0L; nX < nWidth; ++nX )
- pAcc->SetPixel( nY, nX,
- pAcc->GetPixel( nY, nX ).Merge(
rBackgroundColor,
- 255 -
pAlphaAcc->GetPixelIndex( nY, nX ) ) );
+ pAcc->SetPixel( nY, nX,
+ pAcc->GetPixel(
nY, nX ).Merge( rBackgroundColor,
+
255 - pAlphaAcc->GetPixelIndex(
nY, nX ) ) );
- bRet = sal_True;
+ bRet = sal_True;
}
const_cast<AlphaMask&>(rAlpha).ReleaseAccess( pAlphaAcc );
@@ -2012,13 +2012,15 @@ sal_Bool Bitmap::MakeMono( sal_uInt8 cThreshold )
bool Bitmap::GetSystemData( BitmapSystemData& rData ) const
{
- bool bRet = false;
- if( mpImpBmp )
- {
- SalBitmap* pSalBitmap = mpImpBmp->ImplGetSalBitmap();
- if( pSalBitmap )
- bRet = pSalBitmap->GetSystemData( rData );
- }
-
- return bRet;
+ bool bRet = false;
+ if( mpImpBmp )
+ {
+ SalBitmap* pSalBitmap = mpImpBmp->ImplGetSalBitmap();
+ if( pSalBitmap )
+ bRet = pSalBitmap->GetSystemData( rData );
+ }
+
+ return bRet;
}
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/vcl/source/gdi/bitmap3.cxx b/main/vcl/source/gdi/bitmap3.cxx
index 99f0af6e8b..c1121cf6f5 100644
--- a/main/vcl/source/gdi/bitmap3.cxx
+++ b/main/vcl/source/gdi/bitmap3.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -234,7 +234,7 @@ long FloydError7[61] =
long FloydIndexMap[6] =
{
- -30, 21, 72, 123, 174, 225
+ -30, 21, 72, 123, 174, 225
};
// --------------------------
@@ -255,8 +255,8 @@ void ImplCreateDitherMatrix( sal_uInt8
(*pDitherMatrix)[16][16] )
// MagicSquare aufbauen
for ( i = 0; i < 4; i++ )
- for ( j = 0; j < 4; j++ )
- for ( k = 0; k < 4; k++ )
+ for ( j = 0; j < 4; j++ )
+ for ( k = 0; k < 4; k++ )
for ( l = 0; l < 4; l++ )
nMax = Max ( pMtx[ (k<<2) + i][(l<<2 )
+ j] =
(sal_uInt16) ( 0.5 + pMagic[i][j]*fVal
+ pMagic[k][l]*fVal16 ), nMax );
@@ -479,7 +479,7 @@ sal_Bool Bitmap::ImplMakeMonoDither()
for( long nX = 0L, nModY = nY % 16; nX
< nWidth; nX++ )
{
if( pReadAcc->GetPixel( nY, nX
).GetLuminance() >
- pDitherMatrix[ nModY ][
nX % 16 ] )
+ pDitherMatrix[ nModY ][
nX % 16 ] )
{
pWriteAcc->SetPixel(
nY, nX, aWhite );
}
@@ -514,7 +514,7 @@ sal_Bool Bitmap::ImplMakeMonoDither()
sal_Bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
{
- DBG_ASSERT( nGreys == 16 || nGreys == 256, "Only 16 or 256 greyscales
are supported!" );
+ DBG_ASSERT( nGreys == 16 || nGreys == 256, "Only 16 or 256 grayscales
are supported!" );
BitmapReadAccess* pReadAcc = AcquireReadAccess();
sal_Bool bRet = sal_False;
@@ -565,7 +565,7 @@ sal_Bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
const sal_uLong nB =
*pReadScan++;
const sal_uLong nG =
*pReadScan++;
const sal_uLong nR =
*pReadScan++;
-
+
*pWriteScan++ =
(sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift );
}
}
@@ -585,7 +585,7 @@ sal_Bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
const sal_uLong nR =
*pReadScan++;
const sal_uLong nG =
*pReadScan++;
const sal_uLong nB =
*pReadScan++;
-
+
*pWriteScan++ =
(sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift );
}
}
@@ -704,7 +704,7 @@ sal_Bool Bitmap::ImplConvertUp( sal_uInt16 nBitCount,
Color* pExtColor )
sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor )
{
- DBG_ASSERT( nBitCount <= GetBitCount(), "New BitCount must be lower (
or equal when pExtColor is set )!" );
+ DBG_ASSERT( nBitCount <= GetBitCount(), "New BitCount must be lower (or
equal when pExtColor is set)!" );
BitmapReadAccess* pReadAcc = AcquireReadAccess();
sal_Bool bRet = sal_False;
@@ -779,11 +779,11 @@ sal_Bool Bitmap::ImplConvertDown( sal_uInt16 nBitCount,
Color* pExtColor )
}
// letztes ZeilenPixel
- if( nX < nWidth )
- {
- cIndex = (sal_uInt8)
aColorMap.GetBestPaletteIndex( pQLine1[ nWidth1 ].ImplGetColor() );
- pWriteAcc->SetPixelIndex( nY, nX, cIndex );
- }
+ if( nX < nWidth )
+ {
+ cIndex = (sal_uInt8)
aColorMap.GetBestPaletteIndex( pQLine1[ nWidth1 ].ImplGetColor() );
+ pWriteAcc->SetPixelIndex( nY, nX,
cIndex );
+ }
// Zeilenpuffer neu fuellen/kopieren
pQLine1 = pQLine2;
@@ -873,7 +873,7 @@ sal_Bool Bitmap::ImplConvertGhosted()
for( long nX = 0; nX < nWidth; nX++ )
{
const BitmapColor aOld(
pR->GetPixel( nY, nX ) );
- pW->SetPixel( nY, nX,
BitmapColor( ( aOld.GetRed() >> 1 ) | 0x80,
+ pW->SetPixel( nY, nX,
BitmapColor( ( aOld.GetRed() >> 1 ) | 0x80,
( aOld.GetGreen() >> 1 ) | 0x80,
( aOld.GetBlue() >> 1 ) | 0x80 ) );
@@ -906,122 +906,122 @@ sal_Bool Bitmap::ImplConvertGhosted()
sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY,
sal_uInt32 nScaleFlag )
{
- if(basegfx::fTools::equalZero(rScaleX) ||
basegfx::fTools::equalZero(rScaleY))
- {
- // no scale
- return true;
- }
-
- if(basegfx::fTools::equal(rScaleX, 1.0) && basegfx::fTools::equal(rScaleY,
1.0))
- {
- // no scale
- return true;
- }
+ if(basegfx::fTools::equalZero(rScaleX) ||
basegfx::fTools::equalZero(rScaleY))
+ {
+ // no scale
+ return true;
+ }
+
+ if(basegfx::fTools::equal(rScaleX, 1.0) &&
basegfx::fTools::equal(rScaleY, 1.0))
+ {
+ // no scale
+ return true;
+ }
#ifdef DBG_UTIL
- // #121233# allow to test the different scalers in debug build with source
- // level debugger (change nNumber to desired action)
- static sal_uInt16 nNumber(0);
- const sal_uInt16 nStartCount(GetBitCount());
-
- switch(nNumber)
- {
- case 0 : break;
- case 1: nScaleFlag = BMP_SCALE_FAST; break;
- case 2: nScaleFlag = BMP_SCALE_INTERPOLATE; break;
- case 3: nScaleFlag = BMP_SCALE_SUPER; break;
- case 4: nScaleFlag = BMP_SCALE_LANCZOS; break;
- case 5: nScaleFlag = BMP_SCALE_BICUBIC; break;
- case 6: nScaleFlag = BMP_SCALE_BILINEAR; break;
- case 7: nScaleFlag = BMP_SCALE_BOX; break;
- case 8: nScaleFlag = BMP_SCALE_BESTQUALITY; break;
- case 9: nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE; break;
- }
+ // #121233# allow to test the different scalers in debug build with
source
+ // level debugger (change nNumber to desired action)
+ static sal_uInt16 nNumber(0);
+ const sal_uInt16 nStartCount(GetBitCount());
+
+ switch(nNumber)
+ {
+ case 0 : break;
+ case 1: nScaleFlag = BMP_SCALE_FAST; break;
+ case 2: nScaleFlag = BMP_SCALE_INTERPOLATE; break;
+ case 3: nScaleFlag = BMP_SCALE_SUPER; break;
+ case 4: nScaleFlag = BMP_SCALE_LANCZOS; break;
+ case 5: nScaleFlag = BMP_SCALE_BICUBIC; break;
+ case 6: nScaleFlag = BMP_SCALE_BILINEAR; break;
+ case 7: nScaleFlag = BMP_SCALE_BOX; break;
+ case 8: nScaleFlag = BMP_SCALE_BESTQUALITY; break;
+ case 9: nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE; break;
+ }
#endif // DBG_UTIL
- bool bRetval(false);
-
- if(BMP_SCALE_BESTQUALITY == nScaleFlag)
- {
- // Use LANCZOS when best quality is requested
- nScaleFlag = BMP_SCALE_LANCZOS;
- }
- else if(BMP_SCALE_FASTESTINTERPOLATE == nScaleFlag)
- {
- // Use BMP_SCALE_SUPER when speed is requested, but not worst quality
- nScaleFlag = BMP_SCALE_SUPER;
- }
-
- switch(nScaleFlag)
- {
- default:
- case BMP_SCALE_NONE :
- {
- bRetval = false;
- break;
- }
- case BMP_SCALE_FAST :
- {
- bRetval = ImplScaleFast( rScaleX, rScaleY );
- break;
- }
- case BMP_SCALE_INTERPOLATE :
- {
- bRetval = ImplScaleInterpolate( rScaleX, rScaleY );
- break;
- }
- case BMP_SCALE_SUPER :
- {
- if(GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2)
- {
- // fallback to ImplScaleFast
- bRetval = ImplScaleFast( rScaleX, rScaleY );
- }
- else
- {
- // #121233# use method from symphony
- bRetval = ImplScaleSuper( rScaleX, rScaleY );
- }
- break;
- }
- case BMP_SCALE_LANCZOS :
- {
- const Lanczos3Kernel kernel;
-
- bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel);
- break;
- }
- case BMP_SCALE_BICUBIC :
- {
- const BicubicKernel kernel;
-
- bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
- break;
- }
- case BMP_SCALE_BILINEAR :
- {
- const BilinearKernel kernel;
-
- bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
- break;
- }
- case BMP_SCALE_BOX :
- {
- const BoxKernel kernel;
-
- bRetval = ImplScaleConvolution( rScaleX, rScaleY, kernel );
- break;
- }
- }
+ bool bRetval(false);
+
+ if(BMP_SCALE_BESTQUALITY == nScaleFlag)
+ {
+ // Use LANCZOS when best quality is requested
+ nScaleFlag = BMP_SCALE_LANCZOS;
+ }
+ else if(BMP_SCALE_FASTESTINTERPOLATE == nScaleFlag)
+ {
+ // Use BMP_SCALE_SUPER when speed is requested, but not worst
quality
+ nScaleFlag = BMP_SCALE_SUPER;
+ }
+
+ switch(nScaleFlag)
+ {
+ default:
+ case BMP_SCALE_NONE :
+ {
+ bRetval = false;
+ break;
+ }
+ case BMP_SCALE_FAST :
+ {
+ bRetval = ImplScaleFast( rScaleX, rScaleY );
+ break;
+ }
+ case BMP_SCALE_INTERPOLATE :
+ {
+ bRetval = ImplScaleInterpolate( rScaleX, rScaleY );
+ break;
+ }
+ case BMP_SCALE_SUPER :
+ {
+ if(GetSizePixel().Width() < 2 ||
GetSizePixel().Height() < 2)
+ {
+ // fallback to ImplScaleFast
+ bRetval = ImplScaleFast( rScaleX, rScaleY );
+ }
+ else
+ {
+ // #121233# use method from symphony
+ bRetval = ImplScaleSuper( rScaleX, rScaleY );
+ }
+ break;
+ }
+ case BMP_SCALE_LANCZOS :
+ {
+ const Lanczos3Kernel kernel;
+
+ bRetval = ImplScaleConvolution( rScaleX, rScaleY,
kernel);
+ break;
+ }
+ case BMP_SCALE_BICUBIC :
+ {
+ const BicubicKernel kernel;
+
+ bRetval = ImplScaleConvolution( rScaleX, rScaleY,
kernel );
+ break;
+ }
+ case BMP_SCALE_BILINEAR :
+ {
+ const BilinearKernel kernel;
+
+ bRetval = ImplScaleConvolution( rScaleX, rScaleY,
kernel );
+ break;
+ }
+ case BMP_SCALE_BOX :
+ {
+ const BoxKernel kernel;
+
+ bRetval = ImplScaleConvolution( rScaleX, rScaleY,
kernel );
+ break;
+ }
+ }
#ifdef DBG_UTIL
- if(bRetval && nStartCount != GetBitCount())
- {
- OSL_ENSURE(false, "Bitmap::Scale has changed the ColorDepth, this
should *not* happen (!)");
- }
+ if(bRetval && nStartCount != GetBitCount())
+ {
+ OSL_ENSURE(false, "Bitmap::Scale has changed the ColorDepth,
this should *not* happen (!)");
+ }
#endif
- return bRetval;
+ return bRetval;
}
// ------------------------------------------------------------------------
@@ -1047,59 +1047,59 @@ sal_Bool Bitmap::Scale( const Size& rNewSize,
sal_uInt32 nScaleFlag )
void Bitmap::AdaptBitCount(Bitmap& rNew) const
{
- ImplAdaptBitCount(rNew);
+ ImplAdaptBitCount(rNew);
}
// ------------------------------------------------------------------------
void Bitmap::ImplAdaptBitCount(Bitmap& rNew) const
{
- // aNew is the result of some operation; adapt it's BitCount to the
original (this)
- if(GetBitCount() != rNew.GetBitCount())
- {
- switch(GetBitCount())
- {
- case 1:
- {
- rNew.Convert(BMP_CONVERSION_1BIT_THRESHOLD);
- break;
- }
- case 4:
- {
- if(HasGreyPalette())
- {
- rNew.Convert(BMP_CONVERSION_4BIT_GREYS);
- }
- else
- {
- rNew.Convert(BMP_CONVERSION_4BIT_COLORS);
- }
- break;
- }
- case 8:
- {
- if(HasGreyPalette())
- {
- rNew.Convert(BMP_CONVERSION_8BIT_GREYS);
- }
- else
- {
- rNew.Convert(BMP_CONVERSION_8BIT_COLORS);
- }
- break;
- }
- case 24:
- {
- rNew.Convert(BMP_CONVERSION_24BIT);
- break;
- }
- default:
- {
- OSL_ENSURE(false, "BitDepth adaption failed (!)");
- break;
- }
- }
- }
+ // aNew is the result of some operation; adapt its BitCount to the
original (this)
+ if(GetBitCount() != rNew.GetBitCount())
+ {
+ switch(GetBitCount())
+ {
+ case 1:
+ {
+ rNew.Convert(BMP_CONVERSION_1BIT_THRESHOLD);
+ break;
+ }
+ case 4:
+ {
+ if(HasGreyPalette())
+ {
+ rNew.Convert(BMP_CONVERSION_4BIT_GREYS);
+ }
+ else
+ {
+
rNew.Convert(BMP_CONVERSION_4BIT_COLORS);
+ }
+ break;
+ }
+ case 8:
+ {
+ if(HasGreyPalette())
+ {
+ rNew.Convert(BMP_CONVERSION_8BIT_GREYS);
+ }
+ else
+ {
+
rNew.Convert(BMP_CONVERSION_8BIT_COLORS);
+ }
+ break;
+ }
+ case 24:
+ {
+ rNew.Convert(BMP_CONVERSION_24BIT);
+ break;
+ }
+ default:
+ {
+ OSL_ENSURE(false, "BitDepth adaption failed
(!)");
+ break;
+ }
+ }
+ }
}
// ------------------------------------------------------------------------
@@ -1114,8 +1114,8 @@ sal_Bool Bitmap::ImplScaleFast( const double& rScaleX,
const double& rScaleY )
if( nNewWidth && nNewHeight )
{
BitmapReadAccess* pReadAcc = AcquireReadAccess();
- if ( !pReadAcc )
- return sal_False;
+ if ( !pReadAcc )
+ return sal_False;
Bitmap aNewBmp( Size( nNewWidth,
nNewHeight ), GetBitCount(), &pReadAcc->GetPalette() );
BitmapWriteAccess* pWriteAcc =
aNewBmp.AcquireWriteAccess();
@@ -1219,19 +1219,19 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
{
if( 1 == nWidth )
{
- if( pReadAcc->HasPalette() )
- {
- aCol0 = pReadAcc->GetPaletteColor(
pReadAcc->GetPixelIndex( nY, 0 ) );
- }
- else
- {
- aCol0 = pReadAcc->GetPixel( nY, 0 );
- }
+ if( pReadAcc->HasPalette() )
+ {
+ aCol0 =
pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, 0 ) );
+ }
+ else
+ {
+ aCol0 = pReadAcc->GetPixel( nY,
0 );
+ }
for( nX = 0L; nX < nNewWidth; nX++ )
- {
+ {
pWriteAcc->SetPixel( nY, nX,
aCol0 );
- }
+ }
}
else
{
@@ -1239,16 +1239,16 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
{
nTemp = pLutInt[ nX ];
- if( pReadAcc->HasPalette() )
- {
+ if( pReadAcc->HasPalette() )
+ {
aCol0 =
pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) );
aCol1 =
pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) );
- }
- else
- {
+ }
+ else
+ {
aCol0 =
pReadAcc->GetPixel( nY, nTemp++ );
aCol1 =
pReadAcc->GetPixel( nY, nTemp );
- }
+ }
nTemp = pLutFrac[ nX ];
@@ -1276,8 +1276,8 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
if( bRet )
{
bRet = sal_False;
- const Bitmap aOriginal(*this);
- *this = aNewBmp;
+ const Bitmap aOriginal(*this);
+ *this = aNewBmp;
aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 );
pReadAcc = AcquireReadAccess();
pWriteAcc = aNewBmp.AcquireWriteAccess();
@@ -1299,7 +1299,7 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
pLutFrac[ nY ] = (long) ( fTemp * 1024.
);
}
- // after 1st step, bitmap *is* 24bit format (see above)
+ // after 1st step, bitmap *is* 24bit format
(see above)
OSL_ENSURE(!pReadAcc->HasPalette(), "OOps,
somehow ImplScaleInterpolate in-between format has palette, should not happen
(!)");
for( nX = 0L; nX < nNewWidth; nX++ )
@@ -1309,9 +1309,9 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
aCol0 = pReadAcc->GetPixel( 0,
nX );
for( nY = 0L; nY < nNewHeight;
nY++ )
- {
+ {
pWriteAcc->SetPixel(
nY, nX, aCol0 );
- }
+ }
}
else
{
@@ -1346,17 +1346,17 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
aNewBmp.ReleaseAccess( pWriteAcc );
if( bRet )
- {
- aOriginal.ImplAdaptBitCount(aNewBmp);
+ {
+ aOriginal.ImplAdaptBitCount(aNewBmp);
*this = aNewBmp;
- }
+ }
}
}
if( !bRet )
- {
+ {
bRet = ImplScaleFast( rScaleX, rScaleY );
- }
+ }
return bRet;
}
@@ -1364,20 +1364,20 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double&
rScaleX, const double& rSca
// ------------------------------------------------------------------------
// #121233# Added BMP_SCALE_SUPER from symphony code
-sal_Bool Bitmap::ImplScaleSuper(
- const double& rScaleX,
- const double& rScaleY )
+sal_Bool Bitmap::ImplScaleSuper(
+ const double& rScaleX,
+ const double& rScaleY )
{
const Size aSizePix( GetSizePixel() );
bool bHMirr = ( rScaleX < 0 );
- bool bVMirr = ( rScaleY < 0 );
- double scaleX = bHMirr ? -rScaleX : rScaleX;
- double scaleY = bVMirr ? -rScaleY : rScaleY;
+ bool bVMirr = ( rScaleY < 0 );
+ double scaleX = bHMirr ? -rScaleX : rScaleX;
+ double scaleY = bVMirr ? -rScaleY : rScaleY;
const long nDstW = FRound( aSizePix.Width() * scaleX );
const long nDstH = FRound( aSizePix.Height() * scaleY );
const double fScaleThresh = 0.6;
bool bRet = false;
-
+
if( ( nDstW > 1L ) && ( nDstH > 1L ) )
{
BitmapColor aCol0, aCol1, aColRes;
@@ -1386,46 +1386,46 @@ sal_Bool Bitmap::ImplScaleSuper(
long nH = pAcc->Height() ;
Bitmap aOutBmp( Size( nDstW, nDstH ),
24 );
BitmapWriteAccess* pWAcc = aOutBmp.AcquireWriteAccess();
- long* pMapIX = new long[ nDstW ];
- long* pMapIY = new long[ nDstH ];
- long* pMapFX = new long[ nDstW ];
- long* pMapFY = new long[ nDstH ];
+ long* pMapIX = new long[ nDstW ];
+ long* pMapIY = new long[ nDstH ];
+ long* pMapFX = new long[ nDstW ];
+ long* pMapFY = new long[ nDstH ];
long nX, nY, nXDst, nYDst;;
double fTemp;
long nTemp , nTempX, nTempY,
nTempFX, nTempFY;
- sal_uInt8 cR0, cG0, cB0, cR1, cG1, cB1;
- long nStartX = 0 , nStartY = 0;
- long nEndX = nDstW - 1L;
- long nEndY = nDstH - 1L;
- long nMax = 1 << 7L;
-
+ sal_uInt8 cR0, cG0, cB0, cR1, cG1, cB1;
+ long nStartX = 0 , nStartY = 0;
+ long nEndX = nDstW - 1L;
+ long nEndY = nDstH - 1L;
+ long nMax = 1 << 7L;
+
if( pAcc && pWAcc )
{
- const double fRevScaleX = ( nDstW > 1L ) ? ( (double) ( nW -
1 ) / ( nDstW - 1 ) ) : 0.0;
- const double fRevScaleY = ( nDstH > 1L ) ? ( (double) ( nH -
1 ) / ( nDstH - 1 ) ) : 0.0;
-
- // create horizontal mapping table
- for( nX = 0L, nTempX = nW - 1L, nTemp = nW - 2L; nX < nDstW; nX++ )
- {
- fTemp = nX * fRevScaleX;
-
- if( bHMirr )
- fTemp = nTempX - fTemp;
-
- pMapFX[ nX ] = (long) ( ( fTemp - ( pMapIX[ nX ] = MinMax(
(long) fTemp, 0, nTemp ) ) ) * 128. );
- }
-
- // create vertical mapping table
- for( nY = 0L, nTempY = nH - 1L, nTemp = nH - 2L; nY < nDstH; nY++ )
- {
- fTemp = nY * fRevScaleY;
-
- if( bVMirr )
- fTemp = nTempY - fTemp;
-
- pMapFY[ nY ] = (long) ( ( fTemp - ( pMapIY[ nY ] = MinMax(
(long) fTemp, 0, nTemp ) ) ) * 128. );
- }
-
+ const double fRevScaleX = ( nDstW > 1L ) ? (
(double) ( nW - 1 ) / ( nDstW - 1 ) ) : 0.0;
+ const double fRevScaleY = ( nDstH > 1L ) ? (
(double) ( nH - 1 ) / ( nDstH - 1 ) ) : 0.0;
+
+ // create horizontal mapping table
+ for( nX = 0L, nTempX = nW - 1L, nTemp = nW - 2L; nX <
nDstW; nX++ )
+ {
+ fTemp = nX * fRevScaleX;
+
+ if( bHMirr )
+ fTemp = nTempX - fTemp;
+
+ pMapFX[ nX ] = (long) ( ( fTemp - ( pMapIX[ nX
] = MinMax( (long) fTemp, 0, nTemp ) ) ) * 128. );
+ }
+
+ // create vertical mapping table
+ for( nY = 0L, nTempY = nH - 1L, nTemp = nH - 2L; nY <
nDstH; nY++ )
+ {
+ fTemp = nY * fRevScaleY;
+
+ if( bVMirr )
+ fTemp = nTempY - fTemp;
+
+ pMapFY[ nY ] = (long) ( ( fTemp - ( pMapIY[ nY
] = MinMax( (long) fTemp, 0, nTemp ) ) ) * 128. );
+ }
+
if( pAcc->HasPalette() )
{
if( pAcc->GetScanlineFormat() ==
BMP_FORMAT_8BIT_PAL )
@@ -1433,30 +1433,30 @@ sal_Bool Bitmap::ImplScaleSuper(
if( scaleX >= fScaleThresh && scaleY >=
fScaleThresh )
{
Scanline pLine0, pLine1;
-
+
for( nY = nStartY, nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTempY = pMapIY[ nY ];
nTempFY = pMapFY[ nY ];
pLine0 =
pAcc->GetScanline( nTempY );
pLine1 =
pAcc->GetScanline( ++nTempY );
-
+
for( nX = nStartX,
nXDst = 0L; nX <= nEndX; nX++ )
{
nTempX =
pMapIX[ nX ]; nTempFX = pMapFX[ nX ];
-
+
const
BitmapColor& rCol0 = pAcc->GetPaletteColor( pLine0[ nTempX ] );
const
BitmapColor& rCol2 = pAcc->GetPaletteColor( pLine1[ nTempX ] );
const
BitmapColor& rCol1 = pAcc->GetPaletteColor( pLine0[ ++nTempX ] );
const
BitmapColor& rCol3 = pAcc->GetPaletteColor( pLine1[ nTempX ] );
-
+
cR0 = MAP(
rCol0.GetRed(), rCol1.GetRed(), nTempFX );
cG0 = MAP(
rCol0.GetGreen(), rCol1.GetGreen(), nTempFX );
cB0 = MAP(
rCol0.GetBlue(), rCol1.GetBlue(), nTempFX );
-
+
cR1 = MAP(
rCol2.GetRed(), rCol3.GetRed(), nTempFX );
cG1 = MAP(
rCol2.GetGreen(), rCol3.GetGreen(), nTempFX );
cB1 = MAP(
rCol2.GetBlue(), rCol3.GetBlue(), nTempFX );
-
+
aColRes.SetRed(
MAP( cR0, cR1, nTempFY ) );
aColRes.SetGreen( MAP( cG0, cG1, nTempFY ) );
aColRes.SetBlue( MAP( cB0, cB1, nTempFY ) );
@@ -1470,14 +1470,14 @@ sal_Bool Bitmap::ImplScaleSuper(
long nSumR, nSumG,
nSumB,nLineStart , nLineRange, nRowStart , nRowRange ;
long nLeft, nRight,
nTop, nBottom, nWeightX, nWeightY ;
long nSumRowR
,nSumRowG,nSumRowB, nTotalWeightX, nTotalWeightY;
-
+
for( nY = nStartY , nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTop = bVMirr ? ( nY +
1 ) : nY;
nBottom = bVMirr ? nY :
( nY + 1 ) ;
-
+
if( nY ==nEndY )
- {
+ {
nLineStart =
pMapIY[ nY ];
nLineRange = 0;
}
@@ -1486,14 +1486,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nLineStart =
pMapIY[ nTop ] ;
nLineRange = (
pMapIY[ nBottom ] == pMapIY[ nTop ] ) ? 1 :( pMapIY[ nBottom ] - pMapIY[ nTop ]
);
}
-
+
for( nX = nStartX ,
nXDst = 0L; nX <= nEndX; nX++ )
{
nLeft = bHMirr
? ( nX + 1 ) : nX;
nRight = bHMirr
? nX : ( nX + 1 ) ;
-
+
if( nX == nEndX
)
- {
+ {
nRowStart = pMapIX[ nX ];
nRowRange = 0;
}
@@ -1502,29 +1502,29 @@ sal_Bool Bitmap::ImplScaleSuper(
nRowStart = pMapIX[ nLeft ];
nRowRange = ( pMapIX[ nRight ] == pMapIX[ nLeft ] )? 1 : ( pMapIX[ nRight ] -
pMapIX[ nLeft ] );
}
-
+
nSumR = nSumG =
nSumB = 0;
nTotalWeightY =
0;
-
+
for(int i = 0;
i<= nLineRange; i++)
{
pTmpY =
pAcc->GetScanline( nLineStart + i );
nSumRowR = nSumRowG = nSumRowB = 0;
nTotalWeightX = 0;
-
+
for(int
j = 0; j <= nRowRange; j++)
{
const BitmapColor& rCol = pAcc->GetPaletteColor( pTmpY[ nRowStart + j ] );
-
+
if(nX == nEndX )
- {
+
{
nSumRowB += rCol.GetBlue() << 7L;
nSumRowG += rCol.GetGreen() << 7L;
nSumRowR += rCol.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
else if( j == 0 )
- {
+
{
nWeightX = (nMax- pMapFX[ nLeft ]) ;
nSumRowB += ( nWeightX *rCol.GetBlue()) ;
nSumRowG += ( nWeightX *rCol.GetGreen()) ;
@@ -1532,7 +1532,7 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else if ( nRowRange == j )
- {
+
{
nWeightX = pMapFX[ nRight ] ;
nSumRowB += ( nWeightX *rCol.GetBlue() );
nSumRowG += ( nWeightX *rCol.GetGreen() );
@@ -1540,14 +1540,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else
- {
+
{
nSumRowB += rCol.GetBlue() << 7L;
nSumRowG += rCol.GetGreen() << 7L;
nSumRowR += rCol.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
}
-
+
if( nY
== nEndY )
nWeightY = nMax;
else
if( i == 0 )
@@ -1558,20 +1558,20 @@ sal_Bool Bitmap::ImplScaleSuper(
nWeightY = pMapFY[ nBottom ];
else
nWeightY = nMax;
-
+
nSumB
+= nWeightY * ( nSumRowB / nTotalWeightX );
nSumG
+= nWeightY * ( nSumRowG / nTotalWeightX );
nSumR
+= nWeightY * ( nSumRowR / nTotalWeightX );
nTotalWeightY += nWeightY;
}
-
+
aColRes.SetRed(
( sal_uInt8 ) (( nSumR / nTotalWeightY ) ));
aColRes.SetGreen( ( sal_uInt8 ) (( nSumG / nTotalWeightY) ));
aColRes.SetBlue( ( sal_uInt8 ) (( nSumB / nTotalWeightY ) ));
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
-
+
}
- }
+ }
}
}
else
@@ -1581,44 +1581,44 @@ sal_Bool Bitmap::ImplScaleSuper(
for( nY = nStartY, nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTempY = pMapIY[ nY ],
nTempFY = pMapFY[ nY ];
-
+
for( nX = nStartX,
nXDst = 0L; nX <= nEndX; nX++ )
{
nTempX =
pMapIX[ nX ]; nTempFX = pMapFX[ nX ];
-
+
aCol0 =
pAcc->GetPaletteColor( pAcc->GetPixelIndex( nTempY, nTempX ) );
aCol1 =
pAcc->GetPaletteColor( pAcc->GetPixelIndex( nTempY, ++nTempX ) );
cR0 = MAP(
aCol0.GetRed(), aCol1.GetRed(), nTempFX );
cG0 = MAP(
aCol0.GetGreen(), aCol1.GetGreen(), nTempFX );
cB0 = MAP(
aCol0.GetBlue(), aCol1.GetBlue(), nTempFX );
-
+
aCol1 =
pAcc->GetPaletteColor( pAcc->GetPixelIndex( ++nTempY, nTempX ) );
aCol0 =
pAcc->GetPaletteColor( pAcc->GetPixelIndex( nTempY--, --nTempX ) );
cR1 = MAP(
aCol0.GetRed(), aCol1.GetRed(), nTempFX );
cG1 = MAP(
aCol0.GetGreen(), aCol1.GetGreen(), nTempFX );
cB1 = MAP(
aCol0.GetBlue(), aCol1.GetBlue(), nTempFX );
-
+
aColRes.SetRed(
MAP( cR0, cR1, nTempFY ) );
aColRes.SetGreen( MAP( cG0, cG1, nTempFY ) );
aColRes.SetBlue( MAP( cB0, cB1, nTempFY ) );
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
}
}
-
+
}
else
{
long nSumR, nSumG,
nSumB,nLineStart , nLineRange, nRowStart , nRowRange ;
long nLeft, nRight,
nTop, nBottom, nWeightX, nWeightY ;
long nSumRowR
,nSumRowG,nSumRowB, nTotalWeightX, nTotalWeightY;
-
+
for( nY = nStartY , nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTop = bVMirr ? ( nY +
1 ) : nY;
nBottom = bVMirr ? nY :
( nY + 1 ) ;
-
+
if( nY ==nEndY )
- {
+ {
nLineStart =
pMapIY[ nY ];
nLineRange = 0;
}
@@ -1627,14 +1627,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nLineStart =
pMapIY[ nTop ] ;
nLineRange = (
pMapIY[ nBottom ] == pMapIY[ nTop ] ) ? 1 :( pMapIY[ nBottom ] - pMapIY[ nTop ]
);
}
-
+
for( nX = nStartX ,
nXDst = 0L; nX <= nEndX; nX++ )
{
nLeft = bHMirr
? ( nX + 1 ) : nX;
nRight = bHMirr
? nX : ( nX + 1 ) ;
-
+
if( nX == nEndX
)
- {
+ {
nRowStart = pMapIX[ nX ];
nRowRange = 0;
}
@@ -1643,30 +1643,30 @@ sal_Bool Bitmap::ImplScaleSuper(
nRowStart = pMapIX[ nLeft ];
nRowRange = ( pMapIX[ nRight ] == pMapIX[ nLeft ] )? 1 : ( pMapIX[ nRight ] -
pMapIX[ nLeft ] );
}
-
+
nSumR = nSumG =
nSumB = 0;
nTotalWeightY =
0;
-
+
for(int i = 0;
i<= nLineRange; i++)
{
nSumRowR = nSumRowG = nSumRowB = 0;
nTotalWeightX = 0;
-
+
for(int
j = 0; j <= nRowRange; j++)
{
aCol0 = pAcc->GetPaletteColor ( pAcc->GetPixelIndex( nLineStart + i, nRowStart
+ j ) );
-
- if(nX == nEndX )
- {
-
+
+
if(nX == nEndX )
+
{
+
nSumRowB += aCol0.GetBlue() << 7L;
nSumRowG += aCol0.GetGreen() << 7L;
nSumRowR += aCol0.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
else if( j == 0 )
- {
-
+
{
+
nWeightX = (nMax- pMapFX[ nLeft ]) ;
nSumRowB += ( nWeightX *aCol0.GetBlue()) ;
nSumRowG += ( nWeightX *aCol0.GetGreen()) ;
@@ -1674,8 +1674,8 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else if ( nRowRange == j )
- {
-
+
{
+
nWeightX = pMapFX[ nRight ] ;
nSumRowB += ( nWeightX *aCol0.GetBlue() );
nSumRowG += ( nWeightX *aCol0.GetGreen() );
@@ -1683,15 +1683,15 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else
- {
-
+
{
+
nSumRowB += aCol0.GetBlue() << 7L;
nSumRowG += aCol0.GetGreen() << 7L;
nSumRowR += aCol0.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
}
-
+
if( nY
== nEndY )
nWeightY = nMax;
else
if( i == 0 )
@@ -1702,19 +1702,19 @@ sal_Bool Bitmap::ImplScaleSuper(
nWeightY = pMapFY[ nBottom ];
else
nWeightY = nMax;
-
+
nSumB
+= nWeightY * ( nSumRowB / nTotalWeightX );
nSumG
+= nWeightY * ( nSumRowG / nTotalWeightX );
nSumR
+= nWeightY * ( nSumRowR / nTotalWeightX );
nTotalWeightY += nWeightY;
}
-
+
aColRes.SetRed(
( sal_uInt8 ) (( nSumR / nTotalWeightY ) ));
aColRes.SetGreen( ( sal_uInt8 ) (( nSumG / nTotalWeightY) ));
aColRes.SetBlue( ( sal_uInt8 ) (( nSumB / nTotalWeightY ) ));
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
}
- }
+ }
}
}
}
@@ -1726,28 +1726,28 @@ sal_Bool Bitmap::ImplScaleSuper(
{
Scanline pLine0, pLine1,
pTmp0, pTmp1;
long nOff;
-
+
for( nY = nStartY, nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTempY = pMapIY[ nY ];
nTempFY = pMapFY[ nY ];
pLine0 =
pAcc->GetScanline( nTempY );
pLine1 =
pAcc->GetScanline( ++nTempY );
-
- for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+
+ for( nX = nStartX,
nXDst = 0L; nX <= nEndX; nX++ )
{
nOff = 3L * (
nTempX = pMapIX[ nX ] );
nTempFX =
pMapFX[ nX ];
-
+
pTmp1 = ( pTmp0
= pLine0 + nOff ) + 3L;
cB0 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cG0 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cR0 = MAP(
*pTmp0, *pTmp1, nTempFX );
-
+
pTmp1 = ( pTmp0
= pLine1 + nOff ) + 3L;
cB1 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cG1 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cR1 = MAP(
*pTmp0, *pTmp1, nTempFX );
-
+
aColRes.SetRed(
MAP( cR0, cR1, nTempFY ) );
aColRes.SetGreen( MAP( cG0, cG1, nTempFY ) );
aColRes.SetBlue( MAP( cB0, cB1, nTempFY ) );
@@ -1761,14 +1761,14 @@ sal_Bool Bitmap::ImplScaleSuper(
long nSumR, nSumG,
nSumB,nLineStart , nLineRange, nRowStart , nRowRange ;
long nLeft, nRight,
nTop, nBottom, nWeightX, nWeightY ;
long nSumRowR
,nSumRowG,nSumRowB, nTotalWeightX, nTotalWeightY;
-
+
for( nY = nStartY , nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTop = bVMirr ? ( nY +
1 ) : nY;
nBottom = bVMirr ? nY :
( nY + 1 ) ;
-
+
if( nY ==nEndY )
- {
+ {
nLineStart =
pMapIY[ nY ];
nLineRange = 0;
}
@@ -1777,14 +1777,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nLineStart =
pMapIY[ nTop ] ;
nLineRange = (
pMapIY[ nBottom ] == pMapIY[ nTop ] ) ? 1 :( pMapIY[ nBottom ] - pMapIY[ nTop ]
);
}
-
+
for( nX = nStartX ,
nXDst = 0L; nX <= nEndX; nX++ )
{
nLeft = bHMirr
? ( nX + 1 ) : nX;
nRight = bHMirr
? nX : ( nX + 1 ) ;
-
- if( nX == nEndX
)
- {
+
+ if( nX == nEndX
)
+ {
nRowStart = pMapIX[ nX ];
nRowRange = 0;
}
@@ -1793,28 +1793,28 @@ sal_Bool Bitmap::ImplScaleSuper(
nRowStart = pMapIX[ nLeft ];
nRowRange = ( pMapIX[ nRight ] == pMapIX[ nLeft ] )? 1 : ( pMapIX[ nRight ] -
pMapIX[ nLeft ] );
}
-
+
nSumR = nSumG =
nSumB = 0;
nTotalWeightY =
0;
-
+
for(int i = 0;
i<= nLineRange; i++)
{
pTmpY =
pAcc->GetScanline( nLineStart + i );
pTmpX =
pTmpY + 3L * nRowStart;
nSumRowR = nSumRowG = nSumRowB = 0;
nTotalWeightX = 0;
-
+
for(int
j = 0; j <= nRowRange; j++)
{
if(nX == nEndX )
- {
-
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
-
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
-
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
+
{
+
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
+
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
+
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
nTotalWeightX += 1 << 7L;
}
else if( j == 0 )
- {
+
{
nWeightX = (nMax- pMapFX[ nLeft ]) ;
nSumRowB += ( nWeightX *( *pTmpX )) ;pTmpX++;
nSumRowG += ( nWeightX *( *pTmpX )) ;pTmpX++;
@@ -1822,7 +1822,7 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else if ( nRowRange == j )
- {
+
{
nWeightX = pMapFX[ nRight ] ;
nSumRowB += ( nWeightX *( *pTmpX ) );pTmpX++;
nSumRowG += ( nWeightX *( *pTmpX ) );pTmpX++;
@@ -1831,13 +1831,13 @@ sal_Bool Bitmap::ImplScaleSuper(
}
else
{
-
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
+
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
nTotalWeightX += 1 << 7L;
}
}
-
+
if( nY
== nEndY )
nWeightY = nMax;
else
if( i == 0 )
@@ -1848,20 +1848,20 @@ sal_Bool Bitmap::ImplScaleSuper(
nWeightY = pMapFY[ nBottom ];
else
nWeightY = nMax;
-
+
nSumB
+= nWeightY * ( nSumRowB / nTotalWeightX );
nSumG
+= nWeightY * ( nSumRowG / nTotalWeightX );
nSumR
+= nWeightY * ( nSumRowR / nTotalWeightX );
nTotalWeightY += nWeightY;
}
-
+
aColRes.SetRed(
( sal_uInt8 ) (( nSumR / nTotalWeightY ) ));
aColRes.SetGreen( ( sal_uInt8 ) (( nSumG / nTotalWeightY) ));
aColRes.SetBlue( ( sal_uInt8 ) (( nSumB / nTotalWeightY ) ));
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
-
+
}
- }
+ }
}
}
else if( pAcc->GetScanlineFormat() ==
BMP_FORMAT_24BIT_TC_RGB )
@@ -1870,28 +1870,28 @@ sal_Bool Bitmap::ImplScaleSuper(
{
Scanline pLine0, pLine1,
pTmp0, pTmp1;
long nOff;
-
+
for( nY = nStartY, nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTempY = pMapIY[ nY ];
nTempFY = pMapFY[ nY ];
pLine0 =
pAcc->GetScanline( nTempY );
pLine1 =
pAcc->GetScanline( ++nTempY );
-
+
for( nX = nStartX,
nXDst = 0L; nX <= nEndX; nX++ )
{
nOff = 3L * (
nTempX = pMapIX[ nX ] );
nTempFX =
pMapFX[ nX ];
-
+
pTmp1 = ( pTmp0
= pLine0 + nOff ) + 3L;
cR0 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cG0 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cB0 = MAP(
*pTmp0, *pTmp1, nTempFX );
-
+
pTmp1 = ( pTmp0
= pLine1 + nOff ) + 3L;
cR1 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cG1 = MAP(
*pTmp0, *pTmp1, nTempFX ); pTmp0++; pTmp1++;
cB1 = MAP(
*pTmp0, *pTmp1, nTempFX );
-
+
aColRes.SetRed(
MAP( cR0, cR1, nTempFY ) );
aColRes.SetGreen( MAP( cG0, cG1, nTempFY ) );
aColRes.SetBlue( MAP( cB0, cB1, nTempFY ) );
@@ -1905,14 +1905,14 @@ sal_Bool Bitmap::ImplScaleSuper(
long nSumR, nSumG,
nSumB,nLineStart , nLineRange, nRowStart , nRowRange ;
long nLeft, nRight,
nTop, nBottom, nWeightX, nWeightY ;
long nSumRowR
,nSumRowG,nSumRowB, nTotalWeightX, nTotalWeightY;
-
+
for( nY = nStartY , nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTop = bVMirr ? ( nY +
1 ) : nY;
nBottom = bVMirr ? nY :
( nY + 1 ) ;
-
+
if( nY ==nEndY )
- {
+ {
nLineStart =
pMapIY[ nY ];
nLineRange = 0;
}
@@ -1921,14 +1921,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nLineStart =
pMapIY[ nTop ] ;
nLineRange = (
pMapIY[ nBottom ] == pMapIY[ nTop ] ) ? 1 :( pMapIY[ nBottom ] - pMapIY[ nTop ]
);
}
-
+
for( nX = nStartX ,
nXDst = 0L; nX <= nEndX; nX++ )
{
nLeft = bHMirr
? ( nX + 1 ) : nX;
nRight = bHMirr
? nX : ( nX + 1 ) ;
-
+
if( nX == nEndX
)
- {
+ {
nRowStart = pMapIX[ nX ];
nRowRange = 0;
}
@@ -1937,28 +1937,28 @@ sal_Bool Bitmap::ImplScaleSuper(
nRowStart = pMapIX[ nLeft ];
nRowRange = ( pMapIX[ nRight ] == pMapIX[ nLeft ] )? 1 : ( pMapIX[ nRight ] -
pMapIX[ nLeft ] );
}
-
+
nSumR = nSumG =
nSumB = 0;
nTotalWeightY =
0;
-
+
for(int i = 0;
i<= nLineRange; i++)
{
pTmpY =
pAcc->GetScanline( nLineStart + i );
pTmpX =
pTmpY + 3L * nRowStart;
nSumRowR = nSumRowG = nSumRowB = 0;
nTotalWeightX = 0;
-
+
for(int
j = 0; j <= nRowRange; j++)
{
if(nX == nEndX )
- {
-
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
-
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
-
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
+
{
+
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
+
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
+
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
nTotalWeightX += 1 << 7L;
}
else if( j == 0 )
- {
+
{
nWeightX = (nMax- pMapFX[ nLeft ]) ;
nSumRowR += ( nWeightX *( *pTmpX )) ;pTmpX++;
nSumRowG += ( nWeightX *( *pTmpX )) ;pTmpX++;
@@ -1966,7 +1966,7 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else if ( nRowRange == j )
- {
+
{
nWeightX = pMapFX[ nRight ] ;
nSumRowR += ( nWeightX *( *pTmpX ) );pTmpX++;
nSumRowG += ( nWeightX *( *pTmpX ) );pTmpX++;
@@ -1974,14 +1974,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else
- {
-
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
+
{
+
nSumRowR += ( *pTmpX ) << 7L;pTmpX++;
nSumRowG += ( *pTmpX ) << 7L;pTmpX++;
nSumRowB += ( *pTmpX ) << 7L;pTmpX++;
nTotalWeightX += 1 << 7L;
}
}
-
+
if( nY
== nEndY )
nWeightY = nMax;
else
if( i == 0 )
@@ -1992,20 +1992,20 @@ sal_Bool Bitmap::ImplScaleSuper(
nWeightY = pMapFY[ nBottom ];
else
nWeightY = nMax;
-
+
nSumB
+= nWeightY * ( nSumRowB / nTotalWeightX );
nSumG
+= nWeightY * ( nSumRowG / nTotalWeightX );
nSumR
+= nWeightY * ( nSumRowR / nTotalWeightX );
nTotalWeightY += nWeightY;
}
-
+
aColRes.SetRed(
( sal_uInt8 ) (( nSumR / nTotalWeightY ) ));
aColRes.SetGreen( ( sal_uInt8 ) (( nSumG / nTotalWeightY) ));
aColRes.SetBlue( ( sal_uInt8 ) (( nSumB / nTotalWeightY ) ));
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
-
+
}
- }
+ }
}
}
else
@@ -2015,23 +2015,23 @@ sal_Bool Bitmap::ImplScaleSuper(
for( nY = nStartY, nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTempY = pMapIY[ nY ];
nTempFY = pMapFY[ nY ];
-
+
for( nX = nStartX,
nXDst = 0L; nX <= nEndX; nX++ )
{
nTempX =
pMapIX[ nX ]; nTempFX = pMapFX[ nX ];
-
+
aCol0 =
pAcc->GetPixel( nTempY, nTempX );
aCol1 =
pAcc->GetPixel( nTempY, ++nTempX );
cR0 = MAP(
aCol0.GetRed(), aCol1.GetRed(), nTempFX );
cG0 = MAP(
aCol0.GetGreen(), aCol1.GetGreen(), nTempFX );
cB0 = MAP(
aCol0.GetBlue(), aCol1.GetBlue(), nTempFX );
-
+
aCol1 =
pAcc->GetPixel( ++nTempY, nTempX );
aCol0 =
pAcc->GetPixel( nTempY--, --nTempX );
cR1 = MAP(
aCol0.GetRed(), aCol1.GetRed(), nTempFX );
cG1 = MAP(
aCol0.GetGreen(), aCol1.GetGreen(), nTempFX );
cB1 = MAP(
aCol0.GetBlue(), aCol1.GetBlue(), nTempFX );
-
+
aColRes.SetRed(
MAP( cR0, cR1, nTempFY ) );
aColRes.SetGreen( MAP( cG0, cG1, nTempFY ) );
aColRes.SetBlue( MAP( cB0, cB1, nTempFY ) );
@@ -2044,14 +2044,14 @@ sal_Bool Bitmap::ImplScaleSuper(
long nSumR, nSumG,
nSumB,nLineStart , nLineRange, nRowStart , nRowRange ;
long nLeft, nRight,
nTop, nBottom, nWeightX, nWeightY ;
long nSumRowR
,nSumRowG,nSumRowB, nTotalWeightX, nTotalWeightY;
-
+
for( nY = nStartY , nYDst = 0L;
nY <= nEndY; nY++, nYDst++ )
{
nTop = bVMirr ? ( nY +
1 ) : nY;
nBottom = bVMirr ? nY :
( nY + 1 ) ;
-
+
if( nY ==nEndY )
- {
+ {
nLineStart =
pMapIY[ nY ];
nLineRange = 0;
}
@@ -2060,14 +2060,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nLineStart =
pMapIY[ nTop ] ;
nLineRange = (
pMapIY[ nBottom ] == pMapIY[ nTop ] ) ? 1 :( pMapIY[ nBottom ] - pMapIY[ nTop ]
);
}
-
+
for( nX = nStartX ,
nXDst = 0L; nX <= nEndX; nX++ )
{
nLeft = bHMirr
? ( nX + 1 ) : nX;
nRight = bHMirr
? nX : ( nX + 1 ) ;
-
+
if( nX == nEndX
)
- {
+ {
nRowStart = pMapIX[ nX ];
nRowRange = 0;
}
@@ -2076,30 +2076,30 @@ sal_Bool Bitmap::ImplScaleSuper(
nRowStart = pMapIX[ nLeft ];
nRowRange = ( pMapIX[ nRight ] == pMapIX[ nLeft ] )? 1 : ( pMapIX[ nRight ] -
pMapIX[ nLeft ] );
}
-
+
nSumR = nSumG =
nSumB = 0;
nTotalWeightY =
0;
-
+
for(int i = 0;
i<= nLineRange; i++)
{
nSumRowR = nSumRowG = nSumRowB = 0;
nTotalWeightX = 0;
-
+
for(int
j = 0; j <= nRowRange; j++)
{
aCol0 = pAcc->GetPixel( nLineStart + i, nRowStart + j );
-
- if(nX == nEndX )
- {
-
+
+
if(nX == nEndX )
+
{
+
nSumRowB += aCol0.GetBlue() << 7L;
nSumRowG += aCol0.GetGreen() << 7L;
nSumRowR += aCol0.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
else if( j == 0 )
- {
-
+
{
+
nWeightX = (nMax- pMapFX[ nLeft ]) ;
nSumRowB += ( nWeightX *aCol0.GetBlue()) ;
nSumRowG += ( nWeightX *aCol0.GetGreen()) ;
@@ -2107,8 +2107,8 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else if ( nRowRange == j )
- {
-
+
{
+
nWeightX = pMapFX[ nRight ] ;
nSumRowB += ( nWeightX *aCol0.GetBlue() );
nSumRowG += ( nWeightX *aCol0.GetGreen() );
@@ -2116,14 +2116,14 @@ sal_Bool Bitmap::ImplScaleSuper(
nTotalWeightX += nWeightX;
}
else
- {
+
{
nSumRowB += aCol0.GetBlue() << 7L;
nSumRowG += aCol0.GetGreen() << 7L;
nSumRowR += aCol0.GetRed() << 7L;
nTotalWeightX += 1 << 7L;
}
}
-
+
if( nY
== nEndY )
nWeightY = nMax;
else
if( i == 0 )
@@ -2134,43 +2134,43 @@ sal_Bool Bitmap::ImplScaleSuper(
nWeightY = pMapFY[ nBottom ];
else
nWeightY = nMax;
-
+
nSumB
+= nWeightY * ( nSumRowB / nTotalWeightX );
nSumG
+= nWeightY * ( nSumRowG / nTotalWeightX );
nSumR
+= nWeightY * ( nSumRowR / nTotalWeightX );
nTotalWeightY += nWeightY;
}
-
+
aColRes.SetRed(
( sal_uInt8 ) (( nSumR / nTotalWeightY ) ));
aColRes.SetGreen( ( sal_uInt8 ) (( nSumG / nTotalWeightY) ));
aColRes.SetBlue( ( sal_uInt8 ) (( nSumB / nTotalWeightY ) ));
pWAcc->SetPixel( nYDst, nXDst++, aColRes );
-
+
}
- }
+ }
}
}
- }
-
- bRet = true;
+ }
+
+ bRet = true;
}
-
+
delete[] pMapIX;
delete[] pMapIY;
delete[] pMapFX;
delete[] pMapFY;
-
+
ReleaseAccess( pAcc );
aOutBmp.ReleaseAccess( pWAcc );
-
+
if( bRet )
- {
- ImplAdaptBitCount(aOutBmp);
+ {
+ ImplAdaptBitCount(aOutBmp);
ImplAssignWithSize(aOutBmp);
- }
-
+ }
+
if( !bRet )
- bRet = ImplScaleFast( scaleX, scaleY );
+ bRet = ImplScaleFast( scaleX, scaleY );
}
return bRet;
@@ -2180,358 +2180,358 @@ sal_Bool Bitmap::ImplScaleSuper(
namespace
{
- void ImplCalculateContributions(
- const sal_uInt32 aSourceSize,
- const sal_uInt32 aDestinationSize,
- sal_uInt32& aNumberOfContributions,
- double*& pWeights,
- sal_uInt32*& pPixels,
- sal_uInt32*& pCount,
- const Kernel& aKernel)
- {
- const double fSamplingRadius(aKernel.GetWidth());
- const double fScale(aDestinationSize / static_cast< double
>(aSourceSize));
- const double fScaledRadius((fScale < 1.0) ? fSamplingRadius / fScale :
fSamplingRadius);
- const double fFilterFactor((fScale < 1.0) ? fScale : 1.0);
-
- aNumberOfContributions = (static_cast< sal_uInt32
>(fabs(ceil(fScaledRadius))) * 2) + 1;
- const sal_uInt32 nAllocSize(aDestinationSize * aNumberOfContributions);
- pWeights = new double[nAllocSize];
- pPixels = new sal_uInt32[nAllocSize];
- pCount = new sal_uInt32[aDestinationSize];
-
- for(sal_uInt32 i(0); i < aDestinationSize; i++)
- {
- const sal_uInt32 aIndex(i * aNumberOfContributions);
- const double aCenter(i / fScale);
- const sal_Int32 aLeft(static_cast< sal_Int32 >(floor(aCenter -
fScaledRadius)));
- const sal_Int32 aRight(static_cast< sal_Int32 >(ceil(aCenter +
fScaledRadius)));
- sal_uInt32 aCurrentCount(0);
-
- for(sal_Int32 j(aLeft); j <= aRight; j++)
- {
- const double aWeight(aKernel.Calculate(fFilterFactor *
(aCenter - static_cast< double>(j))));
-
- // Reduce calculations with ignoring weights of 0.0
- if(fabs(aWeight) < 0.0001)
- {
- continue;
- }
-
- // Handling on edges
- const sal_uInt32 aPixelIndex(MinMax(j, 0, aSourceSize - 1));
- const sal_uInt32 nIndex(aIndex + aCurrentCount);
-
- pWeights[nIndex] = aWeight;
- pPixels[nIndex] = aPixelIndex;
-
- aCurrentCount++;
- }
-
- pCount[i] = aCurrentCount;
- }
- }
-
- sal_Bool ImplScaleConvolutionHor(
- Bitmap& rSource,
- Bitmap& rTarget,
- const double& rScaleX,
- const Kernel& aKernel)
- {
- // Do horizontal filtering
- OSL_ENSURE(rScaleX > 0.0, "Error in scaling: Mirror given in
non-mirror-capable method (!)");
- const sal_uInt32 nWidth(rSource.GetSizePixel().Width());
- const sal_uInt32 nNewWidth(FRound(nWidth * rScaleX));
-
- if(nWidth == nNewWidth)
- {
- return true;
- }
-
- BitmapReadAccess* pReadAcc = rSource.AcquireReadAccess();
-
- if(pReadAcc)
- {
- double* pWeights = 0;
- sal_uInt32* pPixels = 0;
- sal_uInt32* pCount = 0;
- sal_uInt32 aNumberOfContributions(0);
-
- const sal_uInt32 nHeight(rSource.GetSizePixel().Height());
- ImplCalculateContributions(nWidth, nNewWidth,
aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
- rTarget = Bitmap(Size(nNewWidth, nHeight), 24);
- BitmapWriteAccess* pWriteAcc = rTarget.AcquireWriteAccess();
- bool bResult(0 != pWriteAcc);
-
- if(bResult)
- {
- for(sal_uInt32 y(0); y < nHeight; y++)
- {
- for(sal_uInt32 x(0); x < nNewWidth; x++)
- {
- const sal_uInt32 aBaseIndex(x *
aNumberOfContributions);
- double aSum(0.0);
- double aValueRed(0.0);
- double aValueGreen(0.0);
- double aValueBlue(0.0);
-
- for(sal_uInt32 j(0); j < pCount[x]; j++)
- {
- const sal_uInt32 aIndex(aBaseIndex + j);
- const double aWeight(pWeights[aIndex]);
- BitmapColor aColor;
-
- aSum += aWeight;
-
- if(pReadAcc->HasPalette())
- {
- aColor =
pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(y, pPixels[aIndex]));
- }
- else
- {
- aColor = pReadAcc->GetPixel(y,
pPixels[aIndex]);
- }
-
- aValueRed += aWeight * aColor.GetRed();
- aValueGreen += aWeight * aColor.GetGreen();
- aValueBlue += aWeight * aColor.GetBlue();
- }
-
- const BitmapColor aResultColor(
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueRed / aSum), 0, 255)),
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueGreen / aSum), 0, 255)),
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueBlue / aSum), 0, 255)));
-
- pWriteAcc->SetPixel(y, x, aResultColor);
- }
- }
-
- rTarget.ReleaseAccess(pWriteAcc);
- }
-
- rSource.ReleaseAccess(pReadAcc);
- delete[] pWeights;
- delete[] pCount;
- delete[] pPixels;
-
- if(bResult)
- {
- return true;
- }
- }
-
- return false;
- }
-
- bool ImplScaleConvolutionVer(
- Bitmap& rSource,
- Bitmap& rTarget,
- const double& rScaleY,
- const Kernel& aKernel)
- {
- // Do vertical filtering
- OSL_ENSURE(rScaleY > 0.0, "Error in scaling: Mirror given in
non-mirror-capable method (!)");
- const sal_uInt32 nHeight(rSource.GetSizePixel().Height());
- const sal_uInt32 nNewHeight(FRound(nHeight * rScaleY));
-
- if(nHeight == nNewHeight)
- {
- return true;
- }
-
- BitmapReadAccess* pReadAcc = rSource.AcquireReadAccess();
-
- if(pReadAcc)
- {
- double* pWeights = 0;
- sal_uInt32* pPixels = 0;
- sal_uInt32* pCount = 0;
- sal_uInt32 aNumberOfContributions(0);
-
- const sal_uInt32 nWidth(rSource.GetSizePixel().Width());
- ImplCalculateContributions(nHeight, nNewHeight,
aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
- rTarget = Bitmap(Size(nWidth, nNewHeight), 24);
- BitmapWriteAccess* pWriteAcc = rTarget.AcquireWriteAccess();
- bool bResult(0 != pWriteAcc);
-
- if(pWriteAcc)
- {
- for(sal_uInt32 x(0); x < nWidth; x++)
- {
- for(sal_uInt32 y(0); y < nNewHeight; y++)
- {
- const sal_uInt32 aBaseIndex(y *
aNumberOfContributions);
- double aSum(0.0);
- double aValueRed(0.0);
- double aValueGreen(0.0);
- double aValueBlue(0.0);
-
- for(sal_uInt32 j(0); j < pCount[y]; j++)
- {
- const sal_uInt32 aIndex(aBaseIndex + j);
- const double aWeight(pWeights[aIndex]);
- BitmapColor aColor;
-
- aSum += aWeight;
-
- if(pReadAcc->HasPalette())
- {
- aColor =
pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(pPixels[aIndex], x));
- }
- else
- {
- aColor = pReadAcc->GetPixel(pPixels[aIndex],
x);
- }
-
- aValueRed += aWeight * aColor.GetRed();
- aValueGreen += aWeight * aColor.GetGreen();
- aValueBlue += aWeight * aColor.GetBlue();
- }
-
- const BitmapColor aResultColor(
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueRed / aSum), 0, 255)),
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueGreen / aSum), 0, 255)),
- static_cast< sal_uInt8 >(MinMax(static_cast<
sal_Int32 >(aValueBlue / aSum), 0, 255)));
-
- if(pWriteAcc->HasPalette())
- {
- pWriteAcc->SetPixelIndex(y, x, static_cast<
sal_uInt8 >(pWriteAcc->GetBestPaletteIndex(aResultColor)));
- }
- else
- {
- pWriteAcc->SetPixel(y, x, aResultColor);
- }
- }
- }
- }
-
- rTarget.ReleaseAccess(pWriteAcc);
- rSource.ReleaseAccess(pReadAcc);
-
- delete[] pWeights;
- delete[] pCount;
- delete[] pPixels;
-
- if(bResult)
- {
- return true;
- }
- }
-
- return false;
- }
+ void ImplCalculateContributions(
+ const sal_uInt32 aSourceSize,
+ const sal_uInt32 aDestinationSize,
+ sal_uInt32& aNumberOfContributions,
+ double*& pWeights,
+ sal_uInt32*& pPixels,
+ sal_uInt32*& pCount,
+ const Kernel& aKernel)
+ {
+ const double fSamplingRadius(aKernel.GetWidth());
+ const double fScale(aDestinationSize / static_cast< double
>(aSourceSize));
+ const double fScaledRadius((fScale < 1.0) ? fSamplingRadius /
fScale : fSamplingRadius);
+ const double fFilterFactor((fScale < 1.0) ? fScale : 1.0);
+
+ aNumberOfContributions = (static_cast< sal_uInt32
>(fabs(ceil(fScaledRadius))) * 2) + 1;
+ const sal_uInt32 nAllocSize(aDestinationSize *
aNumberOfContributions);
+ pWeights = new double[nAllocSize];
+ pPixels = new sal_uInt32[nAllocSize];
+ pCount = new sal_uInt32[aDestinationSize];
+
+ for(sal_uInt32 i(0); i < aDestinationSize; i++)
+ {
+ const sal_uInt32 aIndex(i * aNumberOfContributions);
+ const double aCenter(i / fScale);
+ const sal_Int32 aLeft(static_cast< sal_Int32
>(floor(aCenter - fScaledRadius)));
+ const sal_Int32 aRight(static_cast< sal_Int32
>(ceil(aCenter + fScaledRadius)));
+ sal_uInt32 aCurrentCount(0);
+
+ for(sal_Int32 j(aLeft); j <= aRight; j++)
+ {
+ const double
aWeight(aKernel.Calculate(fFilterFactor * (aCenter - static_cast< double>(j))));
+
+ // Reduce calculations with ignoring weights of
0.0
+ if(fabs(aWeight) < 0.0001)
+ {
+ continue;
+ }
+
+ // Handling on edges
+ const sal_uInt32 aPixelIndex(MinMax(j, 0,
aSourceSize - 1));
+ const sal_uInt32 nIndex(aIndex + aCurrentCount);
+
+ pWeights[nIndex] = aWeight;
+ pPixels[nIndex] = aPixelIndex;
+
+ aCurrentCount++;
+ }
+
+ pCount[i] = aCurrentCount;
+ }
+ }
+
+ sal_Bool ImplScaleConvolutionHor(
+ Bitmap& rSource,
+ Bitmap& rTarget,
+ const double& rScaleX,
+ const Kernel& aKernel)
+ {
+ // Do horizontal filtering
+ OSL_ENSURE(rScaleX > 0.0, "Error in scaling: Mirror given in
non-mirror-capable method (!)");
+ const sal_uInt32 nWidth(rSource.GetSizePixel().Width());
+ const sal_uInt32 nNewWidth(FRound(nWidth * rScaleX));
+
+ if(nWidth == nNewWidth)
+ {
+ return true;
+ }
+
+ BitmapReadAccess* pReadAcc = rSource.AcquireReadAccess();
+
+ if(pReadAcc)
+ {
+ double* pWeights = 0;
+ sal_uInt32* pPixels = 0;
+ sal_uInt32* pCount = 0;
+ sal_uInt32 aNumberOfContributions(0);
+
+ const sal_uInt32
nHeight(rSource.GetSizePixel().Height());
+ ImplCalculateContributions(nWidth, nNewWidth,
aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
+ rTarget = Bitmap(Size(nNewWidth, nHeight), 24);
+ BitmapWriteAccess* pWriteAcc =
rTarget.AcquireWriteAccess();
+ bool bResult(0 != pWriteAcc);
+
+ if(bResult)
+ {
+ for(sal_uInt32 y(0); y < nHeight; y++)
+ {
+ for(sal_uInt32 x(0); x < nNewWidth; x++)
+ {
+ const sal_uInt32 aBaseIndex(x *
aNumberOfContributions);
+ double aSum(0.0);
+ double aValueRed(0.0);
+ double aValueGreen(0.0);
+ double aValueBlue(0.0);
+
+ for(sal_uInt32 j(0); j <
pCount[x]; j++)
+ {
+ const sal_uInt32
aIndex(aBaseIndex + j);
+ const double
aWeight(pWeights[aIndex]);
+ BitmapColor aColor;
+
+ aSum += aWeight;
+
+
if(pReadAcc->HasPalette())
+ {
+ aColor =
pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(y, pPixels[aIndex]));
+ }
+ else
+ {
+ aColor =
pReadAcc->GetPixel(y, pPixels[aIndex]);
+ }
+
+ aValueRed += aWeight *
aColor.GetRed();
+ aValueGreen += aWeight
* aColor.GetGreen();
+ aValueBlue += aWeight *
aColor.GetBlue();
+ }
+
+ const BitmapColor aResultColor(
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueRed / aSum), 0, 255)),
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueGreen / aSum), 0, 255)),
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueBlue / aSum), 0, 255)));
+
+ pWriteAcc->SetPixel(y, x,
aResultColor);
+ }
+ }
+
+ rTarget.ReleaseAccess(pWriteAcc);
+ }
+
+ rSource.ReleaseAccess(pReadAcc);
+ delete[] pWeights;
+ delete[] pCount;
+ delete[] pPixels;
+
+ if(bResult)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool ImplScaleConvolutionVer(
+ Bitmap& rSource,
+ Bitmap& rTarget,
+ const double& rScaleY,
+ const Kernel& aKernel)
+ {
+ // Do vertical filtering
+ OSL_ENSURE(rScaleY > 0.0, "Error in scaling: Mirror given in
non-mirror-capable method (!)");
+ const sal_uInt32 nHeight(rSource.GetSizePixel().Height());
+ const sal_uInt32 nNewHeight(FRound(nHeight * rScaleY));
+
+ if(nHeight == nNewHeight)
+ {
+ return true;
+ }
+
+ BitmapReadAccess* pReadAcc = rSource.AcquireReadAccess();
+
+ if(pReadAcc)
+ {
+ double* pWeights = 0;
+ sal_uInt32* pPixels = 0;
+ sal_uInt32* pCount = 0;
+ sal_uInt32 aNumberOfContributions(0);
+
+ const sal_uInt32 nWidth(rSource.GetSizePixel().Width());
+ ImplCalculateContributions(nHeight, nNewHeight,
aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
+ rTarget = Bitmap(Size(nWidth, nNewHeight), 24);
+ BitmapWriteAccess* pWriteAcc =
rTarget.AcquireWriteAccess();
+ bool bResult(0 != pWriteAcc);
+
+ if(pWriteAcc)
+ {
+ for(sal_uInt32 x(0); x < nWidth; x++)
+ {
+ for(sal_uInt32 y(0); y < nNewHeight;
y++)
+ {
+ const sal_uInt32 aBaseIndex(y *
aNumberOfContributions);
+ double aSum(0.0);
+ double aValueRed(0.0);
+ double aValueGreen(0.0);
+ double aValueBlue(0.0);
+
+ for(sal_uInt32 j(0); j <
pCount[y]; j++)
+ {
+ const sal_uInt32
aIndex(aBaseIndex + j);
+ const double
aWeight(pWeights[aIndex]);
+ BitmapColor aColor;
+
+ aSum += aWeight;
+
+
if(pReadAcc->HasPalette())
+ {
+ aColor =
pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(pPixels[aIndex], x));
+ }
+ else
+ {
+ aColor =
pReadAcc->GetPixel(pPixels[aIndex], x);
+ }
+
+ aValueRed += aWeight *
aColor.GetRed();
+ aValueGreen += aWeight
* aColor.GetGreen();
+ aValueBlue += aWeight *
aColor.GetBlue();
+ }
+
+ const BitmapColor aResultColor(
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueRed / aSum), 0, 255)),
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueGreen / aSum), 0, 255)),
+ static_cast< sal_uInt8
>(MinMax(static_cast< sal_Int32 >(aValueBlue / aSum), 0, 255)));
+
+ if(pWriteAcc->HasPalette())
+ {
+
pWriteAcc->SetPixelIndex(y, x, static_cast< sal_uInt8
>(pWriteAcc->GetBestPaletteIndex(aResultColor)));
+ }
+ else
+ {
+ pWriteAcc->SetPixel(y,
x, aResultColor);
+ }
+ }
+ }
+ }
+
+ rTarget.ReleaseAccess(pWriteAcc);
+ rSource.ReleaseAccess(pReadAcc);
+
+ delete[] pWeights;
+ delete[] pCount;
+ delete[] pPixels;
+
+ if(bResult)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
// #121233# Added BMP_SCALE_LANCZOS, BMP_SCALE_BICUBIC, BMP_SCALE_BILINEAR and
-// BMP_SCALE_BOX derived from the original commit from Toma� Vajngerl (see
-// bugzilla task for deitails) Thanks!
-sal_Bool Bitmap::ImplScaleConvolution(
- const double& rScaleX,
- const double& rScaleY,
- const Kernel& aKernel)
+// BMP_SCALE_BOX derived from the original commit from Tomaž Vajngerl (see
+// Bugzilla task for details) Thanks!
+sal_Bool Bitmap::ImplScaleConvolution(
+ const double& rScaleX,
+ const double& rScaleY,
+ const Kernel& aKernel)
{
- const bool bMirrorHor(rScaleX < 0.0);
- const bool bMirrorVer(rScaleY < 0.0);
- const double fScaleX(bMirrorHor ? -rScaleX : rScaleX);
- const double fScaleY(bMirrorVer ? -rScaleY : rScaleY);
- const sal_uInt32 nWidth(GetSizePixel().Width());
- const sal_uInt32 nHeight(GetSizePixel().Height());
- const sal_uInt32 nNewWidth(FRound(nWidth * fScaleX));
- const sal_uInt32 nNewHeight(FRound(nHeight * fScaleY));
- const bool bScaleHor(nWidth != nNewWidth);
- const bool bScaleVer(nHeight != nNewHeight);
- const bool bMirror(bMirrorHor || bMirrorVer);
-
- if(!bMirror && !bScaleHor && !bScaleVer)
- {
- return true;
- }
-
- bool bResult(true);
- sal_uInt32 nMirrorFlags(BMP_MIRROR_NONE);
- bool bMirrorAfter(false);
-
- if(bMirror)
- {
- if(bMirrorHor)
- {
- nMirrorFlags |= BMP_MIRROR_HORZ;
- }
-
- if(bMirrorVer)
- {
- nMirrorFlags |= BMP_MIRROR_VERT;
- }
-
- const sal_uInt32 nStartSize(nWidth * nHeight);
- const sal_uInt32 nEndSize(nNewWidth * nNewHeight);
-
- bMirrorAfter = nStartSize > nEndSize;
-
- if(!bMirrorAfter)
- {
- bResult = Mirror(nMirrorFlags);
- }
- }
-
- Bitmap aResult;
-
- if(bResult)
- {
- const sal_uInt32 nInBetweenSizeHorFirst(nHeight * nNewWidth);
- const sal_uInt32 nInBetweenSizeVerFirst(nNewHeight * nWidth);
- Bitmap aSource(*this);
-
- if(nInBetweenSizeHorFirst < nInBetweenSizeVerFirst)
- {
- if(bScaleHor)
- {
- bResult = ImplScaleConvolutionHor(aSource, aResult, fScaleX,
aKernel);
- }
-
- if(bResult && bScaleVer)
- {
- if(bScaleHor)
- {
- // copy partial result, independent of color depth
- aSource = aResult;
- }
-
- bResult = ImplScaleConvolutionVer(aSource, aResult, fScaleY,
aKernel);
- }
- }
- else
- {
- if(bScaleVer)
- {
- bResult = ImplScaleConvolutionVer(aSource, aResult, fScaleY,
aKernel);
- }
-
- if(bResult && bScaleHor)
- {
- if(bScaleVer)
- {
- // copy partial result, independent of color depth
- aSource = aResult;
- }
-
- bResult = ImplScaleConvolutionHor(aSource, aResult, fScaleX,
aKernel);
- }
- }
- }
-
- if(bResult && bMirrorAfter)
- {
- bResult = aResult.Mirror(nMirrorFlags);
- }
-
- if(bResult)
- {
- ImplAdaptBitCount(aResult);
- *this = aResult;
- }
-
- return bResult;
+ const bool bMirrorHor(rScaleX < 0.0);
+ const bool bMirrorVer(rScaleY < 0.0);
+ const double fScaleX(bMirrorHor ? -rScaleX : rScaleX);
+ const double fScaleY(bMirrorVer ? -rScaleY : rScaleY);
+ const sal_uInt32 nWidth(GetSizePixel().Width());
+ const sal_uInt32 nHeight(GetSizePixel().Height());
+ const sal_uInt32 nNewWidth(FRound(nWidth * fScaleX));
+ const sal_uInt32 nNewHeight(FRound(nHeight * fScaleY));
+ const bool bScaleHor(nWidth != nNewWidth);
+ const bool bScaleVer(nHeight != nNewHeight);
+ const bool bMirror(bMirrorHor || bMirrorVer);
+
+ if(!bMirror && !bScaleHor && !bScaleVer)
+ {
+ return true;
+ }
+
+ bool bResult(true);
+ sal_uInt32 nMirrorFlags(BMP_MIRROR_NONE);
+ bool bMirrorAfter(false);
+
+ if(bMirror)
+ {
+ if(bMirrorHor)
+ {
+ nMirrorFlags |= BMP_MIRROR_HORZ;
+ }
+
+ if(bMirrorVer)
+ {
+ nMirrorFlags |= BMP_MIRROR_VERT;
+ }
+
+ const sal_uInt32 nStartSize(nWidth * nHeight);
+ const sal_uInt32 nEndSize(nNewWidth * nNewHeight);
+
+ bMirrorAfter = nStartSize > nEndSize;
+
+ if(!bMirrorAfter)
+ {
+ bResult = Mirror(nMirrorFlags);
+ }
+ }
+
+ Bitmap aResult;
+
+ if(bResult)
+ {
+ const sal_uInt32 nInBetweenSizeHorFirst(nHeight * nNewWidth);
+ const sal_uInt32 nInBetweenSizeVerFirst(nNewHeight * nWidth);
+ Bitmap aSource(*this);
+
+ if(nInBetweenSizeHorFirst < nInBetweenSizeVerFirst)
+ {
+ if(bScaleHor)
+ {
+ bResult = ImplScaleConvolutionHor(aSource,
aResult, fScaleX, aKernel);
+ }
+
+ if(bResult && bScaleVer)
+ {
+ if(bScaleHor)
+ {
+ // copy partial result, independent of
color depth
+ aSource = aResult;
+ }
+
+ bResult = ImplScaleConvolutionVer(aSource,
aResult, fScaleY, aKernel);
+ }
+ }
+ else
+ {
+ if(bScaleVer)
+ {
+ bResult = ImplScaleConvolutionVer(aSource,
aResult, fScaleY, aKernel);
+ }
+
+ if(bResult && bScaleHor)
+ {
+ if(bScaleVer)
+ {
+ // copy partial result, independent of
color depth
+ aSource = aResult;
+ }
+
+ bResult = ImplScaleConvolutionHor(aSource,
aResult, fScaleX, aKernel);
+ }
+ }
+ }
+
+ if(bResult && bMirrorAfter)
+ {
+ bResult = aResult.Mirror(nMirrorFlags);
+ }
+
+ if(bResult)
+ {
+ ImplAdaptBitCount(aResult);
+ *this = aResult;
+ }
+
+ return bResult;
}
// ------------------------------------------------------------------------
@@ -2959,11 +2959,11 @@ extern "C" int __LOADONCALLAPI ImplPopularCmpFnc( const
void* p1, const void* p2
if( ( (PopularColorCount*) p1 )->mnCount < ( (PopularColorCount*) p2
)->mnCount )
nRet = 1;
- else if( ( (PopularColorCount*) p1 )->mnCount == ( (PopularColorCount*)
p2 )->mnCount )
+ else if( ( (PopularColorCount*) p1 )->mnCount == ( (PopularColorCount*)
p2 )->mnCount )
nRet = 0;
else
nRet = -1;
-
+
return nRet;
}
@@ -3000,16 +3000,16 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16
nColCount )
rtl_zeroMemory( pCountTable, nTotalColors * sizeof(
PopularColorCount ) );
for( nR = 0, nIndex = 0; nR < 256; nR += nColorOffset )
- {
+ {
for( nG = 0; nG < 256; nG += nColorOffset )
- {
+ {
for( nB = 0; nB < 256; nB += nColorOffset )
- {
+ {
pCountTable[ nIndex ].mnIndex = nIndex;
- nIndex++;
- }
- }
- }
+ nIndex++;
+ }
+ }
+ }
if( pRAcc->HasPalette() )
{
@@ -3019,7 +3019,7 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
const BitmapColor& rCol =
pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) );
pCountTable[ ( ( ( (sal_uInt32)
rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
- ( ( (
(sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
+ ( ( (
(sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
( (
(sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++;
}
}
@@ -3032,8 +3032,8 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
const BitmapColor aCol(
pRAcc->GetPixel( nY, nX ) );
pCountTable[ ( ( ( (sal_uInt32)
aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
- ( ( (
(sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
- ( (
(sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++;
+ ( ( (
(sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) |
+ ( (
(sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++;
}
}
}
@@ -3041,11 +3041,11 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16
nColCount )
BitmapPalette aNewPal( nColCount );
qsort( pCountTable, nTotalColors, sizeof( PopularColorCount ),
ImplPopularCmpFnc );
-
+
for( sal_uInt16 n = 0; n < nColCount; n++ )
{
const PopularColorCount& rPop = pCountTable[ n ];
- aNewPal[ n ] = BitmapColor( (sal_uInt8) ( (
rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ),
+ aNewPal[ n ] = BitmapColor( (sal_uInt8) ( (
rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ),
(sal_uInt8) ( ( ( rPop.mnIndex >> nLeftShiftBits1 ) & ( nColorsPerComponent - 1
) ) << nRightShiftBits ),
(sal_uInt8) ( ( rPop.mnIndex & ( nColorsPerComponent - 1 ) ) << nRightShiftBits
) );
}
@@ -3071,7 +3071,7 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
const BitmapColor& rCol =
pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) );
aDstCol.SetIndex( pIndexMap[ (
( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
-
( ( ( (sal_uInt32) rCol.GetGreen() ) >>
nRightShiftBits ) << nLeftShiftBits1 ) |
+
( ( ( (sal_uInt32) rCol.GetGreen() ) >>
nRightShiftBits ) << nLeftShiftBits1 ) |
( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits )
] );
pWAcc->SetPixel( nY, nX,
aDstCol );
}
@@ -3085,7 +3085,7 @@ sal_Bool Bitmap::ImplReducePopular( sal_uInt16 nColCount )
{
const BitmapColor aCol(
pRAcc->GetPixel( nY, nX ) );
aDstCol.SetIndex( pIndexMap[ (
( ( (sal_uInt32) aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) |
-
( ( ( (sal_uInt32) aCol.GetGreen() ) >>
nRightShiftBits ) << nLeftShiftBits1 ) |
+
( ( ( (sal_uInt32) aCol.GetGreen() ) >>
nRightShiftBits ) << nLeftShiftBits1 ) |
( ( (sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits )
] );
pWAcc->SetPixel( nY, nX,
aDstCol );
}
@@ -3174,7 +3174,7 @@ sal_Bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
// create palette via median cut
BitmapPalette aPal( pWAcc->GetPaletteEntryCount() );
- ImplMedianCut( pColBuf, aPal, 0, 31, 0, 31, 0, 31,
+ ImplMedianCut( pColBuf, aPal, 0, 31, 0, 31, 0, 31,
nColCount, nWidth * nHeight,
nIndex );
// do mapping of colors to palette
@@ -3207,7 +3207,7 @@ sal_Bool Bitmap::ImplReduceMedian( sal_uInt16 nColCount )
// ------------------------------------------------------------------------
-void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal,
+void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal,
long nR1, long nR2,
long nG1, long nG2, long nB1, long nB2,
long nColors, long
nPixels, long& rIndex )
{
@@ -3216,7 +3216,7 @@ void Bitmap::ImplMedianCut( sal_uLong* pColBuf,
BitmapPalette& rPal,
BitmapColor aCol;
const long nRLen = nR2 - nR1;
- const long nGLen = nG2 - nG1;
+ const long nGLen = nG2 - nG1;
const long nBLen = nB2 - nB1;
long nR, nG, nB;
sal_uLong* pBuf = pColBuf;
@@ -3362,7 +3362,7 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short
nContrastPercent,
sal_Bool bRet = sal_False;
// nothing to do => return quickly
- if( !nLuminancePercent && !nContrastPercent &&
+ if( !nLuminancePercent && !nContrastPercent &&
!nChannelRPercent && !nChannelGPercent && !nChannelBPercent &&
( fGamma == 1.0 ) && !bInvert )
{
@@ -3382,7 +3382,7 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short
nContrastPercent,
sal_uInt8* cMapB = new sal_uInt8[
256 ];
long nX, nY;
double fM, fROff, fGOff, fBOff, fOff;
-
+
// calculate slope
if( nContrastPercent >= 0 )
fM = 128.0 / ( 128.0 - 1.27 * MinMax(
nContrastPercent, 0L, 100L ) );
@@ -3392,7 +3392,7 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short
nContrastPercent,
// total offset = luminance offset + contrast offset
fOff = MinMax( nLuminancePercent, -100L, 100L ) * 2.55
+ 128.0 - fM * 128.0;
- // channel offset = channel offset + total offset
+ // channel offset = channel offset + total offset
fROff = nChannelRPercent * 2.55 + fOff;
fGOff = nChannelGPercent * 2.55 + fOff;
fBOff = nChannelBPercent * 2.55 + fOff;
@@ -3430,7 +3430,7 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short
nContrastPercent,
for( sal_uInt16 i = 0, nCount =
pAcc->GetPaletteEntryCount(); i < nCount; i++ )
{
- const BitmapColor& rCol =
pAcc->GetPaletteColor( i );
+ const BitmapColor& rCol =
pAcc->GetPaletteColor( i );
aNewCol.SetRed( cMapR[ rCol.GetRed() ]
);
aNewCol.SetGreen( cMapG[
rCol.GetGreen() ] );
aNewCol.SetBlue( cMapB[ rCol.GetBlue()
] );
@@ -3490,3 +3490,5 @@ sal_Bool Bitmap::Adjust( short nLuminancePercent, short
nContrastPercent,
return bRet;
}
+
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/vcl/source/gdi/bitmap4.cxx b/main/vcl/source/gdi/bitmap4.cxx
index d06aa637c0..407a2e5439 100644
--- a/main/vcl/source/gdi/bitmap4.cxx
+++ b/main/vcl/source/gdi/bitmap4.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -139,13 +139,13 @@ sal_Bool Bitmap::ImplConvolute3( const long* pMatrix,
long nDivisor,
// create column LUT
for( i = 0; i < nWidth2; i++ )
pColm[ i ] = ( i > 0 ) ? ( i - 1 ) : 0;
-
+
pColm[ nWidth + 1 ] = pColm[ nWidth ];
// create row LUT
for( i = 0; i < nHeight2; i++ )
pRows[ i ] = ( i > 0 ) ? ( i - 1 ) : 0;
-
+
pRows[ nHeight + 1 ] = pRows[ nHeight ];
// read first three rows of bitmap color
@@ -282,24 +282,24 @@ sal_Bool Bitmap::ImplMedianFilter( const BmpFilterParam*
/*pFilterParam*/, const
// create column LUT
for( i = 0; i < nWidth2; i++ )
pColm[ i ] = ( i > 0 ) ? ( i - 1 ) : 0;
-
+
pColm[ nWidth + 1 ] = pColm[ nWidth ];
// create row LUT
for( i = 0; i < nHeight2; i++ )
pRows[ i ] = ( i > 0 ) ? ( i - 1 ) : 0;
-
+
pRows[ nHeight + 1 ] = pRows[ nHeight ];
// read first three rows of bitmap color
if (nHeight2 > 2)
{
- for( i = 0; i < nWidth2; i++ )
- {
- pColRow1[ i ] = pReadAcc->GetColor( pRows[
0 ], pColm[ i ] );
- pColRow2[ i ] = pReadAcc->GetColor( pRows[
1 ], pColm[ i ] );
- pColRow3[ i ] = pReadAcc->GetColor( pRows[
2 ], pColm[ i ] );
- }
+ for( i = 0; i < nWidth2; i++ )
+ {
+ pColRow1[ i ] = pReadAcc->GetColor(
pRows[ 0 ], pColm[ i ] );
+ pColRow2[ i ] = pReadAcc->GetColor(
pRows[ 1 ], pColm[ i ] );
+ pColRow3[ i ] = pReadAcc->GetColor(
pRows[ 2 ], pColm[ i ] );
+ }
}
// do median filtering
@@ -310,7 +310,7 @@ sal_Bool Bitmap::ImplMedianFilter( const BmpFilterParam*
/*pFilterParam*/, const
nR1 = ( pColor = pRowTmp1 + nX
)->GetRed(), nG1 = pColor->GetGreen(), nB1 = pColor->GetBlue();
nR2 = ( ++pColor )->GetRed(), nG2 =
pColor->GetGreen(), nB2 = pColor->GetBlue();
nR3 = ( ++pColor )->GetRed(), nG3 =
pColor->GetGreen(), nB3 = pColor->GetBlue();
-
+
nR4 = ( pColor = pRowTmp2 + nX
)->GetRed(), nG4 = pColor->GetGreen(), nB4 = pColor->GetBlue();
nR5 = ( ++pColor )->GetRed(), nG5 =
pColor->GetGreen(), nB5 = pColor->GetBlue();
nR6 = ( ++pColor )->GetRed(), nG6 =
pColor->GetGreen(), nB6 = pColor->GetBlue();
@@ -318,22 +318,22 @@ sal_Bool Bitmap::ImplMedianFilter( const BmpFilterParam*
/*pFilterParam*/, const
nR7 = ( pColor = pRowTmp3 + nX
)->GetRed(), nG7 = pColor->GetGreen(), nB7 = pColor->GetBlue();
nR8 = ( ++pColor )->GetRed(), nG8 =
pColor->GetGreen(), nB8 = pColor->GetBlue();
nR9 = ( ++pColor )->GetRed(), nG9 =
pColor->GetGreen(), nB9 = pColor->GetBlue();
-
+
MNMX6( nR1, nR2, nR3, nR4, nR5, nR6 );
- MNMX5( nR7, nR2, nR3, nR4, nR5 );
- MNMX4( nR8, nR2, nR3, nR4 );
- MNMX3( nR9, nR2, nR3 );
+ MNMX5( nR7, nR2, nR3, nR4, nR5 );
+ MNMX4( nR8, nR2, nR3, nR4 );
+ MNMX3( nR9, nR2, nR3 );
MNMX6( nG1, nG2, nG3, nG4, nG5, nG6 );
- MNMX5( nG7, nG2, nG3, nG4, nG5 );
- MNMX4( nG8, nG2, nG3, nG4 );
- MNMX3( nG9, nG2, nG3 );
+ MNMX5( nG7, nG2, nG3, nG4, nG5 );
+ MNMX4( nG8, nG2, nG3, nG4 );
+ MNMX3( nG9, nG2, nG3 );
MNMX6( nB1, nB2, nB3, nB4, nB5, nB6 );
- MNMX5( nB7, nB2, nB3, nB4, nB5 );
- MNMX4( nB8, nB2, nB3, nB4 );
- MNMX3( nB9, nB2, nB3 );
-
+ MNMX5( nB7, nB2, nB3, nB4, nB5 );
+ MNMX4( nB8, nB2, nB3, nB4 );
+ MNMX3( nB9, nB2, nB3 );
+
// set destination color
pWriteAcc->SetPixel( nY, nX,
BitmapColor( (sal_uInt8) nR2, (sal_uInt8) nG2, (sal_uInt8) nB2 ) );
}
@@ -391,7 +391,7 @@ sal_Bool Bitmap::ImplSobelGrey( const BmpFilterParam*
/*pFilterParam*/, const Li
bRet = sal_False;
BitmapReadAccess* pReadAcc = AcquireReadAccess();
-
+
if( pReadAcc )
{
Bitmap aNewBmp(
GetSizePixel(), 8, &pReadAcc->GetPalette() );
@@ -519,7 +519,7 @@ sal_Bool Bitmap::ImplEmbossGrey( const BmpFilterParam*
pFilterParam, const Link*
bRet = sal_False;
BitmapReadAccess* pReadAcc = AcquireReadAccess();
-
+
if( pReadAcc )
{
Bitmap aNewBmp(
GetSizePixel(), 8, &pReadAcc->GetPalette() );
@@ -584,7 +584,7 @@ sal_Bool Bitmap::ImplEmbossGrey( const BmpFilterParam*
pFilterParam, const Link*
const double fGrey =
nDotL / sqrt( (double)(nNx * nNx + nNy * nNy + nZ2) );
aGrey.SetIndex(
(sal_uInt8) VOS_BOUND( fGrey, 0, 255 ) );
}
-
+
pWriteAcc->SetPixel( nY, nX,
aGrey );
if( nX < ( nWidth - 1 ) )
@@ -628,10 +628,10 @@ sal_Bool Bitmap::ImplSolarize( const BmpFilterParam*
pFilterParam, const Link* /
{
sal_Bool bRet = sal_False;
BitmapWriteAccess* pWriteAcc = AcquireWriteAccess();
-
+
if( pWriteAcc )
{
- const sal_uInt8 cThreshold = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_SOLARIZE ) ?
+ const sal_uInt8 cThreshold = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_SOLARIZE ) ?
pFilterParam->mcSolarGreyThreshold : 128;
if( pWriteAcc->HasPalette() )
@@ -658,7 +658,7 @@ sal_Bool Bitmap::ImplSolarize( const BmpFilterParam*
pFilterParam, const Link* /
for( long nX = 0; nX < nWidth; nX++ )
{
aCol = pWriteAcc->GetPixel( nY, nX );
-
+
if( aCol.GetLuminance() >= cThreshold )
pWriteAcc->SetPixel( nY, nX,
aCol.Invert() );
}
@@ -678,11 +678,11 @@ sal_Bool Bitmap::ImplSepia( const BmpFilterParam*
pFilterParam, const Link* /*pP
{
BitmapReadAccess* pReadAcc = AcquireReadAccess();
sal_Bool bRet = sal_False;
-
+
if( pReadAcc )
{
- long nSepiaPercent = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_SEPIA ) ?
-
pFilterParam->mcSolarGreyThreshold : 10;
+ long nSepiaPercent = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_SEPIA ) ?
+
pFilterParam->mcSolarGreyThreshold : 10;
const long nSepia = 10000 - 100 * VOS_BOUND(
nSepiaPercent, 0, 100 );
BitmapPalette aSepiaPal( 256 );
@@ -763,10 +763,10 @@ sal_Bool Bitmap::ImplSepia( const BmpFilterParam*
pFilterParam, const Link* /*pP
sal_Bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam, const Link*
/*pProgress*/ )
{
- sal_uLong nTileWidth = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_MOSAIC ) ?
-
pFilterParam->maMosaicTileSize.mnTileWidth : 4;
- sal_uLong nTileHeight = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_MOSAIC ) ?
-
pFilterParam->maMosaicTileSize.mnTileHeight : 4;
+ sal_uLong nTileWidth = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_MOSAIC ) ?
+
pFilterParam->maMosaicTileSize.mnTileWidth : 4;
+ sal_uLong nTileHeight = ( pFilterParam &&
pFilterParam->meFilter == BMP_FILTER_MOSAIC ) ?
+
pFilterParam->maMosaicTileSize.mnTileHeight : 4;
sal_Bool bRet = sal_False;
if( !nTileWidth )
@@ -792,7 +792,7 @@ sal_Bool Bitmap::ImplMosaic( const BmpFilterParam*
pFilterParam, const Link* /*p
pReadAcc = AcquireReadAccess();
pWriteAcc = pNewBmp->AcquireWriteAccess();
}
-
+
if( pReadAcc && pWriteAcc )
{
BitmapColor aCol;
@@ -812,7 +812,7 @@ sal_Bool Bitmap::ImplMosaic( const BmpFilterParam*
pFilterParam, const Link* /*p
if( nX2 >= nWidth )
nX2 = nWidth - 1;
-
+
fArea_1 = 1.0 / ( ( nX2 - nX1 + 1 ) * ( nY2 -
nY1 + 1 ) );
if( !pNewBmp )
@@ -914,7 +914,7 @@ sal_Bool Bitmap::ImplMosaic( const BmpFilterParam*
pFilterParam, const Link* /*p
}
else
bRet = sal_True;
-
+
return bRet;
}
@@ -934,11 +934,11 @@ extern "C" int __LOADONCALLAPI ImplPopArtCmpFnc( const
void* p1, const void* p2
if( ( (PopArtEntry*) p1 )->mnCount < ( (PopArtEntry*) p2 )->mnCount )
nRet = 1;
- else if( ( (PopArtEntry*) p1 )->mnCount == ( (PopArtEntry*) p2
)->mnCount )
+ else if( ( (PopArtEntry*) p1 )->mnCount == ( (PopArtEntry*) p2
)->mnCount )
nRet = 0;
else
nRet = -1;
-
+
return nRet;
}
@@ -976,7 +976,7 @@ sal_Bool Bitmap::ImplPopArt( const BmpFilterParam*
/*pFilterParam*/, const Link*
// sort table
qsort( pPopArtTable, nEntryCount, sizeof( PopArtEntry
), ImplPopArtCmpFnc );
-
+
// get last used entry
sal_uLong nFirstEntry;
sal_uLong nLastEntry = 0;
@@ -989,7 +989,7 @@ sal_Bool Bitmap::ImplPopArt( const BmpFilterParam*
/*pFilterParam*/, const Link*
const BitmapColor aFirstCol(
pWriteAcc->GetPaletteColor( sal::static_int_cast<sal_uInt16>(pPopArtTable[ 0
].mnIndex) ) );
for( nFirstEntry = 0; nFirstEntry < nLastEntry;
nFirstEntry++ )
{
- pWriteAcc->SetPaletteColor(
sal::static_int_cast<sal_uInt16>(pPopArtTable[ nFirstEntry ].mnIndex),
+ pWriteAcc->SetPaletteColor(
sal::static_int_cast<sal_uInt16>(pPopArtTable[ nFirstEntry ].mnIndex),
pWriteAcc->GetPaletteColor(
sal::static_int_cast<sal_uInt16>(pPopArtTable[ nFirstEntry + 1 ].mnIndex) ) );
}
pWriteAcc->SetPaletteColor(
sal::static_int_cast<sal_uInt16>(pPopArtTable[ nLastEntry ].mnIndex), aFirstCol
);
@@ -1004,5 +1004,4 @@ sal_Bool Bitmap::ImplPopArt( const BmpFilterParam*
/*pFilterParam*/, const Link*
return bRet;
}
-//
-----------------------------------------------------------------------------
-// eof
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/vcl/source/gdi/bitmapex.cxx b/main/vcl/source/gdi/bitmapex.cxx
index 4150e8e06c..fff95c4fa8 100644
--- a/main/vcl/source/gdi/bitmapex.cxx
+++ b/main/vcl/source/gdi/bitmapex.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,18 +7,20 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
+
+
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
@@ -77,7 +79,7 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc,
Size aSize ) :
}
else if( rBitmapEx.IsTransparent() )
aMask = Bitmap( aSize, rBitmapEx.aMask.GetBitCount() );
-
+
Rectangle aDestRect( Point( 0, 0 ), aSize );
Rectangle aSrcRect( aSrc, aSize );
CopyPixel( aDestRect, aSrcRect, &rBitmapEx );
@@ -95,13 +97,13 @@ BitmapEx::BitmapEx( const ResId& rResId ) :
ResMgr::GetResourceSkipHeader( rResId.SetRT( RSC_BITMAP ), &pResMgr );
pResMgr->ReadLong();
pResMgr->ReadLong();
-
+
const String aFileName( pResMgr->ReadString() );
::rtl::OUString aCurrentSymbolsStyle =
Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
-
+
if( !aImageTree->loadImage( aFileName, aCurrentSymbolsStyle, *this ) )
{
-#ifdef DBG_UTIL
+#ifdef DBG_UTIL
ByteString aErrorStr( "BitmapEx::BitmapEx( const ResId& rResId
): could not load image <" );
DBG_ERROR( ( ( aErrorStr += ByteString( aFileName,
RTL_TEXTENCODING_ASCII_US ) ) += '>' ).GetBuffer() );
#endif
@@ -127,18 +129,18 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap&
rMask ) :
eTransparent ( !rMask ? TRANSPARENT_NONE :
TRANSPARENT_BITMAP ),
bAlpha ( sal_False )
{
- if(!!aBitmap && !!aMask && aBitmap.GetSizePixel() != aMask.GetSizePixel())
- {
- OSL_ENSURE(false, "Mask size differs from Bitmap size, corrected Mask
(!)");
- aMask.Scale(aBitmap.GetSizePixel());
- }
-
- // #105489# Ensure a mask is exactly one bit deep
- if( !!aMask && aMask.GetBitCount() != 1 )
- {
- OSL_TRACE("BitmapEx: forced mask to monochrome");
- aMask.ImplMakeMono( 255 );
- }
+ if(!!aBitmap && !!aMask && aBitmap.GetSizePixel() !=
aMask.GetSizePixel())
+ {
+ OSL_ENSURE(false, "Mask size differs from Bitmap size,
corrected Mask (!)");
+ aMask.Scale(aBitmap.GetSizePixel());
+ }
+
+ // #105489# Ensure a mask is exactly one bit deep
+ if( !!aMask && aMask.GetBitCount() != 1 )
+ {
+ OSL_TRACE("BitmapEx: forced mask to monochrome");
+ aMask.ImplMakeMono( 255 );
+ }
}
// ------------------------------------------------------------------
@@ -150,17 +152,17 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const AlphaMask&
rAlphaMask ) :
eTransparent ( !rAlphaMask ? TRANSPARENT_NONE :
TRANSPARENT_BITMAP ),
bAlpha ( !rAlphaMask ? sal_False : sal_True )
{
- if(!!aBitmap && !!aMask && aBitmap.GetSizePixel() != aMask.GetSizePixel())
- {
- OSL_ENSURE(false, "Alpha size differs from Bitmap size, corrected Mask
(!)");
- aMask.Scale(rBmp.GetSizePixel());
- }
-
- // #i75531# the workaround below can go when
- // X11SalGraphics::drawAlphaBitmap()'s render acceleration
- // can handle the bitmap depth mismatch directly
- if( aBitmap.GetBitCount() < aMask.GetBitCount() )
- aBitmap.Convert( BMP_CONVERSION_24BIT );
+ if(!!aBitmap && !!aMask && aBitmap.GetSizePixel() !=
aMask.GetSizePixel())
+ {
+ OSL_ENSURE(false, "Alpha size differs from Bitmap size,
corrected Mask (!)");
+ aMask.Scale(rBmp.GetSizePixel());
+ }
+
+ // #i75531# the workaround below can go when
+ // X11SalGraphics::drawAlphaBitmap()'s render acceleration
+ // can handle the bitmap depth mismatch directly
+ if( aBitmap.GetBitCount() < aMask.GetBitCount() )
+ aBitmap.Convert( BMP_CONVERSION_24BIT );
}
// ------------------------------------------------------------------
@@ -174,8 +176,8 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Color&
rTransparentColor ) :
{
aMask = aBitmap.CreateMask( aTransparentColor );
- DBG_ASSERT( rBmp.GetSizePixel() == aMask.GetSizePixel(),
- "BitmapEx::BitmapEx(): size mismatch for bitmap and alpha
mask." );
+ DBG_ASSERT( rBmp.GetSizePixel() == aMask.GetSizePixel(),
+ "BitmapEx::BitmapEx(): size mismatch for bitmap
and alpha mask." );
}
// ------------------------------------------------------------------
@@ -302,7 +304,7 @@ Bitmap BitmapEx::GetBitmap( const Color* pTransReplaceColor
) const
BitmapEx BitmapEx::GetColorTransformedBitmapEx( BmpColorMode eColorMode ) const
{
BitmapEx aRet;
-
+
if( BMP_COLOR_HIGHCONTRAST == eColorMode )
{
aRet = *this;
@@ -313,14 +315,14 @@ BitmapEx BitmapEx::GetColorTransformedBitmapEx(
BmpColorMode eColorMode ) const
{
aRet = *this;
aRet.aBitmap = aRet.aBitmap.GetColorTransformedBitmap(
eColorMode );
-
+
if( !aRet.aMask.IsEmpty() )
{
aRet.aMask.CombineSimple( aRet.aBitmap, BMP_COMBINE_OR
);
aRet.aBitmap.Erase( ( BMP_COLOR_MONOCHROME_BLACK ==
eColorMode ) ? COL_BLACK : COL_WHITE );
- DBG_ASSERT( aRet.aBitmap.GetSizePixel() ==
aRet.aMask.GetSizePixel(),
- "BitmapEx::GetColorTransformedBitmapEx(): size
mismatch for bitmap and alpha mask." );
+ DBG_ASSERT( aRet.aBitmap.GetSizePixel() ==
aRet.aMask.GetSizePixel(),
+
"BitmapEx::GetColorTransformedBitmapEx(): size mismatch for bitmap and alpha
mask." );
}
}
@@ -391,10 +393,10 @@ sal_uLong BitmapEx::GetChecksum() const
void BitmapEx::SetSizePixel( const Size& rNewSize, sal_uInt32 nScaleFlag )
{
- if(GetSizePixel() != rNewSize)
- {
- Scale( rNewSize, nScaleFlag );
- }
+ if(GetSizePixel() != rNewSize)
+ {
+ Scale( rNewSize, nScaleFlag );
+ }
}
// ------------------------------------------------------------------
@@ -442,14 +444,14 @@ sal_Bool BitmapEx::Scale( const double& rScaleX, const
double& rScaleY, sal_uInt
bRet = aBitmap.Scale( rScaleX, rScaleY, nScaleFlag );
if( bRet && ( eTransparent == TRANSPARENT_BITMAP ) && !!aMask )
- {
+ {
aMask.Scale( rScaleX, rScaleY, nScaleFlag );
- }
+ }
aBitmapSize = aBitmap.GetSizePixel();
- DBG_ASSERT( !aMask || aBitmap.GetSizePixel() == aMask.GetSizePixel(),
- "BitmapEx::Scale(): size mismatch for bitmap and alpha
mask." );
+ DBG_ASSERT( !aMask || aBitmap.GetSizePixel() ==
aMask.GetSizePixel(),
+ "BitmapEx::Scale(): size mismatch for
bitmap and alpha mask." );
}
return bRet;
@@ -512,8 +514,8 @@ sal_Bool BitmapEx::Rotate( long nAngle10, const Color&
rFillColor )
aBitmapSize = aBitmap.GetSizePixel();
- DBG_ASSERT( !aMask || aBitmap.GetSizePixel() == aMask.GetSizePixel(),
- "BitmapEx::Rotate(): size mismatch for bitmap and alpha
mask." );
+ DBG_ASSERT( !aMask || aBitmap.GetSizePixel() ==
aMask.GetSizePixel(),
+ "BitmapEx::Rotate(): size mismatch for
bitmap and alpha mask." );
}
return bRet;
@@ -534,8 +536,8 @@ sal_Bool BitmapEx::Crop( const Rectangle& rRectPixel )
aBitmapSize = aBitmap.GetSizePixel();
- DBG_ASSERT( !aMask || aBitmap.GetSizePixel() == aMask.GetSizePixel(),
- "BitmapEx::Crop(): size mismatch for bitmap and alpha
mask." );
+ DBG_ASSERT( !aMask || aBitmap.GetSizePixel() ==
aMask.GetSizePixel(),
+ "BitmapEx::Crop(): size mismatch for
bitmap and alpha mask." );
}
return bRet;
@@ -573,8 +575,8 @@ sal_Bool BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY,
const Color* pInitColor
aBitmapSize = aBitmap.GetSizePixel();
- DBG_ASSERT( !aMask || aBitmap.GetSizePixel() == aMask.GetSizePixel(),
- "BitmapEx::Expand(): size mismatch for bitmap and alpha
mask." );
+ DBG_ASSERT( !aMask || aBitmap.GetSizePixel() ==
aMask.GetSizePixel(),
+ "BitmapEx::Expand(): size mismatch for
bitmap and alpha mask." );
}
return bRet;
@@ -608,7 +610,7 @@ sal_Bool BitmapEx::CopyPixel( const Rectangle& rRectDst,
const Rectangle& rRectS
if( pBmpExSrc->IsAlpha() )
{
if( IsAlpha() )
- // cast to use the optimized AlphaMask::CopyPixel
+ // cast to use the optimized
AlphaMask::CopyPixel
((AlphaMask*)
&aMask)->CopyPixel( rRectDst, rRectSrc, (AlphaMask*)&pBmpExSrc->aMask );
else if( IsTransparent() )
{
@@ -648,20 +650,20 @@ sal_Bool BitmapEx::CopyPixel( const Rectangle& rRectDst,
const Rectangle& rRectS
aMask.CopyPixel( rRectDst,
rRectSrc, &pBmpExSrc->aMask );
}
}
- else if( IsAlpha() )
- {
- sal_uInt8 cBlack = 0;
- const AlphaMask aAlphaSrc( pBmpExSrc->GetSizePixel(),
&cBlack );
-
- aMask.CopyPixel( rRectDst, rRectSrc,
&aAlphaSrc.ImplGetBitmap() );
- }
- else if( IsTransparent() )
- {
- Bitmap aMaskSrc( pBmpExSrc->GetSizePixel(), 1 );
-
- aMaskSrc.Erase( Color( COL_BLACK ) );
- aMask.CopyPixel( rRectDst, rRectSrc, &aMaskSrc );
- }
+ else if( IsAlpha() )
+ {
+ sal_uInt8 cBlack
= 0;
+ const AlphaMask aAlphaSrc(
pBmpExSrc->GetSizePixel(), &cBlack );
+
+ aMask.CopyPixel( rRectDst, rRectSrc,
&aAlphaSrc.ImplGetBitmap() );
+ }
+ else if( IsTransparent() )
+ {
+ Bitmap aMaskSrc(
pBmpExSrc->GetSizePixel(), 1 );
+
+ aMaskSrc.Erase( Color( COL_BLACK ) );
+ aMask.CopyPixel( rRectDst, rRectSrc,
&aMaskSrc );
+ }
}
}
}
@@ -681,17 +683,17 @@ sal_Bool BitmapEx::Erase( const Color& rFillColor )
if( bRet && ( eTransparent == TRANSPARENT_BITMAP ) && !!aMask )
{
- // #104416# Respect transparency on fill color
- if( rFillColor.GetTransparency() )
- {
- const Color aFill( rFillColor.GetTransparency(),
rFillColor.GetTransparency(), rFillColor.GetTransparency() );
- aMask.Erase( aFill );
- }
- else
- {
- const Color aBlack( COL_BLACK );
- aMask.Erase( aBlack );
- }
+ // #104416# Respect transparency on fill color
+ if( rFillColor.GetTransparency() )
+ {
+ const Color aFill(
rFillColor.GetTransparency(), rFillColor.GetTransparency(),
rFillColor.GetTransparency() );
+ aMask.Erase( aFill );
+ }
+ else
+ {
+ const Color aBlack( COL_BLACK );
+ aMask.Erase( aBlack );
+ }
}
}
@@ -765,581 +767,580 @@ void BitmapEx::Draw( OutputDevice* pOutDev,
sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const
{
- sal_uInt8 nTransparency(0xff);
-
- if(!aBitmap.IsEmpty())
- {
- if(nX >= 0 && nX < aBitmapSize.Width() && nY >= 0 && nY <
aBitmapSize.Height())
- {
- switch(eTransparent)
- {
- case TRANSPARENT_NONE:
- {
- // not transparent, ergo all covered
- nTransparency = 0x00;
- break;
- }
- case TRANSPARENT_COLOR:
- {
- Bitmap aTestBitmap(aBitmap);
- BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess();
-
- if(pRead)
- {
- const Color aColor = pRead->GetColor(nY, nX);
-
- // if color is not equal to TransparentColor, we are
not transparent
- if(aColor != aTransparentColor)
- {
- nTransparency = 0x00;
- }
-
- aTestBitmap.ReleaseAccess(pRead);
- }
- break;
- }
- case TRANSPARENT_BITMAP:
- {
- if(!aMask.IsEmpty())
- {
- Bitmap aTestBitmap(aMask);
- BitmapReadAccess* pRead =
aTestBitmap.AcquireReadAccess();
-
- if(pRead)
- {
- const BitmapColor aBitmapColor(pRead->GetPixel(nY,
nX));
-
- if(bAlpha)
- {
- nTransparency = aBitmapColor.GetIndex();
- }
- else
- {
- if(0x00 == aBitmapColor.GetIndex())
- {
- nTransparency = 0x00;
- }
- }
-
- aTestBitmap.ReleaseAccess(pRead);
- }
- }
- break;
- }
- }
- }
- }
-
- return nTransparency;
+ sal_uInt8 nTransparency(0xff);
+
+ if(!aBitmap.IsEmpty())
+ {
+ if(nX >= 0 && nX < aBitmapSize.Width() && nY >= 0 && nY <
aBitmapSize.Height())
+ {
+ switch(eTransparent)
+ {
+ case TRANSPARENT_NONE:
+ {
+ // not transparent, ergo all covered
+ nTransparency = 0x00;
+ break;
+ }
+ case TRANSPARENT_COLOR:
+ {
+ Bitmap aTestBitmap(aBitmap);
+ BitmapReadAccess* pRead =
aTestBitmap.AcquireReadAccess();
+
+ if(pRead)
+ {
+ const Color aColor =
pRead->GetColor(nY, nX);
+
+ // if color is not equal to
TransparentColor, we are not transparent
+ if(aColor != aTransparentColor)
+ {
+ nTransparency = 0x00;
+ }
+
+
aTestBitmap.ReleaseAccess(pRead);
+ }
+ break;
+ }
+ case TRANSPARENT_BITMAP:
+ {
+ if(!aMask.IsEmpty())
+ {
+ Bitmap aTestBitmap(aMask);
+ BitmapReadAccess* pRead =
aTestBitmap.AcquireReadAccess();
+
+ if(pRead)
+ {
+ const BitmapColor
aBitmapColor(pRead->GetPixel(nY, nX));
+
+ if(bAlpha)
+ {
+ nTransparency =
aBitmapColor.GetIndex();
+ }
+ else
+ {
+ if(0x00 ==
aBitmapColor.GetIndex())
+ {
+
nTransparency = 0x00;
+ }
+ }
+
+
aTestBitmap.ReleaseAccess(pRead);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return nTransparency;
}
// ------------------------------------------------------------------
namespace
{
- Bitmap impTransformBitmap(
- const Bitmap& rSource,
- const Size aDestinationSize,
- const basegfx::B2DHomMatrix& rTransform,
- bool bSmooth)
- {
- Bitmap aDestination(aDestinationSize, 24);
- BitmapWriteAccess* pWrite = aDestination.AcquireWriteAccess();
-
- if(pWrite)
- {
- //const Size aContentSizePixel(rSource.GetSizePixel());
- BitmapReadAccess* pRead = (const_cast< Bitmap&
>(rSource)).AcquireReadAccess();
-
- if(pRead)
- {
- const Size aDestinationSizePixel(aDestination.GetSizePixel());
- const BitmapColor aOutside(BitmapColor(0xff, 0xff, 0xff));
-
- for(sal_Int32 y(0L); y < aDestinationSizePixel.getHeight();
y++)
- {
- for(sal_Int32 x(0L); x < aDestinationSizePixel.getWidth();
x++)
- {
- const basegfx::B2DPoint aSourceCoor(rTransform *
basegfx::B2DPoint(x, y));
-
- if(bSmooth)
- {
- pWrite->SetPixel(
- y,
- x,
- pRead->GetInterpolatedColorWithFallback(
- aSourceCoor.getY(),
- aSourceCoor.getX(),
- aOutside));
- }
- else
- {
- // this version does the correct <= 0.0 checks, so
no need
- // to do the static_cast< sal_Int32 > self and
make an error
- pWrite->SetPixel(
- y,
- x,
- pRead->GetColorWithFallback(
- aSourceCoor.getY(),
- aSourceCoor.getX(),
- aOutside));
- }
- }
- }
-
- delete pRead;
- }
-
- delete pWrite;
- }
-
- rSource.AdaptBitCount(aDestination);
-
- return aDestination;
- }
+ Bitmap impTransformBitmap(
+ const Bitmap& rSource,
+ const Size aDestinationSize,
+ const basegfx::B2DHomMatrix& rTransform,
+ bool bSmooth)
+ {
+ Bitmap aDestination(aDestinationSize, 24);
+ BitmapWriteAccess* pWrite = aDestination.AcquireWriteAccess();
+
+ if(pWrite)
+ {
+ //const Size aContentSizePixel(rSource.GetSizePixel());
+ BitmapReadAccess* pRead = (const_cast< Bitmap&
>(rSource)).AcquireReadAccess();
+
+ if(pRead)
+ {
+ const Size
aDestinationSizePixel(aDestination.GetSizePixel());
+ const BitmapColor aOutside(BitmapColor(0xff,
0xff, 0xff));
+
+ for(sal_Int32 y(0L); y <
aDestinationSizePixel.getHeight(); y++)
+ {
+ for(sal_Int32 x(0L); x <
aDestinationSizePixel.getWidth(); x++)
+ {
+ const basegfx::B2DPoint
aSourceCoor(rTransform * basegfx::B2DPoint(x, y));
+
+ if(bSmooth)
+ {
+ pWrite->SetPixel(
+ y,
+ x,
+
pRead->GetInterpolatedColorWithFallback(
+
aSourceCoor.getY(),
+
aSourceCoor.getX(),
+
aOutside));
+ }
+ else
+ {
+ // this version does
the correct <= 0.0 checks, so no need
+ // to do the
static_cast< sal_Int32 > self and make an error
+ pWrite->SetPixel(
+ y,
+ x,
+
pRead->GetColorWithFallback(
+
aSourceCoor.getY(),
+
aSourceCoor.getX(),
+
aOutside));
+ }
+ }
+ }
+
+ delete pRead;
+ }
+
+ delete pWrite;
+ }
+
+ rSource.AdaptBitCount(aDestination);
+
+ return aDestination;
+ }
} // end of anonymous namespace
BitmapEx BitmapEx::TransformBitmapEx(
- double fWidth,
- double fHeight,
- const basegfx::B2DHomMatrix& rTransformation,
- bool bSmooth) const
+ double fWidth,
+ double fHeight,
+ const basegfx::B2DHomMatrix& rTransformation,
+ bool bSmooth) const
{
- if(fWidth <= 1 || fHeight <= 1)
- return BitmapEx();
-
- // force destination to 24 bit, we want to smooth output
- const Size aDestinationSize(basegfx::fround(fWidth),
basegfx::fround(fHeight));
- const Bitmap aDestination(impTransformBitmap(GetBitmap(),
aDestinationSize, rTransformation, bSmooth));
-
- // create mask
- if(IsTransparent())
- {
- if(IsAlpha())
- {
- const Bitmap aAlpha(impTransformBitmap(GetAlpha().GetBitmap(),
aDestinationSize, rTransformation, bSmooth));
- return BitmapEx(aDestination, AlphaMask(aAlpha));
- }
- else
- {
- const Bitmap aMask(impTransformBitmap(GetMask(), aDestinationSize,
rTransformation, false));
- return BitmapEx(aDestination, aMask);
- }
- }
-
- return BitmapEx(aDestination);
+ if(fWidth <= 1 || fHeight <= 1)
+ return BitmapEx();
+
+ // force destination to 24 bit, we want to smooth output
+ const Size aDestinationSize(basegfx::fround(fWidth),
basegfx::fround(fHeight));
+ const Bitmap aDestination(impTransformBitmap(GetBitmap(),
aDestinationSize, rTransformation, bSmooth));
+
+ // create mask
+ if(IsTransparent())
+ {
+ if(IsAlpha())
+ {
+ const Bitmap
aAlpha(impTransformBitmap(GetAlpha().GetBitmap(), aDestinationSize,
rTransformation, bSmooth));
+ return BitmapEx(aDestination, AlphaMask(aAlpha));
+ }
+ else
+ {
+ const Bitmap aMask(impTransformBitmap(GetMask(),
aDestinationSize, rTransformation, false));
+ return BitmapEx(aDestination, aMask);
+ }
+ }
+
+ return BitmapEx(aDestination);
}
// ------------------------------------------------------------------
BitmapEx BitmapEx::getTransformed(
- const basegfx::B2DHomMatrix& rTransformation,
- const basegfx::B2DRange& rVisibleRange,
- double fMaximumArea,
- bool bSmooth) const
+ const basegfx::B2DHomMatrix& rTransformation,
+ const basegfx::B2DRange& rVisibleRange,
+ double fMaximumArea,
+ bool bSmooth) const
{
- BitmapEx aRetval;
-
- if(IsEmpty())
- return aRetval;
-
- const sal_uInt32 nSourceWidth(GetSizePixel().Width());
- const sal_uInt32 nSourceHeight(GetSizePixel().Height());
-
- if(!nSourceWidth || !nSourceHeight)
- return aRetval;
-
- // Get aOutlineRange
- basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0);
-
- aOutlineRange.transform(rTransformation);
-
- // create visible range from it by moving from relative to absolute
- basegfx::B2DRange aVisibleRange(rVisibleRange);
-
- aVisibleRange.transform(
- basegfx::tools::createScaleTranslateB2DHomMatrix(
- aOutlineRange.getRange(),
- aOutlineRange.getMinimum()));
-
- // get target size (which is visible range's size)
- double fWidth(aVisibleRange.getWidth());
- double fHeight(aVisibleRange.getHeight());
-
- if(fWidth < 1.0 || fHeight < 1.0)
- {
- return aRetval;
- }
-
- // test if discrete size (pixel) maybe too big and limit it
- const double fArea(fWidth * fHeight);
- const bool bNeedToReduce(basegfx::fTools::more(fArea, fMaximumArea));
- double fReduceFactor(1.0);
-
- if(bNeedToReduce)
- {
- fReduceFactor = sqrt(fMaximumArea / fArea);
- fWidth *= fReduceFactor;
- fHeight *= fReduceFactor;
- }
-
- // Build complete transform from source pixels to target pixels.
- // Start by scaling from source pixel size to unit coordinates
- basegfx::B2DHomMatrix aTransform(
- basegfx::tools::createScaleB2DHomMatrix(
- 1.0 / nSourceWidth,
- 1.0 / nSourceHeight));
-
- // multiply with given transform which leads from unit coordinates inside
- // aOutlineRange
- aTransform = rTransformation * aTransform;
-
- // subtract top-left of absolute VisibleRange
- aTransform.translate(
- -aVisibleRange.getMinX(),
- -aVisibleRange.getMinY());
-
- // scale to target pixels (if needed)
- if(bNeedToReduce)
- {
- aTransform.scale(fReduceFactor, fReduceFactor);
- }
-
- // invert to get transformation from target pixel coordiates to source
pixels
- aTransform.invert();
-
- // create bitmap using source, destination and linear back-transformation
- aRetval = TransformBitmapEx(fWidth, fHeight, aTransform, bSmooth);
-
- return aRetval;
+ BitmapEx aRetval;
+
+ if(IsEmpty())
+ return aRetval;
+
+ const sal_uInt32 nSourceWidth(GetSizePixel().Width());
+ const sal_uInt32 nSourceHeight(GetSizePixel().Height());
+
+ if(!nSourceWidth || !nSourceHeight)
+ return aRetval;
+
+ // Get aOutlineRange
+ basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0);
+
+ aOutlineRange.transform(rTransformation);
+
+ // create visible range from it by moving from relative to absolute
+ basegfx::B2DRange aVisibleRange(rVisibleRange);
+
+ aVisibleRange.transform(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aOutlineRange.getRange(),
+ aOutlineRange.getMinimum()));
+
+ // get target size (which is visible range's size)
+ double fWidth(aVisibleRange.getWidth());
+ double fHeight(aVisibleRange.getHeight());
+
+ if(fWidth < 1.0 || fHeight < 1.0)
+ {
+ return aRetval;
+ }
+
+ // test if discrete size (pixel) maybe too big and limit it
+ const double fArea(fWidth * fHeight);
+ const bool bNeedToReduce(basegfx::fTools::more(fArea, fMaximumArea));
+ double fReduceFactor(1.0);
+
+ if(bNeedToReduce)
+ {
+ fReduceFactor = sqrt(fMaximumArea / fArea);
+ fWidth *= fReduceFactor;
+ fHeight *= fReduceFactor;
+ }
+
+ // Build complete transform from source pixels to target pixels.
+ // Start by scaling from source pixel size to unit coordinates
+ basegfx::B2DHomMatrix aTransform(
+ basegfx::tools::createScaleB2DHomMatrix(
+ 1.0 / nSourceWidth,
+ 1.0 / nSourceHeight));
+
+ // multiply with given transform which leads from unit coordinates
inside
+ // aOutlineRange
+ aTransform = rTransformation * aTransform;
+
+ // subtract top-left of absolute VisibleRange
+ aTransform.translate(
+ -aVisibleRange.getMinX(),
+ -aVisibleRange.getMinY());
+
+ // scale to target pixels (if needed)
+ if(bNeedToReduce)
+ {
+ aTransform.scale(fReduceFactor, fReduceFactor);
+ }
+
+ // invert to get transformation from target pixel coordinates to source
pixels
+ aTransform.invert();
+
+ // create bitmap using source, destination and linear
back-transformation
+ aRetval = TransformBitmapEx(fWidth, fHeight, aTransform, bSmooth);
+
+ return aRetval;
}
// ------------------------------------------------------------------
BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack&
rBColorModifierStack) const
{
- Bitmap aChangedBitmap(GetBitmap());
- bool bDone(false);
-
- for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; )
- {
- const basegfx::BColorModifierSharedPtr& rModifier =
rBColorModifierStack.getBColorModifier(--a);
- const basegfx::BColorModifier_replace* pReplace = dynamic_cast< const
basegfx::BColorModifier_replace* >(rModifier.get());
-
- if(pReplace)
- {
- // complete replace
- if(IsTransparent())
- {
- // clear bitmap with dest color
- if(aChangedBitmap.GetBitCount() <= 8)
- {
- // do NOT use erase; for e.g. 8bit Bitmaps, the nearest
color to the given
- // erase color is determined and used -> this may be
different from what is
- // wanted here. Better create a new bitmap with the needed
color explicitly
- BitmapReadAccess* pReadAccess =
aChangedBitmap.AcquireReadAccess();
- OSL_ENSURE(pReadAccess, "Got no Bitmap ReadAccess ?!?");
-
- if(pReadAccess)
- {
- BitmapPalette aNewPalette(pReadAccess->GetPalette());
- aNewPalette[0] =
BitmapColor(Color(pReplace->getBColor()));
- aChangedBitmap = Bitmap(
- aChangedBitmap.GetSizePixel(),
- aChangedBitmap.GetBitCount(),
- &aNewPalette);
- delete pReadAccess;
- }
- }
- else
- {
- aChangedBitmap.Erase(Color(pReplace->getBColor()));
- }
- }
- else
- {
- // erase bitmap, caller will know to paint direct
- aChangedBitmap.SetEmpty();
- }
-
- bDone = true;
- }
- else
- {
- BitmapWriteAccess* pContent = aChangedBitmap.AcquireWriteAccess();
-
- if(pContent)
- {
- const double fConvertColor(1.0 / 255.0);
-
- if(pContent->HasPalette())
- {
- const sal_uInt16 nCount(pContent->GetPaletteEntryCount());
-
- for(sal_uInt16 a(0); a < nCount; a++)
- {
- const BitmapColor& rCol =
pContent->GetPaletteColor(a);
- const basegfx::BColor aBSource(
- rCol.GetRed() * fConvertColor,
- rCol.GetGreen() * fConvertColor,
- rCol.GetBlue() * fConvertColor);
- const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
- pContent->SetPaletteColor(a,
BitmapColor(Color(aBDest)));
- }
- }
- else if(BMP_FORMAT_24BIT_TC_BGR ==
pContent->GetScanlineFormat())
- {
- for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height();
y++)
- {
- Scanline pScan = pContent->GetScanline(y);
-
- for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
- {
- const basegfx::BColor aBSource(
- *(pScan + 2)* fConvertColor,
- *(pScan + 1) * fConvertColor,
- *pScan * fConvertColor);
- const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getBlue() * 255.0);
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getGreen() * 255.0);
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getRed() * 255.0);
- }
- }
- }
- else if(BMP_FORMAT_24BIT_TC_RGB ==
pContent->GetScanlineFormat())
- {
- for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height();
y++)
- {
- Scanline pScan = pContent->GetScanline(y);
-
- for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
- {
- const basegfx::BColor aBSource(
- *pScan * fConvertColor,
- *(pScan + 1) * fConvertColor,
- *(pScan + 2) * fConvertColor);
- const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getRed() * 255.0);
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getGreen() * 255.0);
- *pScan++ = static_cast< sal_uInt8
>(aBDest.getBlue() * 255.0);
- }
- }
- }
- else
- {
- for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height();
y++)
- {
- for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
- {
- const BitmapColor aBMCol(pContent->GetColor(y, x));
- const basegfx::BColor aBSource(
- (double)aBMCol.GetRed() * fConvertColor,
- (double)aBMCol.GetGreen() * fConvertColor,
- (double)aBMCol.GetBlue() * fConvertColor);
- const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
-
- pContent->SetPixel(y, x,
BitmapColor(Color(aBDest)));
- }
- }
- }
-
- delete pContent;
- }
- }
- }
-
- if(aChangedBitmap.IsEmpty())
- {
- return BitmapEx();
- }
- else
- {
- if(IsTransparent())
- {
- if(IsAlpha())
- {
- return BitmapEx(aChangedBitmap, GetAlpha());
- }
- else
- {
- return BitmapEx(aChangedBitmap, GetMask());
- }
- }
- else
- {
- return BitmapEx(aChangedBitmap);
- }
- }
+ Bitmap aChangedBitmap(GetBitmap());
+ bool bDone(false);
+
+ for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; )
+ {
+ const basegfx::BColorModifierSharedPtr& rModifier =
rBColorModifierStack.getBColorModifier(--a);
+ const basegfx::BColorModifier_replace* pReplace = dynamic_cast<
const basegfx::BColorModifier_replace* >(rModifier.get());
+
+ if(pReplace)
+ {
+ // complete replace
+ if(IsTransparent())
+ {
+ // clear bitmap with dest color
+ if(aChangedBitmap.GetBitCount() <= 8)
+ {
+ // do NOT use erase; for e.g. 8bit
Bitmaps, the nearest color to the given
+ // erase color is determined and used
-> this may be different from what is
+ // wanted here. Better create a new
bitmap with the needed color explicitly
+ BitmapReadAccess* pReadAccess =
aChangedBitmap.AcquireReadAccess();
+ OSL_ENSURE(pReadAccess, "Got no Bitmap
ReadAccess ?!?");
+
+ if(pReadAccess)
+ {
+ BitmapPalette
aNewPalette(pReadAccess->GetPalette());
+ aNewPalette[0] =
BitmapColor(Color(pReplace->getBColor()));
+ aChangedBitmap = Bitmap(
+
aChangedBitmap.GetSizePixel(),
+
aChangedBitmap.GetBitCount(),
+ &aNewPalette);
+ delete pReadAccess;
+ }
+ }
+ else
+ {
+
aChangedBitmap.Erase(Color(pReplace->getBColor()));
+ }
+ }
+ else
+ {
+ // erase bitmap, caller will know to paint
direct
+ aChangedBitmap.SetEmpty();
+ }
+
+ bDone = true;
+ }
+ else
+ {
+ BitmapWriteAccess* pContent =
aChangedBitmap.AcquireWriteAccess();
+
+ if(pContent)
+ {
+ const double fConvertColor(1.0 / 255.0);
+
+ if(pContent->HasPalette())
+ {
+ const sal_uInt16
nCount(pContent->GetPaletteEntryCount());
+
+ for(sal_uInt16 a(0); a < nCount; a++)
+ {
+ const BitmapColor& rCol =
pContent->GetPaletteColor(a);
+ const basegfx::BColor aBSource(
+ rCol.GetRed() *
fConvertColor,
+ rCol.GetGreen() *
fConvertColor,
+ rCol.GetBlue() *
fConvertColor);
+ const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
+ pContent->SetPaletteColor(a,
BitmapColor(Color(aBDest)));
+ }
+ }
+ else if(BMP_FORMAT_24BIT_TC_BGR ==
pContent->GetScanlineFormat())
+ {
+ for(sal_uInt32 y(0L); y <
(sal_uInt32)pContent->Height(); y++)
+ {
+ Scanline pScan =
pContent->GetScanline(y);
+
+ for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
+ {
+ const basegfx::BColor
aBSource(
+ *(pScan + 2)*
fConvertColor,
+ *(pScan + 1) *
fConvertColor,
+ *pScan *
fConvertColor);
+ const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getBlue() * 255.0);
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getGreen() * 255.0);
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getRed() * 255.0);
+ }
+ }
+ }
+ else if(BMP_FORMAT_24BIT_TC_RGB ==
pContent->GetScanlineFormat())
+ {
+ for(sal_uInt32 y(0L); y <
(sal_uInt32)pContent->Height(); y++)
+ {
+ Scanline pScan =
pContent->GetScanline(y);
+
+ for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
+ {
+ const basegfx::BColor
aBSource(
+ *pScan *
fConvertColor,
+ *(pScan + 1) *
fConvertColor,
+ *(pScan + 2) *
fConvertColor);
+ const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getRed() * 255.0);
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getGreen() * 255.0);
+ *pScan++ = static_cast<
sal_uInt8 >(aBDest.getBlue() * 255.0);
+ }
+ }
+ }
+ else
+ {
+ for(sal_uInt32 y(0L); y <
(sal_uInt32)pContent->Height(); y++)
+ {
+ for(sal_uInt32 x(0L); x <
(sal_uInt32)pContent->Width(); x++)
+ {
+ const BitmapColor
aBMCol(pContent->GetColor(y, x));
+ const basegfx::BColor
aBSource(
+
(double)aBMCol.GetRed() * fConvertColor,
+
(double)aBMCol.GetGreen() * fConvertColor,
+
(double)aBMCol.GetBlue() * fConvertColor);
+ const basegfx::BColor
aBDest(rModifier->getModifiedColor(aBSource));
+
+ pContent->SetPixel(y,
x, BitmapColor(Color(aBDest)));
+ }
+ }
+ }
+
+ delete pContent;
+ }
+ }
+ }
+
+ if(aChangedBitmap.IsEmpty())
+ {
+ return BitmapEx();
+ }
+ else
+ {
+ if(IsTransparent())
+ {
+ if(IsAlpha())
+ {
+ return BitmapEx(aChangedBitmap, GetAlpha());
+ }
+ else
+ {
+ return BitmapEx(aChangedBitmap, GetMask());
+ }
+ }
+ else
+ {
+ return BitmapEx(aChangedBitmap);
+ }
+ }
}
//
-----------------------------------------------------------------------------
BitmapEx VCL_DLLPUBLIC createBlendFrame(
- const Size& rSize,
- sal_uInt8 nAlpha,
- Color aColorTopLeft,
- Color aColorBottomRight)
+ const Size& rSize,
+ sal_uInt8 nAlpha,
+ Color aColorTopLeft,
+ Color aColorBottomRight)
{
- const sal_uInt32 nW(rSize.Width());
- const sal_uInt32 nH(rSize.Height());
+ const sal_uInt32 nW(rSize.Width());
+ const sal_uInt32 nH(rSize.Height());
- if(nW || nH)
- {
- Color aColTopRight(aColorTopLeft);
- Color aColBottomLeft(aColorTopLeft);
- const sal_uInt32 nDE(nW + nH);
+ if(nW || nH)
+ {
+ Color aColTopRight(aColorTopLeft);
+ Color aColBottomLeft(aColorTopLeft);
+ const sal_uInt32 nDE(nW + nH);
- aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW * 255) /
nDE));
- aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH * 255) /
nDE));
+ aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW *
255) / nDE));
+ aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH *
255) / nDE));
- return createBlendFrame(rSize, nAlpha, aColorTopLeft, aColTopRight,
aColorBottomRight, aColBottomLeft);
- }
+ return createBlendFrame(rSize, nAlpha, aColorTopLeft,
aColTopRight, aColorBottomRight, aColBottomLeft);
+ }
- return BitmapEx();
+ return BitmapEx();
}
BitmapEx VCL_DLLPUBLIC createBlendFrame(
- const Size& rSize,
- sal_uInt8 nAlpha,
- Color aColorTopLeft,
- Color aColorTopRight,
- Color aColorBottomRight,
- Color aColorBottomLeft)
+ const Size& rSize,
+ sal_uInt8 nAlpha,
+ Color aColorTopLeft,
+ Color aColorTopRight,
+ Color aColorBottomRight,
+ Color aColorBottomLeft)
{
- static Size aLastSize(0, 0);
- static sal_uInt8 nLastAlpha(0);
- static Color aLastColorTopLeft(COL_BLACK);
- static Color aLastColorTopRight(COL_BLACK);
- static Color aLastColorBottomRight(COL_BLACK);
- static Color aLastColorBottomLeft(COL_BLACK);
- static BitmapEx aLastResult;
-
- if(aLastSize == rSize
- && nLastAlpha == nAlpha
- && aLastColorTopLeft == aColorTopLeft
- && aLastColorTopRight == aColorTopRight
- && aLastColorBottomRight == aColorBottomRight
- && aLastColorBottomLeft == aColorBottomLeft)
- {
- return aLastResult;
- }
-
- aLastSize = rSize;
- nLastAlpha = nAlpha;
- aLastColorTopLeft = aColorTopLeft;
- aLastColorTopRight = aColorTopRight;
- aLastColorBottomRight = aColorBottomRight;
- aLastColorBottomLeft = aColorBottomLeft;
- aLastResult.Clear();
-
- const long nW(rSize.Width());
- const long nH(rSize.Height());
-
- if(nW && nH)
- {
- sal_uInt8 aEraseTrans(0xff);
- Bitmap aContent(rSize, 24);
- AlphaMask aAlpha(rSize, &aEraseTrans);
-
- aContent.Erase(COL_BLACK);
-
- BitmapWriteAccess* pContent = aContent.AcquireWriteAccess();
- BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess();
-
- if(pContent && pAlpha)
- {
- long x(0);
- long y(0);
-
- // x == 0, y == 0, top-left corner
- pContent->SetPixel(0, 0, aColorTopLeft);
- pAlpha->SetPixelIndex(0, 0, nAlpha);
-
- // y == 0, top line left to right
- for(x = 1; x < nW - 1; x++)
- {
- Color aMix(aColorTopLeft);
-
- aMix.Merge(aColorTopRight, 255 - sal_uInt8((x * 255) / nW));
- pContent->SetPixel(0, x, aMix);
- pAlpha->SetPixelIndex(0, x, nAlpha);
- }
-
- // x == nW - 1, y == 0, top-right corner
- // #123690# Caution! When nW is 1, x == nW is possible (!)
- if(x < nW)
- {
- pContent->SetPixel(0, x, aColorTopRight);
- pAlpha->SetPixelIndex(0, x, nAlpha);
- }
-
- // x == 0 and nW - 1, left and right line top-down
- for(y = 1; y < nH - 1; y++)
- {
- Color aMixA(aColorTopLeft);
-
- aMixA.Merge(aColorBottomLeft, 255 - sal_uInt8((y * 255) / nH));
- pContent->SetPixel(y, 0, aMixA);
- pAlpha->SetPixelIndex(y, 0, nAlpha);
-
- // #123690# Caution! When nW is 1, x == nW is possible (!)
- if(x < nW)
- {
- Color aMixB(aColorTopRight);
-
- aMixB.Merge(aColorBottomRight, 255 - sal_uInt8((y * 255) /
nH));
- pContent->SetPixel(y, x, aMixB);
- pAlpha->SetPixelIndex(y, x, nAlpha);
- }
- }
-
- // #123690# Caution! When nH is 1, y == nH is possible (!)
- if(y < nH)
- {
- // x == 0, y == nH - 1, bottom-left corner
- pContent->SetPixel(y, 0, aColorBottomLeft);
- pAlpha->SetPixelIndex(y, 0, nAlpha);
-
- // y == nH - 1, bottom line left to right
- for(x = 1; x < nW - 1; x++)
- {
- Color aMix(aColorBottomLeft);
-
- aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - 0)*
255) / nW));
- pContent->SetPixel(y, x, aMix);
- pAlpha->SetPixelIndex(y, x, nAlpha);
- }
-
- // x == nW - 1, y == nH - 1, bottom-right corner
- // #123690# Caution! When nW is 1, x == nW is possible (!)
- if(x < nW)
- {
- pContent->SetPixel(y, x, aColorBottomRight);
- pAlpha->SetPixelIndex(y, x, nAlpha);
- }
- }
-
- aContent.ReleaseAccess(pContent);
- aAlpha.ReleaseAccess(pAlpha);
-
- aLastResult = BitmapEx(aContent, aAlpha);
- }
- else
- {
- if(pContent)
- {
- aContent.ReleaseAccess(pContent);
- }
-
- if(pAlpha)
- {
- aAlpha.ReleaseAccess(pAlpha);
- }
- }
- }
-
- return aLastResult;
+ static Size aLastSize(0, 0);
+ static sal_uInt8 nLastAlpha(0);
+ static Color aLastColorTopLeft(COL_BLACK);
+ static Color aLastColorTopRight(COL_BLACK);
+ static Color aLastColorBottomRight(COL_BLACK);
+ static Color aLastColorBottomLeft(COL_BLACK);
+ static BitmapEx aLastResult;
+
+ if(aLastSize == rSize
+ && nLastAlpha == nAlpha
+ && aLastColorTopLeft == aColorTopLeft
+ && aLastColorTopRight == aColorTopRight
+ && aLastColorBottomRight == aColorBottomRight
+ && aLastColorBottomLeft == aColorBottomLeft)
+ {
+ return aLastResult;
+ }
+
+ aLastSize = rSize;
+ nLastAlpha = nAlpha;
+ aLastColorTopLeft = aColorTopLeft;
+ aLastColorTopRight = aColorTopRight;
+ aLastColorBottomRight = aColorBottomRight;
+ aLastColorBottomLeft = aColorBottomLeft;
+ aLastResult.Clear();
+
+ const long nW(rSize.Width());
+ const long nH(rSize.Height());
+
+ if(nW && nH)
+ {
+ sal_uInt8 aEraseTrans(0xff);
+ Bitmap aContent(rSize, 24);
+ AlphaMask aAlpha(rSize, &aEraseTrans);
+
+ aContent.Erase(COL_BLACK);
+
+ BitmapWriteAccess* pContent = aContent.AcquireWriteAccess();
+ BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess();
+
+ if(pContent && pAlpha)
+ {
+ long x(0);
+ long y(0);
+
+ // x == 0, y == 0, top-left corner
+ pContent->SetPixel(0, 0, aColorTopLeft);
+ pAlpha->SetPixelIndex(0, 0, nAlpha);
+
+ // y == 0, top line left to right
+ for(x = 1; x < nW - 1; x++)
+ {
+ Color aMix(aColorTopLeft);
+
+ aMix.Merge(aColorTopRight, 255 - sal_uInt8((x *
255) / nW));
+ pContent->SetPixel(0, x, aMix);
+ pAlpha->SetPixelIndex(0, x, nAlpha);
+ }
+
+ // x == nW - 1, y == 0, top-right corner
+ // #123690# Caution! When nW is 1, x == nW is possible
(!)
+ if(x < nW)
+ {
+ pContent->SetPixel(0, x, aColorTopRight);
+ pAlpha->SetPixelIndex(0, x, nAlpha);
+ }
+
+ // x == 0 and nW - 1, left and right line top-down
+ for(y = 1; y < nH - 1; y++)
+ {
+ Color aMixA(aColorTopLeft);
+
+ aMixA.Merge(aColorBottomLeft, 255 -
sal_uInt8((y * 255) / nH));
+ pContent->SetPixel(y, 0, aMixA);
+ pAlpha->SetPixelIndex(y, 0, nAlpha);
+
+ // #123690# Caution! When nW is 1, x == nW is
possible (!)
+ if(x < nW)
+ {
+ Color aMixB(aColorTopRight);
+
+ aMixB.Merge(aColorBottomRight, 255 -
sal_uInt8((y * 255) / nH));
+ pContent->SetPixel(y, x, aMixB);
+ pAlpha->SetPixelIndex(y, x, nAlpha);
+ }
+ }
+
+ // #123690# Caution! When nH is 1, y == nH is possible
(!)
+ if(y < nH)
+ {
+ // x == 0, y == nH - 1, bottom-left corner
+ pContent->SetPixel(y, 0, aColorBottomLeft);
+ pAlpha->SetPixelIndex(y, 0, nAlpha);
+
+ // y == nH - 1, bottom line left to right
+ for(x = 1; x < nW - 1; x++)
+ {
+ Color aMix(aColorBottomLeft);
+
+ aMix.Merge(aColorBottomRight, 255 -
sal_uInt8(((x - 0)* 255) / nW));
+ pContent->SetPixel(y, x, aMix);
+ pAlpha->SetPixelIndex(y, x, nAlpha);
+ }
+
+ // x == nW - 1, y == nH - 1, bottom-right corner
+ // #123690# Caution! When nW is 1, x == nW is
possible (!)
+ if(x < nW)
+ {
+ pContent->SetPixel(y, x,
aColorBottomRight);
+ pAlpha->SetPixelIndex(y, x, nAlpha);
+ }
+ }
+
+ aContent.ReleaseAccess(pContent);
+ aAlpha.ReleaseAccess(pAlpha);
+
+ aLastResult = BitmapEx(aContent, aAlpha);
+ }
+ else
+ {
+ if(pContent)
+ {
+ aContent.ReleaseAccess(pContent);
+ }
+
+ if(pAlpha)
+ {
+ aAlpha.ReleaseAccess(pAlpha);
+ }
+ }
+ }
+
+ return aLastResult;
}
-// ------------------------------------------------------------------
-// eof
+/* vim: set noet sw=4 ts=4: */