[Libreoffice-commits] core.git: drawinglayer/source emfio/source filter/source include/vcl svx/source vcl/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Mar 1 11:40:30 UTC 2018
drawinglayer/source/primitive2d/sceneprimitive2d.cxx | 2 -
emfio/source/reader/wmfreader.cxx | 2 -
filter/source/graphicfilter/icgm/bitmap.cxx | 2 -
filter/source/graphicfilter/ieps/ieps.cxx | 2 -
filter/source/graphicfilter/ipbm/ipbm.cxx | 6 +--
filter/source/graphicfilter/ipcd/ipcd.cxx | 2 -
filter/source/graphicfilter/ipcx/ipcx.cxx | 2 -
filter/source/graphicfilter/ipict/ipict.cxx | 10 ++---
filter/source/graphicfilter/ipsd/ipsd.cxx | 2 -
filter/source/graphicfilter/iras/iras.cxx | 2 -
filter/source/graphicfilter/itga/itga.cxx | 2 -
filter/source/msfilter/msdffimp.cxx | 4 +-
include/vcl/BitmapTools.hxx | 23 ++++++++----
svx/source/xoutdev/xattrbmp.cxx | 2 -
vcl/source/bitmap/BitmapTools.cxx | 35 +++++++++++++++----
15 files changed, 65 insertions(+), 33 deletions(-)
New commits:
commit 3d400321910ff0fe89ab8c70c59432e676cb1340
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Mar 1 12:00:24 2018 +0200
tdf#116001 Incorrect Colors in Chart Wall Area
regression from
commit b10c7022f1be6e4825269bd5872575b5b53744ef
"use RawBitmap in BPixelRasterToBitmapEx"
we need to implement alpha support in vcl::bitmap::CreateFromData
Change-Id: I68bebbe1dd15e3bb04de312309c1631d6bb7fe2d
Reviewed-on: https://gerrit.libreoffice.org/50556
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index 5d3e972a6592..98fb19bfe172 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -49,7 +49,7 @@ namespace
if(nWidth && nHeight)
{
const Size aDestSize(nWidth, nHeight);
- vcl::bitmap::RawBitmap aContent(aDestSize);
+ vcl::bitmap::RawBitmap aContent(aDestSize, 32);
if(mnAntiAlialize)
{
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index 7b5d8c6eb7ac..e82d756f28b2 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -715,7 +715,7 @@ namespace emfio
}
if (bOk)
{
- vcl::bitmap::RawBitmap aBmp( Size( nWidth, nHeight ) );
+ vcl::bitmap::RawBitmap aBmp( Size( nWidth, nHeight ), 24 );
for (sal_uInt16 y = 0; y < nHeight && mpInputStream->good(); ++y)
{
sal_uInt16 x = 0;
diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index c98a6b5ac76e..a1ee269a408c 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -69,7 +69,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
if (!(ImplGetDimensions(rDesc) && rDesc.mpBuf && isLegalBitsPerPixel(rDesc.mnDstBitsPerPixel)))
return;
- vcl::bitmap::RawBitmap aBitmap( Size( rDesc.mnX, rDesc.mnY ) );
+ vcl::bitmap::RawBitmap aBitmap( Size( rDesc.mnX, rDesc.mnY ), 24 );
// the picture may either be read from left to right or right to left, from top to bottom ...
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index ee634180c1f1..cf398e481e78 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -662,7 +662,7 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
{
rStream.Seek( nBufStartPos + ( pDest - pBuf.get() ) );
- vcl::bitmap::RawBitmap aBitmap( Size( nWidth, nHeight ) );
+ vcl::bitmap::RawBitmap aBitmap( Size( nWidth, nHeight ), 24 );
{
bool bIsValid = true;
sal_uInt8 nDat = 0;
diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/filter/source/graphicfilter/ipbm/ipbm.cxx
index 06f51d0e9bac..ee50754e30ae 100644
--- a/filter/source/graphicfilter/ipbm/ipbm.cxx
+++ b/filter/source/graphicfilter/ipbm/ipbm.cxx
@@ -92,7 +92,7 @@ bool PBMReader::ReadPBM(Graphic & rGraphic )
if (nRemainingSize < nPixelsRequired / 8)
return false;
- mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ) ) );
+ mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ), 24 ) );
mvPalette.resize( 2 );
mvPalette[0] = Color( 0xff, 0xff, 0xff );
mvPalette[1] = Color( 0x00, 0x00, 0x00 );
@@ -102,7 +102,7 @@ bool PBMReader::ReadPBM(Graphic & rGraphic )
if (nRemainingSize < nPixelsRequired)
return false;
- mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ) ) );
+ mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ), 24 ) );
mnCol = static_cast<sal_uInt16>(mnMaxVal) + 1;
if ( mnCol > 256 )
mnCol = 256;
@@ -118,7 +118,7 @@ bool PBMReader::ReadPBM(Graphic & rGraphic )
if (nRemainingSize / 3 < nPixelsRequired)
return false;
- mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ) ) );
+ mpRawBmp.reset( new vcl::bitmap::RawBitmap( Size( mnWidth, mnHeight ), 24 ) );
break;
}
diff --git a/filter/source/graphicfilter/ipcd/ipcd.cxx b/filter/source/graphicfilter/ipcd/ipcd.cxx
index 18b6d99b2c42..cd2f306b499d 100644
--- a/filter/source/graphicfilter/ipcd/ipcd.cxx
+++ b/filter/source/graphicfilter/ipcd/ipcd.cxx
@@ -148,7 +148,7 @@ bool PCDReader::ReadPCD( Graphic & rGraphic, FilterConfigItem* pConfigItem )
nBMPWidth = nHeight;
nBMPHeight = nWidth;
}
- mpBitmap.reset(new vcl::bitmap::RawBitmap( Size( nBMPWidth, nBMPHeight ) ));
+ mpBitmap.reset(new vcl::bitmap::RawBitmap( Size( nBMPWidth, nBMPHeight ), 24 ));
ReadImage();
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index 51b50be2fa56..3a4e8a64b73f 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -105,7 +105,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
// Write BMP header and conditionally (maybe invalid for now) color palette:
if (bStatus)
{
- mpBitmap.reset( new vcl::bitmap::RawBitmap( Size( nWidth, nHeight ) ) );
+ mpBitmap.reset( new vcl::bitmap::RawBitmap( Size( nWidth, nHeight ), 24 ) );
if ( nDestBitsPerPixel <= 8 )
{
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index 193c18656d62..d6e37740dff1 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -850,7 +850,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
return 0xffffffff;
}
- pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight) ));
+ pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight), 24 ));
for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{
@@ -932,7 +932,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
return 0xffffffff;
}
- pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight) ));
+ pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight), 24 ));
for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{
@@ -1027,7 +1027,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
if (nWidth > nMaxCols)
return 0xffffffff;
- pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight) ));
+ pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight), 24 ));
for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{
@@ -1050,7 +1050,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
if (nWidth > nMaxCols)
return 0xffffffff;
- pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight) ));
+ pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight), 24 ));
for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{
@@ -1072,7 +1072,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
if (nHeight > pPict->remainingSize() / nByteCountSize)
return 0xffffffff;
- pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight) ));
+ pBitmap.reset(new vcl::bitmap::RawBitmap( Size(nWidth, nHeight), 24 ));
size_t nByteWidth = static_cast<size_t>(nWidth) * nCmpCount;
std::vector<sal_uInt8> aScanline(nByteWidth);
diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx
index 8510ee9b583e..b5b4a81d3bf2 100644
--- a/filter/source/graphicfilter/ipsd/ipsd.cxx
+++ b/filter/source/graphicfilter/ipsd/ipsd.cxx
@@ -115,7 +115,7 @@ bool PSDReader::ReadPSD(Graphic & rGraphic )
}
Size aBitmapSize( mpFileHeader->nColumns, mpFileHeader->nRows );
- mpBitmap.reset( new vcl::bitmap::RawBitmap( aBitmapSize ) );
+ mpBitmap.reset( new vcl::bitmap::RawBitmap( aBitmapSize, 24 ) );
if ( mpPalette && mbStatus )
{
mvPalette.resize( 256 );
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index d12e4f92ad82..1908afb6273c 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -173,7 +173,7 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
if (m_rRAS.remainingSize() * nMaxCompression < nBitSize / 8)
return false;
- vcl::bitmap::RawBitmap aBmp(Size(mnWidth, mnHeight));
+ vcl::bitmap::RawBitmap aBmp(Size(mnWidth, mnHeight), 24);
// read in the bitmap data
mbStatus = ImplReadBody(aBmp, aPalette);
diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx
index 28cfb8dd25b8..000237069556 100644
--- a/filter/source/graphicfilter/itga/itga.cxx
+++ b/filter/source/graphicfilter/itga/itga.cxx
@@ -146,7 +146,7 @@ bool TGAReader::ReadTGA(Graphic & rGraphic)
if (nSize > SAL_MAX_INT32/2/3)
return false;
- mpBitmap.reset( new vcl::bitmap::RawBitmap( Size( mpFileHeader->nImageWidth, mpFileHeader->nImageHeight ) ) );
+ mpBitmap.reset( new vcl::bitmap::RawBitmap( Size( mpFileHeader->nImageWidth, mpFileHeader->nImageHeight ), 24 ) );
if ( mbIndexing )
mbStatus = ImplReadPalette();
if ( mbStatus )
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 12e8cdb6b005..89404f1a986a 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1109,7 +1109,7 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
double fFocusX = rManager.GetPropertyValue( DFF_Prop_fillToRight, 0 ) / 65536.0;
double fFocusY = rManager.GetPropertyValue( DFF_Prop_fillToBottom, 0 ) / 65536.0;
- vcl::bitmap::RawBitmap aBitmap(aBitmapSizePixel);
+ vcl::bitmap::RawBitmap aBitmap(aBitmapSizePixel, 24);
for ( long nY = 0; nY < aBitmapSizePixel.Height(); nY++ )
{
@@ -1364,7 +1364,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor, 0 ), DFF_Prop_fillBackColor );
// Create a bitmap for the pattern with expected colors
- vcl::bitmap::RawBitmap aResult(Size(8, 8));
+ vcl::bitmap::RawBitmap aResult(Size(8, 8), 24);
{
Bitmap::ScopedReadAccess pRead(aBmp);
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index cf790e85be14..51088b0fefa1 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -30,28 +30,37 @@ class VCL_DLLPUBLIC RawBitmap
friend BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap&& rawBitmap );
std::unique_ptr<sal_uInt8[]> mpData;
Size maSize;
+ sal_uInt8 mnBitCount;
public:
- RawBitmap(Size const & rSize)
- : mpData(new sal_uInt8[ rSize.getWidth() * 3 * rSize.getHeight()]),
- maSize(rSize)
+ RawBitmap(Size const & rSize, sal_uInt8 nBitCount)
+ : mpData(new sal_uInt8[ rSize.getWidth() * nBitCount/8 * rSize.getHeight()]),
+ maSize(rSize),
+ mnBitCount(nBitCount)
{
+ assert(nBitCount == 24 || nBitCount == 32);
}
void SetPixel(long nY, long nX, Color nColor)
{
- long p = (nY * maSize.getWidth() + nX) * 3;
+ long p = (nY * maSize.getWidth() + nX) * (mnBitCount/8);
mpData[ p++ ] = nColor.GetRed();
mpData[ p++ ] = nColor.GetGreen();
- mpData[ p ] = nColor.GetBlue();
+ mpData[ p++ ] = nColor.GetBlue();
+ if (mnBitCount == 32)
+ mpData[ p ] = nColor.GetTransparency();
}
Color GetPixel(long nY, long nX) const
{
- long p = (nY * maSize.getWidth() + nX) * 3;
- return Color( mpData[p], mpData[p+1], mpData[p+2]);
+ long p = (nY * maSize.getWidth() + nX) * mnBitCount/8;
+ if (mnBitCount == 24)
+ return Color( mpData[p], mpData[p+1], mpData[p+2]);
+ else
+ return Color( mpData[p+3], mpData[p], mpData[p+1], mpData[p+2]);
}
// so we don't accidentally leave any code in that uses palette color indexes
void SetPixel(long nY, long nX, BitmapColor nColor) = delete;
long Height() { return maSize.Height(); }
long Width() { return maSize.Width(); }
+ sal_uInt8 GetBitCount() { return mnBitCount; }
};
BitmapEx VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index ed65981097f3..bad890bdc1a5 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -145,7 +145,7 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack)
{
- vcl::bitmap::RawBitmap aBitmap(Size(8, 8));
+ vcl::bitmap::RawBitmap aBitmap(Size(8, 8), 24);
for(sal_uInt16 a(0); a < 8; a++)
{
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index a171fd848a39..beda990e5b03 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -148,7 +148,7 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
{
for( long y = 0; y < nHeight; ++y )
{
- sal_uInt8 const *p = pData + y * nStride;
+ sal_uInt8 const *p = pData + (y * nStride);
Scanline pScanline = pWrite->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
@@ -158,7 +158,7 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
}
if (nBitCount == 32)
{
- p = pData + y * nStride + 3;
+ p = pData + (y * nStride) + 3;
Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
@@ -179,27 +179,50 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
*/
BitmapEx CreateFromData( RawBitmap&& rawBitmap )
{
- Bitmap aBmp( rawBitmap.maSize, /*nBitCount*/24 );
+ auto nBitCount = rawBitmap.GetBitCount();
+ assert( nBitCount == 24 || nBitCount == 32);
+ Bitmap aBmp( rawBitmap.maSize, nBitCount );
Bitmap::ScopedWriteAccess pWrite(aBmp);
assert(pWrite.get());
if( !pWrite )
return BitmapEx();
+ std::unique_ptr<AlphaMask> pAlphaMask;
+ AlphaMask::ScopedWriteAccess xMaskAcc;
+ if (nBitCount == 32)
+ {
+ pAlphaMask.reset( new AlphaMask( rawBitmap.maSize ) );
+ xMaskAcc = AlphaMask::ScopedWriteAccess(*pAlphaMask);
+ }
auto nHeight = rawBitmap.maSize.getHeight();
auto nWidth = rawBitmap.maSize.getWidth();
+ auto nStride = nWidth * nBitCount / 8;
for( long y = 0; y < nHeight; ++y )
{
- sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nWidth * 3);
+ sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nStride);
Scanline pScanline = pWrite->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
BitmapColor col(p[0], p[1], p[2]);
pWrite->SetPixelOnData(pScanline, x, col);
- p += 3;
+ p += nBitCount/8;
+ }
+ if (nBitCount == 32)
+ {
+ p = rawBitmap.mpData.get() + (y * nStride) + 3;
+ Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
+ for (long x = 0; x < nWidth; ++x)
+ {
+ xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p));
+ p += 4;
+ }
}
}
- return aBmp;
+ if (nBitCount == 32)
+ return BitmapEx(aBmp, *pAlphaMask);
+ else
+ return aBmp;
}
#if ENABLE_CAIRO_CANVAS
More information about the Libreoffice-commits
mailing list