summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpbmp.cxx91
-rw-r--r--vcl/opengl/salbmp.cxx48
-rw-r--r--vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmpbin0 -> 632 bytes
-rw-r--r--vcl/quartz/salbmp.cxx46
-rw-r--r--vcl/source/gdi/dibtools.cxx24
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx36
-rw-r--r--vcl/win/source/gdi/salbmp.cxx30
7 files changed, 230 insertions, 45 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 3231043a882f..30f6a56323fa 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -172,65 +172,130 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode )
pBuf->mnFormat = BMP_FORMAT_8BIT_PAL;
break;
case Format::SixteenBitLsbTcMask:
+ {
nBitCount = 16;
pBuf->mnFormat = BMP_FORMAT_16BIT_TC_LSB_MASK;
- pBuf->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
case Format::SixteenBitMsbTcMask:
+ {
nBitCount = 16;
pBuf->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK;
- pBuf->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
case Format::TwentyFourBitTcMask:
nBitCount = 24;
pBuf->mnFormat = BMP_FORMAT_24BIT_TC_BGR;
break;
case Format::ThirtyTwoBitTcMaskBGRX:
+ {
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ ColorMaskElement aRedMask(0x0000ff00);
+ ColorMaskElement aGreenMask(0x00ff0000);
+ ColorMaskElement aBlueMask(0xff000000);
#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ ColorMaskElement aRedMask(0x00ff0000);
+ ColorMaskElement aGreenMask(0x0000ff00);
+ ColorMaskElement aBlueMask(0x000000ff);
#endif
+ aBlueMask.CalcMaskShift();
+ aRedMask.CalcMaskShift();
+ aGreenMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
case Format::ThirtyTwoBitTcMaskBGRA:
+ {
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
+ ColorMaskElement aRedMask(0x0000ff00);
+ ColorMaskElement aGreenMask(0x00ff0000);
+ ColorMaskElement aBlueMask(0xff000000);
#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
+ ColorMaskElement aRedMask(0x00ff0000);
+ ColorMaskElement aGreenMask(0x0000ff00);
+ ColorMaskElement aBlueMask(0x000000ff);
#endif
+ aBlueMask.CalcMaskShift();
+ aRedMask.CalcMaskShift();
+ aGreenMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, 0xff000000);
break;
+ }
case Format::ThirtyTwoBitTcMaskARGB:
+ {
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
+ ColorMaskElement aRedMask(0x00ff0000);
+ ColorMaskElement aGreenMask(0x0000ff00);
+ ColorMaskElement aBlueMask(0x000000ff);
#else
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
+ ColorMaskElement aRedMask(0x0000ff00);
+ ColorMaskElement aGreenMask(0x00ff0000);
+ ColorMaskElement aBlueMask(0xff000000);
#endif
+ aBlueMask.CalcMaskShift();
+ aRedMask.CalcMaskShift();
+ aGreenMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, 0xff000000 );
break;
+ }
case Format::ThirtyTwoBitTcMaskABGR:
+ {
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
+ ColorMaskElement aRedMask(0x000000ff);
+ ColorMaskElement aGreenMask(0x0000ff00);
+ ColorMaskElement aBlueMask(0x00ff0000);
#else
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
+ ColorMaskElement aRedMask(0xff000000);
+ ColorMaskElement aGreenMask(0x00ff0000);
+ ColorMaskElement aBlueMask(0x0000ff00);
#endif
+ aBlueMask.CalcMaskShift();
+ aRedMask.CalcMaskShift();
+ aGreenMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, 0xff000000);
break;
+ }
case Format::ThirtyTwoBitTcMaskRGBA:
+ {
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
+ ColorMaskElement aRedMask(0xff000000);
+ ColorMaskElement aGreenMask(0x00ff0000);
+ ColorMaskElement aBlueMask(0x0000ff00);
#else
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
+ ColorMaskElement aRedMask(0x000000ff);
+ ColorMaskElement aGreenMask(0x0000ff00);
+ ColorMaskElement aBlueMask(0x00ff0000);
#endif
+ aBlueMask.CalcMaskShift();
+ aRedMask.CalcMaskShift();
+ aGreenMask.CalcMaskShift();
+ pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, 0x000000ff);
break;
-
+ }
default:
// this is an error case !!!!!
nBitCount = 1;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 286c4632837a..6144d9a04b2e 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -709,18 +709,44 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
pBuffer->mnScanlineSize = mnBytesPerRow;
pBuffer->mpBits = maUserBuffer.get();
pBuffer->mnBitCount = mnBits;
- switch( mnBits )
+ switch (mnBits)
{
- case 1: pBuffer->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; break;
- case 4: pBuffer->mnFormat = BMP_FORMAT_4BIT_MSN_PAL; break;
- case 8: pBuffer->mnFormat = BMP_FORMAT_8BIT_PAL; break;
- case 16: pBuffer->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK;
- pBuffer->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
- break;
- case 24: pBuffer->mnFormat = BMP_FORMAT_24BIT_TC_RGB; break;
- case 32: pBuffer->mnFormat = BMP_FORMAT_32BIT_TC_RGBA;
- pBuffer->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
- break;
+ case 1:
+ pBuffer->mnFormat = BMP_FORMAT_1BIT_MSB_PAL;
+ break;
+ case 4:
+ pBuffer->mnFormat = BMP_FORMAT_4BIT_MSN_PAL;
+ break;
+ case 8:
+ pBuffer->mnFormat = BMP_FORMAT_8BIT_PAL;
+ break;
+ case 16:
+ {
+ pBuffer->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK;
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ break;
+ }
+ case 24:
+ pBuffer->mnFormat = BMP_FORMAT_24BIT_TC_RGB;
+ break;
+ case 32:
+ {
+ pBuffer->mnFormat = BMP_FORMAT_32BIT_TC_RGBA;
+ ColorMaskElement aRedMask(0xff000000);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x00ff0000);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x0000ff00);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ break;
+ }
}
return pBuffer;
diff --git a/vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmp b/vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmp
new file mode 100644
index 000000000000..84b6c35c87e6
--- /dev/null
+++ b/vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmp
Binary files differ
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index 8463d06b0bf5..6699e8038308 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -759,16 +759,42 @@ BitmapBuffer* QuartzSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
pBuffer->mnBitCount = mnBits;
switch( mnBits )
{
- case 1: pBuffer->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; break;
- case 4: pBuffer->mnFormat = BMP_FORMAT_4BIT_MSN_PAL; break;
- case 8: pBuffer->mnFormat = BMP_FORMAT_8BIT_PAL; break;
- case 16: pBuffer->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK;
- pBuffer->maColorMask = ColorMask( k16BitRedColorMask, k16BitGreenColorMask, k16BitBlueColorMask );
- break;
- case 24: pBuffer->mnFormat = BMP_FORMAT_24BIT_TC_BGR; break;
- case 32: pBuffer->mnFormat = BMP_FORMAT_32BIT_TC_ARGB;
- pBuffer->maColorMask = ColorMask( k32BitRedColorMask, k32BitGreenColorMask, k32BitBlueColorMask );
- break;
+ case 1:
+ pBuffer->mnFormat = BMP_FORMAT_1BIT_MSB_PAL;
+ break;
+ case 4:
+ pBuffer->mnFormat = BMP_FORMAT_4BIT_MSN_PAL;
+ break;
+ case 8:
+ pBuffer->mnFormat = BMP_FORMAT_8BIT_PAL;
+ break;
+ case 16:
+ {
+ pBuffer->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK;
+ ColorMaskElement aRedMask(k16BitRedColorMask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(k16BitGreenColorMask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(k16BitBlueColorMask);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ break;
+ }
+ case 24:
+ pBuffer->mnFormat = BMP_FORMAT_24BIT_TC_BGR;
+ break;
+ case 32:
+ {
+ pBuffer->mnFormat = BMP_FORMAT_32BIT_TC_ARGB;
+ ColorMaskElement aRedMask(k32BitRedColorMask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(k32BitGreenColorMask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(k32BitBlueColorMask);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ break;
+ }
}
pBuffer->mnFormat |= BMP_FORMAT_BOTTOM_UP;
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index d597ee15d1b9..bbd2658059fd 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -596,7 +596,17 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
case( 16 ):
{
- ColorMask aMask( nRMask, nGMask, nBMask );
+ ColorMaskElement aRedMask(nRMask);
+ if (!aRedMask.CalcMaskShift())
+ return false;
+ ColorMaskElement aGreenMask(nGMask);
+ if (!aGreenMask.CalcMaskShift())
+ return false;
+ ColorMaskElement aBlueMask(nBMask);
+ if (!aBlueMask.CalcMaskShift())
+ return false;
+
+ ColorMask aMask(aRedMask, aGreenMask, aBlueMask);
BitmapColor aColor;
sal_uInt16* pTmp16;
@@ -643,7 +653,17 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
case( 32 ):
{
- ColorMask aMask(nRMask, nGMask, nBMask);
+ ColorMaskElement aRedMask(nRMask);
+ if (!aRedMask.CalcMaskShift())
+ return false;
+ ColorMaskElement aGreenMask(nGMask);
+ if (!aGreenMask.CalcMaskShift())
+ return false;
+ ColorMaskElement aBlueMask(nBMask);
+ if (!aBlueMask.CalcMaskShift())
+ return false;
+ ColorMask aMask(aRedMask, aGreenMask, aBlueMask);
+
BitmapColor aColor;
sal_uInt32* pTmp32;
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index c6c156b2c29b..82044492904f 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -154,14 +154,30 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
case( 8 ): pDIB->mnFormat |= BMP_FORMAT_8BIT_PAL; break;
#ifdef OSL_BIGENDIAN
case(16 ):
+ {
pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_MSB_MASK;
- pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pDIB->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
#else
case(16 ):
+ {
pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_LSB_MASK;
- pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ ColorMaskElement aRedMask(0xf800);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x07e0);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x001f);
+ aBlueMask.CalcMaskShift();
+ pDIB->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
break;
+ }
#endif
default:
nBitCount = 24;
@@ -274,7 +290,13 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
case( 16 ):
{
- aSrcBuf.maColorMask = ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
+ ColorMaskElement aRedMask(pImage->red_mask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(pImage->green_mask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(pImage->blue_mask);
+ aBlueMask.CalcMaskShift();
+ aSrcBuf.maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
if( LSBFirst == pImage->byte_order )
{
@@ -444,7 +466,13 @@ XImage* X11SalBitmap::ImplCreateXImage(
#endif
- xMask.reset(new ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask ));
+ ColorMaskElement aRedMask(pImage->red_mask);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(pImage->green_mask);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(pImage->blue_mask);
+ aBlueMask.CalcMaskShift();
+ xMask.reset(new ColorMask(aRedMask, aGreenMask, aBlueMask));
}
break;
diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index 014700570d45..eeaa1cd49aec 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -906,14 +906,34 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
if( pBIH->biCompression == BI_BITFIELDS )
{
nOffset = 3 * sizeof( RGBQUAD );
- pBuffer->maColorMask = ColorMask( *(UINT32*) &pBI->bmiColors[ 0 ],
- *(UINT32*) &pBI->bmiColors[ 1 ],
- *(UINT32*) &pBI->bmiColors[ 2 ] );
+ ColorMaskElement aRedMask(*(UINT32*) &pBI->bmiColors[ 0 ]);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(*(UINT32*) &pBI->bmiColors[ 1 ]);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(*(UINT32*) &pBI->bmiColors[ 2 ]);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
}
else if( pBIH->biBitCount == 16 )
- pBuffer->maColorMask = ColorMask( 0x00007c00UL, 0x000003e0UL, 0x0000001fUL );
+ {
+ ColorMaskElement aRedMask(0x00007c00UL);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x000003e0UL);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x0000001fUL);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ }
else
- pBuffer->maColorMask = ColorMask( 0x00ff0000UL, 0x0000ff00UL, 0x000000ffUL );
+ {
+ ColorMaskElement aRedMask(0x00ff0000UL);
+ aRedMask.CalcMaskShift();
+ ColorMaskElement aGreenMask(0x0000ff00UL);
+ aGreenMask.CalcMaskShift();
+ ColorMaskElement aBlueMask(0x000000ffUL);
+ aBlueMask.CalcMaskShift();
+ pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+ }
pBuffer->mpBits = (PBYTE) pBI + *(DWORD*) pBI + nOffset;
}