Fill the alpha channel by default for vcl 32-bit bitmaps too.
Otherwise the alpha channel for bitmaps created directly is empty, indicating a transparent bitmap (although we don't actually handle transparency). This complements hardcoding of the alpha channel in basebmp. VCL bitmaps can be copied bit-for-bit directly into a basebmp bitmap, hence it's important to make sure we fill the alpha channel in vcl too. Conflicts: include/vcl/salbtype.hxx Change-Id: Icb2fa417db6625a6ffa6bd82eb5773ff75be5a3c
This commit is contained in:
parent
e756452c40
commit
cd1f3480a6
@ -84,13 +84,14 @@ d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS ) \
|
#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_ALPHA ) \
|
||||||
( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \
|
( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \
|
||||||
( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \
|
( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \
|
||||||
( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \
|
( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \
|
||||||
( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \
|
( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \
|
||||||
( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \
|
( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \
|
||||||
( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) )
|
( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) | \
|
||||||
|
d_ALPHA )
|
||||||
|
|
||||||
|
|
||||||
// - BitmapColor -
|
// - BitmapColor -
|
||||||
@ -215,12 +216,16 @@ class VCL_DLLPUBLIC ColorMask
|
|||||||
sal_uLong mnROr;
|
sal_uLong mnROr;
|
||||||
sal_uLong mnGOr;
|
sal_uLong mnGOr;
|
||||||
sal_uLong mnBOr;
|
sal_uLong mnBOr;
|
||||||
|
sal_uLong mnAlphaChannel;
|
||||||
|
|
||||||
SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const;
|
SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline ColorMask( sal_uLong nRedMask = 0UL, sal_uLong nGreenMask = 0UL, sal_uLong nBlueMask = 0UL );
|
inline ColorMask( sal_uLong nRedMask = 0UL,
|
||||||
|
sal_uLong nGreenMask = 0UL,
|
||||||
|
sal_uLong nBlueMask = 0UL,
|
||||||
|
sal_uLong nAlphaChannel = 0UL );
|
||||||
inline ~ColorMask() {}
|
inline ~ColorMask() {}
|
||||||
|
|
||||||
inline sal_uLong GetRedMask() const;
|
inline sal_uLong GetRedMask() const;
|
||||||
@ -698,7 +703,10 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask ) :
|
inline ColorMask::ColorMask( sal_uLong nRedMask,
|
||||||
|
sal_uLong nGreenMask,
|
||||||
|
sal_uLong nBlueMask,
|
||||||
|
sal_uLong nAlphaChannel ) :
|
||||||
mnRMask( nRedMask ),
|
mnRMask( nRedMask ),
|
||||||
mnGMask( nGreenMask ),
|
mnGMask( nGreenMask ),
|
||||||
mnBMask( nBlueMask ),
|
mnBMask( nBlueMask ),
|
||||||
@ -707,7 +715,8 @@ inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong
|
|||||||
mnBOrShift( 0L ),
|
mnBOrShift( 0L ),
|
||||||
mnROr( 0L ),
|
mnROr( 0L ),
|
||||||
mnGOr( 0L ),
|
mnGOr( 0L ),
|
||||||
mnBOr( 0L )
|
mnBOr( 0L ),
|
||||||
|
mnAlphaChannel( nAlphaChannel )
|
||||||
{
|
{
|
||||||
mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L );
|
mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L );
|
||||||
mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L );
|
mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L );
|
||||||
@ -774,7 +783,7 @@ inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel
|
|||||||
|
|
||||||
inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
||||||
{
|
{
|
||||||
*pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
|
*pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -790,7 +799,7 @@ inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPi
|
|||||||
|
|
||||||
inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const
|
inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const
|
||||||
{
|
{
|
||||||
const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
|
const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
|
||||||
|
|
||||||
pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
|
pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
|
||||||
pPixel[ 1 ] = (sal_uInt8) nVal;
|
pPixel[ 1 ] = (sal_uInt8) nVal;
|
||||||
@ -809,7 +818,7 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPi
|
|||||||
|
|
||||||
inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const
|
inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const
|
||||||
{
|
{
|
||||||
const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
|
const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
|
||||||
|
|
||||||
pPixel[ 0 ] = (sal_uInt8) nVal;
|
pPixel[ 0 ] = (sal_uInt8) nVal;
|
||||||
pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
|
pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
|
||||||
@ -828,7 +837,7 @@ inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel
|
|||||||
|
|
||||||
inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
||||||
{
|
{
|
||||||
const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
|
const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
|
||||||
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
|
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +866,7 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8&
|
|||||||
|
|
||||||
inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
|
||||||
{
|
{
|
||||||
const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
|
const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
|
||||||
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
|
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
|
||||||
pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL );
|
pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL );
|
||||||
}
|
}
|
||||||
|
@ -188,36 +188,36 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
|
|||||||
nBitCount = 32;
|
nBitCount = 32;
|
||||||
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
||||||
#ifdef OSL_BIGENDIAN
|
#ifdef OSL_BIGENDIAN
|
||||||
pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
|
pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
|
||||||
#else
|
#else
|
||||||
pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
|
pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
|
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
|
||||||
nBitCount = 32;
|
nBitCount = 32;
|
||||||
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
||||||
#ifdef OSL_BIGENDIAN
|
#ifdef OSL_BIGENDIAN
|
||||||
pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
|
pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
|
||||||
#else
|
#else
|
||||||
pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
|
pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
|
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
|
||||||
nBitCount = 32;
|
nBitCount = 32;
|
||||||
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
||||||
#ifdef OSL_BIGENDIAN
|
#ifdef OSL_BIGENDIAN
|
||||||
pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
|
pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
|
||||||
#else
|
#else
|
||||||
pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
|
pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
|
case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
|
||||||
nBitCount = 32;
|
nBitCount = 32;
|
||||||
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
|
||||||
#ifdef OSL_BIGENDIAN
|
#ifdef OSL_BIGENDIAN
|
||||||
pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
|
pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
|
||||||
#else
|
#else
|
||||||
pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
|
pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
|
|||||||
|
|
||||||
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
|
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
|
||||||
{
|
{
|
||||||
*( pScanline = pScanline + ( nX << 2 ) )++ = 0;
|
*( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
|
||||||
*pScanline++ = rBitmapColor.GetBlue();
|
*pScanline++ = rBitmapColor.GetBlue();
|
||||||
*pScanline++ = rBitmapColor.GetGreen();
|
*pScanline++ = rBitmapColor.GetGreen();
|
||||||
*pScanline = rBitmapColor.GetRed();
|
*pScanline = rBitmapColor.GetRed();
|
||||||
@ -198,7 +198,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
|
|||||||
|
|
||||||
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
|
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
|
||||||
{
|
{
|
||||||
*( pScanline = pScanline + ( nX << 2 ) )++ = 0;
|
*( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
|
||||||
*pScanline++ = rBitmapColor.GetRed();
|
*pScanline++ = rBitmapColor.GetRed();
|
||||||
*pScanline++ = rBitmapColor.GetGreen();
|
*pScanline++ = rBitmapColor.GetGreen();
|
||||||
*pScanline = rBitmapColor.GetBlue();
|
*pScanline = rBitmapColor.GetBlue();
|
||||||
@ -220,7 +220,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
|
|||||||
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
|
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
|
||||||
*pScanline++ = rBitmapColor.GetGreen();
|
*pScanline++ = rBitmapColor.GetGreen();
|
||||||
*pScanline++ = rBitmapColor.GetRed();
|
*pScanline++ = rBitmapColor.GetRed();
|
||||||
*pScanline = 0;
|
*pScanline = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
|
IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
|
||||||
@ -239,7 +239,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
|
|||||||
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
|
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
|
||||||
*pScanline++ = rBitmapColor.GetGreen();
|
*pScanline++ = rBitmapColor.GetGreen();
|
||||||
*pScanline++ = rBitmapColor.GetBlue();
|
*pScanline++ = rBitmapColor.GetBlue();
|
||||||
*pScanline = 0;
|
*pScanline = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
|
IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user