ofz: speed up bitmap image fuzzing

Change-Id: I73c9ee7aef7062e3cb025c6ae0f3bb6a91485330
Reviewed-on: https://gerrit.libreoffice.org/48983
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-01-31 10:32:11 +00:00
parent 96ae2a3300
commit a3251b83e3
8 changed files with 126 additions and 95 deletions

View File

@@ -182,10 +182,11 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
for( int y = 0; y < nHeight; ++y ) for( int y = 0; y < nHeight; ++y )
{ {
sal_uInt8 *p = pData + y * nStride; sal_uInt8 *p = pData + y * nStride;
Scanline pScanline = pWrite->GetScanline(y);
for (int x = 0; x < nWidth; ++x) for (int x = 0; x < nWidth; ++x)
{ {
BitmapColor col(p[0], p[1], p[2]); BitmapColor col(p[0], p[1], p[2]);
pWrite->SetPixel( y, x, col ); pWrite->SetPixelOnData(pScanline, x, col);
p += 3; p += 3;
} }
} }

View File

@@ -94,9 +94,10 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
for ( ny = 0; --nyCount ; ny++, rDesc.mpBuf += rDesc.mnScanSize ) for ( ny = 0; --nyCount ; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{ {
nxC = nxCount; nxC = nxCount;
Scanline pScanline = rDesc.mpAcc->GetScanline(ny);
for ( nx = 0; --nxC; nx++ ) for ( nx = 0; --nxC; nx++ )
{ // this is not fast, but a one bit/pixel format is rarely used { // this is not fast, but a one bit/pixel format is rarely used
rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*( rDesc.mpBuf + (nx >> 3)) >> ((nx & 7)^7))) & 1 ); rDesc.mpAcc->SetPixelOnData(pScanline, nx, BitmapColor(static_cast<sal_uInt8>( (*( rDesc.mpBuf + (nx >> 3)) >> ((nx & 7)^7))) & 1));
} }
} }
} }
@@ -108,9 +109,10 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize ) for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{ {
nxC = nxCount; nxC = nxCount;
Scanline pScanline = rDesc.mpAcc->GetScanline(ny);
for ( nx = 0; --nxC; nx++ ) for ( nx = 0; --nxC; nx++ )
{ // this is not fast, but a two bits/pixel format is rarely used { // this is not fast, but a two bits/pixel format is rarely used
rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*(rDesc.mpBuf + (nx >> 2)) >> (((nx & 3)^3) << 1))) & 3 ); rDesc.mpAcc->SetPixelOnData(pScanline, nx, BitmapColor(static_cast<sal_uInt8>( (*(rDesc.mpBuf + (nx >> 2)) >> (((nx & 3)^3) << 1))) & 3));
} }
} }
} }
@@ -127,11 +129,12 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
for ( nx = 0; --nxC; nx++ ) for ( nx = 0; --nxC; nx++ )
{ {
nDat = *pTemp++; nDat = *pTemp++;
rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat >> 4) ); Scanline pScanline = rDesc.mpAcc->GetScanline(ny);
rDesc.mpAcc->SetPixelOnData(pScanline, nx, BitmapColor(static_cast<sal_uInt8>(nDat >> 4)));
if ( --nxC ) if ( --nxC )
{ {
nx ++; ++nx;
rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat & 15) ); rDesc.mpAcc->SetPixelOnData(pScanline, nx, BitmapColor(static_cast<sal_uInt8>(nDat & 15)));
} }
else else
break; break;
@@ -146,10 +149,11 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize ) for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{ {
sal_uInt8* pTemp = rDesc.mpBuf; sal_uInt8* pTemp = rDesc.mpBuf;
Scanline pScanline = rDesc.mpAcc->GetScanline(ny);
nxC = nxCount; nxC = nxCount;
for ( nx = 0; --nxC; nx++ ) for ( nx = 0; --nxC; nx++ )
{ {
rDesc.mpAcc->SetPixelIndex( ny, nx, *(pTemp++) ); rDesc.mpAcc->SetPixelOnData(pScanline, nx, BitmapColor(*(pTemp++)));
} }
} }
} }
@@ -162,12 +166,13 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
{ {
sal_uInt8* pTemp = rDesc.mpBuf; sal_uInt8* pTemp = rDesc.mpBuf;
nxC = nxCount; nxC = nxCount;
Scanline pScanline = rDesc.mpAcc->GetScanline(ny);
for ( nx = 0; --nxC; nx++ ) for ( nx = 0; --nxC; nx++ )
{ {
aBitmapColor.SetRed( *pTemp++ ); aBitmapColor.SetRed( *pTemp++ );
aBitmapColor.SetGreen( *pTemp++ ); aBitmapColor.SetGreen( *pTemp++ );
aBitmapColor.SetBlue( *pTemp++ ); aBitmapColor.SetBlue( *pTemp++ );
rDesc.mpAcc->SetPixel( ny, nx, aBitmapColor ); rDesc.mpAcc->SetPixelOnData(pScanline, nx, aBitmapColor);
} }
} }
} }

