Kaydet (Commit) aa620864 authored tarafından Matteo Casalin's avatar Matteo Casalin

sal_uLong to sal_uInt16 as return type of BitmapColor::GetColorError

Change-Id: I62c0d073d6b22346b65e3560303d7fc9373bfc7e
üst e28c9ccb
......@@ -1392,8 +1392,8 @@ static bool HasSimilarScheme(const BitmapColor& rBitmapColor1, const BitmapColor
static sal_uInt16 GetBestIndex(const BitmapPalette& rPalette, const BitmapColor& rBitmapColor)
{
sal_uInt16 nReturn = 0;
sal_uInt16 nLastErr = SAL_MAX_UINT16;
bool bFound = false;
sal_uLong nLastErr = 3 * 255 + 1;
// Prefer those colors which have similar scheme as the input
// Allow bigger and bigger variance of the schemes until we find
......@@ -1404,7 +1404,7 @@ static sal_uInt16 GetBestIndex(const BitmapPalette& rPalette, const BitmapColor&
{
if( HasSimilarScheme(rBitmapColor, rPalette[i], nVariance) )
{
sal_uLong nActErr = rBitmapColor.GetColorError( rPalette[i] );
const sal_uInt16 nActErr = rBitmapColor.GetColorError( rPalette[i] );
if( nActErr < nLastErr )
{
nLastErr = nActErr;
......
......@@ -138,7 +138,7 @@ public:
inline BitmapColor& Merge( const BitmapColor& rColor, sal_uInt8 cTransparency );
inline sal_uLong GetColorError( const BitmapColor& rBitmapColor ) const;
inline sal_uInt16 GetColorError( const BitmapColor& rBitmapColor ) const;
};
// - BitmapPalette -
......@@ -398,13 +398,14 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn
inline sal_uLong BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const
inline sal_uInt16 BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const
{
DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" );
DBG_ASSERT( !rBitmapColor.mbIndex, "Pixel represents index into colortable!" );
return( (sal_uLong) ( labs( mcBlueOrIndex - rBitmapColor.mcBlueOrIndex ) +
labs( mcGreen - rBitmapColor.mcGreen ) +
labs( mcRed - rBitmapColor.mcRed ) ) );
return static_cast<sal_uInt16>(
abs( static_cast<int>(mcBlueOrIndex) - static_cast<int>(rBitmapColor.mcBlueOrIndex) ) +
abs( static_cast<int>(mcGreen) - static_cast<int>(rBitmapColor.mcGreen) ) +
abs( static_cast<int>(mcRed) - static_cast<int>(rBitmapColor.mcRed) ) );
}
inline BitmapPalette::BitmapPalette() :
......@@ -550,10 +551,10 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const
return j;
}
sal_uLong nLastErr = rCol.GetColorError( mpBitmapColor[ nRetIndex ] );
for( sal_uInt16 i = 1; i < mnCount; ++i )
sal_uInt16 nLastErr = SAL_MAX_UINT16;
for( sal_uInt16 i = 0; i < mnCount; ++i )
{
const sal_uLong nActErr = rCol.GetColorError( mpBitmapColor[ i ] );
const sal_uInt16 nActErr = rCol.GetColorError( mpBitmapColor[ i ] );
if ( nActErr < nLastErr )
{
nLastErr = nActErr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment