summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-10-30 11:02:38 +0000
committerArmin Le Grand <alg@apache.org>2012-10-30 11:02:38 +0000
commitdb00dfd93ac0e215a5d71e72645790918db0e734 (patch)
treee5dd9d22eb955571cc35f56049f66d800f53e435 /vcl
parentbf734a151dc5169b65cf5d2a127e4142b765326c (diff)
#121233# some slight corrections/enhancements
Notes
Notes: merged as: 9536e3cbb8b1e765b83cdb10359cca91ff80b172
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/bitmap.hxx6
-rw-r--r--vcl/source/gdi/bitmap3.cxx166
2 files changed, 65 insertions, 107 deletions
diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index be57468ff32c..e0fa88049957 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -397,7 +397,7 @@ public:
BitmapWriteAccess& rAcc, sal_Bool bRLE4 );
SAL_DLLPRIVATE static sal_Bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bRLE4 );
- SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew);
+ SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew) const;
SAL_DLLPRIVATE sal_Bool ImplScaleFast( const double& rScaleX, const double& rScaleY );
SAL_DLLPRIVATE sal_Bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY );
SAL_DLLPRIVATE sal_Bool ImplScaleSuper( const double& rScaleX, const double& rScaleY );
@@ -668,6 +668,10 @@ public:
*/
sal_Bool Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE );
+ // Adapt the BitCount of rNew to BitCount of lolal, including grey or color paltette
+ // Can be used to create alpha/mask bitmaps after their processing in 24bit
+ void AdaptBitCount(Bitmap& rNew) const;
+
/** Rotate bitmap by the specified angle
@param nAngle10
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index c6f87e774310..731dd23c0c12 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -1032,7 +1032,14 @@ sal_Bool Bitmap::Scale( const Size& rNewSize, sal_uLong nScaleFlag )
// ------------------------------------------------------------------------
-void Bitmap::ImplAdaptBitCount(Bitmap& rNew)
+void Bitmap::AdaptBitCount(Bitmap& rNew) const
+{
+ 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())
@@ -1195,73 +1202,52 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
pLutFrac[ nX ] = (long) ( fTemp * 1024. );
}
- if( pReadAcc->HasPalette() )
+ for( nY = 0L; nY < nHeight; nY++ )
{
- for( nY = 0L; nY < nHeight; nY++ )
+ if( 1 == nWidth )
{
- if( 1 == nWidth )
+ if( pReadAcc->HasPalette() )
{
aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, 0 ) );
-
- for( nX = 0L; nX < nNewWidth; nX++ )
- pWriteAcc->SetPixel( nY, nX, aCol0 );
}
else
{
- for( nX = 0L; nX < nNewWidth; nX++ )
- {
- nTemp = pLutInt[ nX ];
-
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) );
- aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) );
-
- nTemp = pLutFrac[ nX ];
-
- lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
- lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
- lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
-
- aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
- aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
- aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
+ aCol0 = pReadAcc->GetPixel( nY, 0 );
+ }
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
+ for( nX = 0L; nX < nNewWidth; nX++ )
+ {
+ pWriteAcc->SetPixel( nY, nX, aCol0 );
}
}
- }
- else
- {
- for( nY = 0L; nY < nHeight; nY++ )
+ else
{
- if( 1 == nWidth )
+ for( nX = 0L; nX < nNewWidth; nX++ )
{
- aCol0 = pReadAcc->GetPixel( nY, 0 );
+ nTemp = pLutInt[ nX ];
- for( nX = 0L; nX < nNewWidth; nX++ )
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
- else
- {
- for( nX = 0L; nX < nNewWidth; nX++ )
+ if( pReadAcc->HasPalette() )
+ {
+ aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) );
+ aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) );
+ }
+ else
{
- nTemp = pLutInt[ nX ];
-
aCol0 = pReadAcc->GetPixel( nY, nTemp++ );
aCol1 = pReadAcc->GetPixel( nY, nTemp );
+ }
- nTemp = pLutFrac[ nX ];
+ nTemp = pLutFrac[ nX ];
- lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
- lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
- lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
+ lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
+ lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
+ lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
- aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
- aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
- aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
+ aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
+ aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
+ aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
+ pWriteAcc->SetPixel( nY, nX, aCol0 );
}
}
}
@@ -1277,10 +1263,9 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
if( bRet )
{
bRet = sal_False;
- ImplAdaptBitCount(aNewBmp);
- ImplAssignWithSize( aNewBmp );
- pReadAcc = AcquireReadAccess();
+ *this = aNewBmp;
aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 );
+ pReadAcc = AcquireReadAccess();
pWriteAcc = aNewBmp.AcquireWriteAccess();
if( pReadAcc && pWriteAcc )
@@ -1300,73 +1285,40 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
pLutFrac[ nY ] = (long) ( fTemp * 1024. );
}
- if( pReadAcc->HasPalette() )
+ // 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++ )
{
- for( nX = 0L; nX < nNewWidth; nX++ )
+ if( 1 == nHeight )
{
- if( 1 == nHeight )
- {
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nX ) );
+ aCol0 = pReadAcc->GetPixel( 0, nX );
- for( nY = 0L; nY < nNewHeight; nY++ )
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
- else
+ for( nY = 0L; nY < nNewHeight; nY++ )
{
- for( nY = 0L; nY < nNewHeight; nY++ )
- {
- nTemp = pLutInt[ nY ];
-
- aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp++, nX ) );
- aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp, nX ) );
-
- nTemp = pLutFrac[ nY ];
-
- lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
- lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
- lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
-
- aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
- aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
- aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
-
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
+ pWriteAcc->SetPixel( nY, nX, aCol0 );
}
}
- }
- else
- {
- for( nX = 0L; nX < nNewWidth; nX++ )
+ else
{
- if( 1 == nHeight )
- {
- aCol0 = pReadAcc->GetPixel( 0, nX );
-
- for( nY = 0L; nY < nNewHeight; nY++ )
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
- else
+ for( nY = 0L; nY < nNewHeight; nY++ )
{
- for( nY = 0L; nY < nNewHeight; nY++ )
- {
- nTemp = pLutInt[ nY ];
+ nTemp = pLutInt[ nY ];
- aCol0 = pReadAcc->GetPixel( nTemp++, nX );
- aCol1 = pReadAcc->GetPixel( nTemp, nX );
+ aCol0 = pReadAcc->GetPixel( nTemp++, nX );
+ aCol1 = pReadAcc->GetPixel( nTemp, nX );
- nTemp = pLutFrac[ nY ];
+ nTemp = pLutFrac[ nY ];
- lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
- lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
- lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
+ lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() );
+ lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() );
+ lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() );
- aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
- aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
- aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
+ aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) );
+ aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) );
+ aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) );
- pWriteAcc->SetPixel( nY, nX, aCol0 );
- }
+ pWriteAcc->SetPixel( nY, nX, aCol0 );
}
}
}
@@ -1382,13 +1334,15 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca
if( bRet )
{
ImplAdaptBitCount(aNewBmp);
- ImplAssignWithSize( aNewBmp );
+ *this = aNewBmp;
}
}
}
if( !bRet )
+ {
bRet = ImplScaleFast( rScaleX, rScaleY );
+ }
return bRet;
}