View File

@@ -240,6 +240,7 @@ private:
// OSNOLA: returns the text encoding which must be used for system id // OSNOLA: returns the text encoding which must be used for system id
static rtl_TextEncoding GetTextEncoding (sal_uInt16 fId = 0xFFFF); static rtl_TextEncoding GetTextEncoding (sal_uInt16 fId = 0xFFFF);
public: public:
PictReader() PictReader()
@@ -258,46 +259,46 @@ public:
}; };
static void SetByte(sal_uInt16& nx, Scanline pScanline, BitmapWriteAccess* pAcc, sal_uInt16 nPixelSize, sal_uInt8 nDat, sal_uInt16 nWidth)
#define SETBYTE \ {
switch ( nPixelSize ) \ switch (nPixelSize)
{ \ {
case 1 : \ case 1:
pAcc->SetPixelIndex( ny, nx++, nDat >> 7 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 7));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 6 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 6));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 5 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 5));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 4 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 4));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 3 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 3));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 2 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 2));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat >> 1 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 1));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat));
break; \ break;
case 2 : \ case 2:
pAcc->SetPixelIndex( ny, nx++, nDat >> 6 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 6));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, (nDat>>4)&3);\ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor((nDat>>4)&3));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, (nDat>>2)&3 );\ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor((nDat>>2)&3));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat & 3); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat & 3));
break; \ break;
case 4 : \ case 4:
pAcc->SetPixelIndex( ny, nx++, nDat >> 4 ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat >> 4));
if ( nx == nWidth ) break; \ if ( nx == nWidth ) break;
pAcc->SetPixelIndex( ny, nx++, nDat ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat));
break; \ break;
case 8 : \ case 8:
pAcc->SetPixelIndex( ny, nx++, nDat ); \ pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nDat));
break; \ break;
}
} }
#define BITMAPERROR \ #define BITMAPERROR \
{ \ { \
@@ -876,6 +877,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
for (sal_uInt16 ny = 0; ny < nHeight; ++ny) for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{ {
Scanline pScanline = pAcc->GetScanline(ny);
sal_uInt16 nx = 0; sal_uInt16 nx = 0;
if ( nRowBytes < 8 || nPackType == 1 ) if ( nRowBytes < 8 || nPackType == 1 )
{ {
@@ -883,7 +885,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
{ {
pPict->ReadUChar( nDat ); pPict->ReadUChar( nDat );
if ( nx < nWidth ) if ( nx < nWidth )
SETBYTE; SetByte(nx, pScanline, pAcc, nPixelSize, nDat, nWidth);
} }
nDataSize += nRowBytes; nDataSize += nRowBytes;
} }
@@ -914,7 +916,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
{ {
pPict->ReadUChar( nDat ); pPict->ReadUChar( nDat );
if ( nx < nWidth ) if ( nx < nWidth )
SETBYTE; SetByte(nx, pScanline, pAcc, nPixelSize, nDat, nWidth);
} }
nByteCount -= 1 + nCount; nByteCount -= 1 + nCount;
} }
@@ -925,7 +927,7 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
{ {
if ( nx < nWidth ) if ( nx < nWidth )
SETBYTE; SetByte(nx, pScanline, pAcc, nPixelSize, nDat, nWidth);
} }
nByteCount -= 2; nByteCount -= 2;
} }
@@ -962,13 +964,14 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
sal_uInt16 nx = 0; sal_uInt16 nx = 0;
if ( nRowBytes < 8 || nPackType == 1 ) if ( nRowBytes < 8 || nPackType == 1 )
{ {
Scanline pScanline = pAcc->GetScanline(ny);
for (size_t i = 0; i < nWidth; ++i) for (size_t i = 0; i < nWidth; ++i)
{ {
pPict->ReadUInt16( nD ); pPict->ReadUInt16( nD );
nRed = static_cast<sal_uInt8>( nD >> 7 ); nRed = static_cast<sal_uInt8>( nD >> 7 );
nGreen = static_cast<sal_uInt8>( nD >> 2 ); nGreen = static_cast<sal_uInt8>( nD >> 2 );
nBlue = static_cast<sal_uInt8>( nD << 3 ); nBlue = static_cast<sal_uInt8>( nD << 3 );
pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nRed, nGreen, nBlue));
} }
nDataSize += static_cast<sal_uLong>(nWidth) * 2; nDataSize += static_cast<sal_uLong>(nWidth) * 2;
} }
@@ -1001,13 +1004,14 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
this case. Have a look at 32bit, there I changed the this case. Have a look at 32bit, there I changed the
encoding, so that it is used a straight forward array encoding, so that it is used a straight forward array
*/ */
Scanline pScanline = pAcc->GetScanline(ny);
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
{ {
pPict->ReadUInt16( nD ); pPict->ReadUInt16( nD );
nRed = static_cast<sal_uInt8>( nD >> 7 ); nRed = static_cast<sal_uInt8>( nD >> 7 );
nGreen = static_cast<sal_uInt8>( nD >> 2 ); nGreen = static_cast<sal_uInt8>( nD >> 2 );
nBlue = static_cast<sal_uInt8>( nD << 3 ); nBlue = static_cast<sal_uInt8>( nD << 3 );
pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nRed, nGreen, nBlue));
} }
} }
else else
@@ -1021,9 +1025,10 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
nRed = static_cast<sal_uInt8>( nD >> 7 ); nRed = static_cast<sal_uInt8>( nD >> 7 );
nGreen = static_cast<sal_uInt8>( nD >> 2 ); nGreen = static_cast<sal_uInt8>( nD >> 2 );
nBlue = static_cast<sal_uInt8>( nD << 3 ); nBlue = static_cast<sal_uInt8>( nD << 3 );
Scanline pScanline = pAcc->GetScanline(ny);
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
{ {
pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(nRed, nGreen, nBlue));
} }
} }
} }
@@ -1056,11 +1061,12 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
for (sal_uInt16 ny = 0; ny < nHeight; ++ny) for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{ {
Scanline pScanline = pAcc->GetScanline(ny);
for (sal_uInt16 nx = 0; nx < nWidth; ++nx) for (sal_uInt16 nx = 0; nx < nWidth; ++nx)
{ {
sal_uInt8 nDummy; sal_uInt8 nDummy;
pPict->ReadUChar( nDummy ).ReadUChar( nRed ).ReadUChar( nGreen ).ReadUChar( nBlue ); pPict->ReadUChar( nDummy ).ReadUChar( nRed ).ReadUChar( nGreen ).ReadUChar( nBlue );
pAcc->SetPixel( ny, nx, BitmapColor( nRed, nGreen, nBlue) ); pAcc->SetPixelOnData(pScanline, nx, BitmapColor(nRed, nGreen, nBlue));
} }
nDataSize += static_cast<sal_uLong>(nWidth) * 4; nDataSize += static_cast<sal_uLong>(nWidth) * 4;
} }
@@ -1080,10 +1086,11 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
for (sal_uInt16 ny = 0; ny < nHeight; ++ny) for (sal_uInt16 ny = 0; ny < nHeight; ++ny)
{ {
Scanline pScanline = pAcc->GetScanline(ny);
for (sal_uInt16 nx = 0; nx < nWidth; ++nx) for (sal_uInt16 nx = 0; nx < nWidth; ++nx)
{ {
pPict->ReadUChar( nRed ).ReadUChar( nGreen ).ReadUChar( nBlue ); pPict->ReadUChar( nRed ).ReadUChar( nGreen ).ReadUChar( nBlue );
pAcc->SetPixel( ny, nx, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixelOnData(pScanline, nx, BitmapColor(nRed, nGreen, nBlue));
} }
nDataSize += static_cast<sal_uLong>(nWidth) * 3; nDataSize += static_cast<sal_uLong>(nWidth) * 3;
} }
@@ -1149,8 +1156,9 @@ sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, bool bBaseAddr, bool bColo
sal_uInt8* pTmp = aScanline.data(); sal_uInt8* pTmp = aScanline.data();
if ( nCmpCount == 4 ) if ( nCmpCount == 4 )
pTmp += nWidth; pTmp += nWidth;
Scanline pScanline = pAcc->GetScanline(ny);
for (sal_uInt16 nx = 0; nx < nWidth; pTmp++) for (sal_uInt16 nx = 0; nx < nWidth; pTmp++)
pAcc->SetPixel( ny, nx++, BitmapColor( *pTmp, pTmp[ nWidth ], pTmp[ 2 * nWidth ] ) ); pAcc->SetPixelOnData(pScanline, nx++, BitmapColor(*pTmp, pTmp[ nWidth ], pTmp[ 2 * nWidth ]));
nDataSize += static_cast<sal_uLong>(nByteCount); nDataSize += static_cast<sal_uLong>(nByteCount);
pPict->Seek( nSrcBitsPos + static_cast<sal_uLong>(nByteCount) ); pPict->Seek( nSrcBitsPos + static_cast<sal_uLong>(nByteCount) );
} }

View File

@@ -789,6 +789,10 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
{ {
sal_uInt8* pt = getMapData(0); sal_uInt8* pt = getMapData(0);
Scanline pMaskScanLine = nullptr;
if (nSamplesPerPixel >= 4 && xMaskAcc)
pMaskScanLine = xMaskAcc->GetScanline(nY);
// are the values being saved as difference? // are the values being saved as difference?
if ( 2 == nPredictor ) if ( 2 == nPredictor )
{ {
@@ -801,11 +805,11 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
nLRed = nLRed + pt[ 0 ]; nLRed = nLRed + pt[ 0 ];
nLGreen = nLGreen + pt[ 1 ]; nLGreen = nLGreen + pt[ 1 ];
nLBlue = nLBlue + pt[ 2 ]; nLBlue = nLBlue + pt[ 2 ];
pAcc->SetPixel( nY, nx, Color( nLRed, nLGreen, nLBlue ) ); pAcc->SetPixelOnData(pScanLine, nx, Color(nLRed, nLGreen, nLBlue));
if (nSamplesPerPixel >= 4 && xMaskAcc) if (pMaskScanLine)
{ {
nLAlpha = nLAlpha + pt[ 3 ]; nLAlpha = nLAlpha + pt[ 3 ];
xMaskAcc->SetPixel( nY, nx, BitmapColor(~nLAlpha) ); xMaskAcc->SetPixelOnData(pMaskScanLine, nx, BitmapColor(~nLAlpha));
} }
} }
} }
@@ -813,11 +817,11 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
{ {
for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel) for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel)
{ {
pAcc->SetPixel( nY, nx, Color( pt[0], pt[1], pt[2] ) ); pAcc->SetPixelOnData(pScanLine, nx, Color(pt[0], pt[1], pt[2]));
if (nSamplesPerPixel >= 4 && xMaskAcc) if (pMaskScanLine)
{ {
sal_uInt8 nAlpha = pt[3]; sal_uInt8 nAlpha = pt[3];
xMaskAcc->SetPixel( nY, nx, BitmapColor(~nAlpha) ); xMaskAcc->SetPixelOnData(pMaskScanLine, nx, BitmapColor(~nAlpha));
} }
} }
} }
@@ -841,7 +845,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
nGreen = GetBits( getMapData(1), nx * nBitsPerSample, nBitsPerSample ); nGreen = GetBits( getMapData(1), nx * nBitsPerSample, nBitsPerSample );
nBlue = GetBits( getMapData(2), nx * nBitsPerSample, nBitsPerSample ); nBlue = GetBits( getMapData(2), nx * nBitsPerSample, nBitsPerSample );
} }
pAcc->SetPixel( nY, nx, Color( static_cast<sal_uInt8>( nRed - nMinMax ), static_cast<sal_uInt8>( nGreen - nMinMax ), static_cast<sal_uInt8>(nBlue - nMinMax) ) ); pAcc->SetPixelOnData(pScanLine, nx, Color(static_cast<sal_uInt8>(nRed - nMinMax), static_cast<sal_uInt8>(nGreen - nMinMax), static_cast<sal_uInt8>(nBlue - nMinMax)));
} }
} }
} }
@@ -867,7 +871,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
nRed = 255 - static_cast<sal_uInt8>( nRed - nMinMax ); nRed = 255 - static_cast<sal_uInt8>( nRed - nMinMax );
nGreen = 255 - static_cast<sal_uInt8>( nGreen - nMinMax ); nGreen = 255 - static_cast<sal_uInt8>( nGreen - nMinMax );
nBlue = 255 - static_cast<sal_uInt8>( nBlue - nMinMax ); nBlue = 255 - static_cast<sal_uInt8>( nBlue - nMinMax );
pAcc->SetPixel( nY, nx, Color( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) ); pAcc->SetPixelOnData(pScanLine, nx, Color(static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue)));
} }
} }
} }
@@ -909,7 +913,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
255L/static_cast<sal_Int32>(nMaxSampleValue-nMinSampleValue) ) )); 255L/static_cast<sal_Int32>(nMaxSampleValue-nMinSampleValue) ) ));
nBlue = static_cast<sal_uInt8>(std::max( 0L, 255L - ( ( static_cast<sal_Int32>(nSamp[ 2 ]) + nBlack - ( static_cast<sal_Int32>(nMinSampleValue) << 1 ) ) * nBlue = static_cast<sal_uInt8>(std::max( 0L, 255L - ( ( static_cast<sal_Int32>(nSamp[ 2 ]) + nBlack - ( static_cast<sal_Int32>(nMinSampleValue) << 1 ) ) *
255L/static_cast<sal_Int32>(nMaxSampleValue-nMinSampleValue) ) )); 255L/static_cast<sal_Int32>(nMaxSampleValue-nMinSampleValue) ) ));
pAcc->SetPixel( nY, nx, Color ( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) ); pAcc->SetPixelOnData(pScanLine, nx, Color(static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue)));
} }
} }
} }

View File

@@ -1117,6 +1117,7 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
{ {
for ( long nY = 0; nY < aBitmapSizePixel.Height(); nY++ ) for ( long nY = 0; nY < aBitmapSizePixel.Height(); nY++ )
{ {
Scanline pScanline = pAcc->GetScanline(nY);
for ( long nX = 0; nX < aBitmapSizePixel.Width(); nX++ ) for ( long nX = 0; nX < aBitmapSizePixel.Width(); nX++ )
{ {
double fX = static_cast< double >( nX ) / aBitmapSizePixel.Width(); double fX = static_cast< double >( nX ) / aBitmapSizePixel.Width();
@@ -1233,7 +1234,7 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
if ( nBlue > 255 ) if ( nBlue > 255 )
nBlue = 255; nBlue = 255;
pAcc->SetPixel( nY, nX, BitmapColor( static_cast< sal_Int8 >( nRed ), static_cast< sal_Int8 >( nGreen ), static_cast< sal_Int8 >( nBlue ) ) ); pAcc->SetPixelOnData(pScanline, nX, BitmapColor(static_cast<sal_Int8>(nRed), static_cast<sal_Int8>(nGreen), static_cast<sal_Int8>(nBlue)));
} }
} }
Bitmap::ReleaseAccess( pAcc ); Bitmap::ReleaseAccess( pAcc );
@@ -1376,6 +1377,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
for (long y = 0; y < pWrite->Height(); ++y) for (long y = 0; y < pWrite->Height(); ++y)
{ {
Scanline pScanline = pWrite->GetScanline(y);
for (long x = 0; x < pWrite->Width(); ++x) for (long x = 0; x < pWrite->Width(); ++x)
{ {
Color aReadColor; Color aReadColor;
@@ -1385,9 +1387,9 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
aReadColor = pRead->GetPixel(y, x); aReadColor = pRead->GetPixel(y, x);
if (aReadColor.GetColor() == 0) if (aReadColor.GetColor() == 0)
pWrite->SetPixel(y, x, aCol2); pWrite->SetPixelOnData(pScanline, x, aCol2);
else else
pWrite->SetPixel(y, x, aCol1); pWrite->SetPixelOnData(pScanline, x, aCol1);
} }
} }
} }

View File

@@ -241,8 +241,9 @@ bool XBMReader::ParseData( SvStream* pInStm, const OString& aLastLine, XBMFormat
if( bProcessed ) if( bProcessed )
{ {
Scanline pScanline = pAcc1->GetScanline(nRow);
while( ( nCol < nWidth ) && ( nBit < nBits ) ) while( ( nCol < nWidth ) && ( nBit < nBits ) )
pAcc1->SetPixel( nRow, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite ); pAcc1->SetPixelOnData(pScanline, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite);
if( nCol == nWidth ) if( nCol == nWidth )
{ {

View File

@@ -305,6 +305,8 @@ bool XPMReader::ImplGetScanLine( sal_uLong nY )
bStatus = false; bStatus = false;
else else
{ {
Scanline pScanline = mpAcc->GetScanline(nY);
Scanline pMaskScanline = mpMaskAcc ? mpMaskAcc->GetScanline(nY) : nullptr;
for (sal_uLong i = 0; i < mnWidth; ++i) for (sal_uLong i = 0; i < mnWidth; ++i)
{ {
OString aKey(reinterpret_cast<sal_Char*>(pString), mnCpp); OString aKey(reinterpret_cast<sal_Char*>(pString), mnCpp);
@@ -312,11 +314,11 @@ bool XPMReader::ImplGetScanLine( sal_uLong nY )
if (it != maColMap.end()) if (it != maColMap.end())
{ {
if (mnColors > 256) if (mnColors > 256)
mpAcc->SetPixel(nY, i, Color(it->second[1], it->second[2], it->second[3])); mpAcc->SetPixelOnData(pScanline, i, Color(it->second[1], it->second[2], it->second[3]));
else else
mpAcc->SetPixel(nY, i, BitmapColor(it->second[1])); mpAcc->SetPixelOnData(pScanline, i, BitmapColor(it->second[1]));
if (mpMaskAcc) if (pMaskScanline)
mpMaskAcc->SetPixel(nY, i, it->second[0] ? aWhite : aBlack); mpMaskAcc->SetPixelOnData(pMaskScanline, i, it->second[0] ? aWhite : aBlack);
} }
pString += mnCpp; pString += mnCpp;
} }

View File

@@ -376,6 +376,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
if( nRunByte > 2 ) if( nRunByte > 2 )
{ {
Scanline pScanline = rAcc.GetScanline(nY);
if( bRLE4 ) if( bRLE4 )
{ {
nCountByte = nRunByte >> 1; nCountByte = nRunByte >> 1;
@@ -388,10 +389,10 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
cTmp = *pRLE++; cTmp = *pRLE++;
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)));
} }
if( nRunByte & 1 ) if( nRunByte & 1 )
@@ -400,7 +401,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false; return false;
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(*pRLE >> 4, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(*pRLE >> 4, rPalette, bForceToMonoWhileReading)));
pRLE++; pRLE++;
} }
@@ -421,7 +422,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false; return false;
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(*pRLE, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(*pRLE, rPalette, bForceToMonoWhileReading)));
pRLE++; pRLE++;
} }
@@ -461,6 +462,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
return false; return false;
cTmp = *pRLE++; cTmp = *pRLE++;
Scanline pScanline = rAcc.GetScanline(nY);
if( bRLE4 ) if( bRLE4 )
{ {
nRunByte = nCountByte >> 1; nRunByte = nCountByte >> 1;
@@ -468,19 +470,19 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA
for( sal_uLong i = 0; i < nRunByte; i++ ) for( sal_uLong i = 0; i < nRunByte; i++ )
{ {
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
if( nX < nWidth ) if( nX < nWidth )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)));
} }
if( ( nCountByte & 1 ) && ( nX < nWidth ) ) if( ( nCountByte & 1 ) && ( nX < nWidth ) )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)));
} }
else else
{ {
for( sal_uLong i = 0; ( i < nCountByte ) && ( nX < nWidth ); i++ ) for( sal_uLong i = 0; ( i < nCountByte ) && ( nX < nWidth ); i++ )
rAcc.SetPixelIndex(nY, nX++, SanitizePaletteIndex(cTmp, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX++, BitmapColor(SanitizePaletteIndex(cTmp, rPalette, bForceToMonoWhileReading)));
} }
} }
} }
@@ -584,7 +586,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
sal_uInt8 cTmp = *pTmp++; sal_uInt8 cTmp = *pTmp++;
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0, nShift = 8; nX < nWidth; nX++ ) for( long nX = 0, nShift = 8; nX < nWidth; nX++ )
{ {
if( !nShift ) if( !nShift )
@@ -594,7 +596,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
} }
auto nIndex = (cTmp >> --nShift) & 1; auto nIndex = (cTmp >> --nShift) & 1;
rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
} }
} }
} }
@@ -611,7 +613,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
sal_uInt8 cTmp = *pTmp++; sal_uInt8 cTmp = *pTmp++;
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0, nShift = 2; nX < nWidth; nX++ ) for( long nX = 0, nShift = 2; nX < nWidth; nX++ )
{ {
if( !nShift ) if( !nShift )
@@ -621,7 +623,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
} }
auto nIndex = (cTmp >> ( --nShift << 2 ) ) & 0x0f; auto nIndex = (cTmp >> ( --nShift << 2 ) ) & 0x0f;
rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
} }
} }
} }
@@ -638,10 +640,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ ) for( long nX = 0; nX < nWidth; nX++ )
{ {
auto nIndex = *pTmp++; auto nIndex = *pTmp++;
rAcc.SetPixelIndex(nY, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, BitmapColor(SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)));
} }
} }
} }
@@ -671,10 +674,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ ) for( long nX = 0; nX < nWidth; nX++ )
{ {
aMask.GetColorFor16BitLSB( aColor, reinterpret_cast<sal_uInt8*>(pTmp16++) ); aMask.GetColorFor16BitLSB( aColor, reinterpret_cast<sal_uInt8*>(pTmp16++) );
rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
} }
} }
} }
@@ -693,12 +697,13 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ ) for( long nX = 0; nX < nWidth; nX++ )
{ {
aPixelColor.SetBlue( *pTmp++ ); aPixelColor.SetBlue( *pTmp++ );
aPixelColor.SetGreen( *pTmp++ ); aPixelColor.SetGreen( *pTmp++ );
aPixelColor.SetRed( *pTmp++ ); aPixelColor.SetRed( *pTmp++ );
rAcc.SetPixel(nY, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading));
} }
} }
} }
@@ -733,11 +738,13 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
Scanline pScanline = rAcc.GetScanline(nY);
Scanline pAlphaScanline = pAccAlpha->GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ ) for( long nX = 0; nX < nWidth; nX++ )
{ {
aMask.GetColorAndAlphaFor32Bit( aColor, aAlpha, reinterpret_cast<sal_uInt8*>(pTmp32++) ); aMask.GetColorAndAlphaFor32Bit( aColor, aAlpha, reinterpret_cast<sal_uInt8*>(pTmp32++) );
rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
pAccAlpha->SetPixelIndex(nY, nX, sal_uInt8(0xff) - aAlpha); pAccAlpha->SetPixelOnData(pAlphaScanline, nX, BitmapColor(sal_uInt8(0xff) - aAlpha));
rAlphaUsed |= 0xff != aAlpha; rAlphaUsed |= 0xff != aAlpha;
} }
} }
@@ -753,10 +760,11 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
return false; return false;
} }
Scanline pScanline = rAcc.GetScanline(nY);
for( long nX = 0; nX < nWidth; nX++ ) for( long nX = 0; nX < nWidth; nX++ )
{ {
aMask.GetColorFor32Bit( aColor, reinterpret_cast<sal_uInt8*>(pTmp32++) ); aMask.GetColorFor32Bit( aColor, reinterpret_cast<sal_uInt8*>(pTmp32++) );
rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading));
} }
} }
} }