diff options
author | Herbert Dürr <hdu@apache.org> | 2012-10-19 15:12:40 +0000 |
---|---|---|
committer | Herbert Dürr <hdu@apache.org> | 2012-10-19 15:12:40 +0000 |
commit | 2d9d5c8d6beb7fb0a7dafa0c1c4d10a25d7200fd (patch) | |
tree | 15a68700c164567baace3aa5dc175aa588ed9134 /svx/source/xoutdev | |
parent | b0a48fbbaa2d3d530743672186618a468cce694a (diff) |
make conversions between BitmapColor and sal_uInt8 explicit
Implicit conversions are a dangerous cause of confusion as seen
in http://markmail.org/thread/a4copx2di7cxeowg and require tricky
rewrites to work around them, this change cleans them up and
disables them for all code outside of the immutable binfilter.
Notes
Notes:
merged as: 78eca44c4db67848a85b600cc40e25d41bb647df
Diffstat (limited to 'svx/source/xoutdev')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 26 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index d2608c52fb35..fd04551a20ee 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -577,13 +577,13 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold ) const long nHeight = aSize.Height(); const long nHeight2 = nHeight - 2L; const long lThres2 = (long) cThreshold * cThreshold; - const BitmapColor aWhite = (sal_uInt8) pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) ); - const BitmapColor aBlack = (sal_uInt8) pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) ); + const sal_uInt8 nWhitePalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_WHITE ) ); + const sal_uInt8 nBlackPalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_BLACK ) ); long nSum1; long nSum2; long lGray; - // Rand mit Weiss init. + // initialize border with white pixels pWriteAcc->SetLineColor( Color( COL_WHITE) ); pWriteAcc->DrawLine( Point(), Point( nWidth - 1L, 0L ) ); pWriteAcc->DrawLine( Point( nWidth - 1L, 0L ), Point( nWidth - 1L, nHeight - 1L ) ); @@ -596,24 +596,24 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold ) { nXTmp = nX; - nSum1 = -( nSum2 = lGray = (sal_uInt8) pReadAcc->GetPixel( nY, nXTmp++ ) ); - nSum2 += ( (long) (sal_uInt8) pReadAcc->GetPixel( nY, nXTmp++ ) ) << 1; - nSum1 += ( lGray = pReadAcc->GetPixel( nY, nXTmp ) ); + nSum1 = -( nSum2 = lGray = pReadAcc->GetPixelIndex( nY, nXTmp++ ) ); + nSum2 += ( (long) pReadAcc->GetPixelIndex( nY, nXTmp++ ) ) << 1; + nSum1 += ( lGray = pReadAcc->GetPixelIndex( nY, nXTmp ) ); nSum2 += lGray; - nSum1 += ( (long) (sal_uInt8) pReadAcc->GetPixel( nY1, nXTmp ) ) << 1; - nSum1 -= ( (long) (sal_uInt8) pReadAcc->GetPixel( nY1, nXTmp -= 2 ) ) << 1; + nSum1 += ( (long) pReadAcc->GetPixelIndex( nY1, nXTmp ) ) << 1; + nSum1 -= ( (long) pReadAcc->GetPixelIndex( nY1, nXTmp -= 2 ) ) << 1; - nSum1 += ( lGray = -(long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp++ ) ); + nSum1 += ( lGray = -(long) pReadAcc->GetPixelIndex( nY2, nXTmp++ ) ); nSum2 += lGray; - nSum2 -= ( (long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp++ ) ) << 1; - nSum1 += ( lGray = (long) (sal_uInt8) pReadAcc->GetPixel( nY2, nXTmp ) ); + nSum2 -= ( (long) pReadAcc->GetPixelIndex( nY2, nXTmp++ ) ) << 1; + nSum1 += ( lGray = (long) pReadAcc->GetPixelIndex( nY2, nXTmp ) ); nSum2 -= lGray; if( ( nSum1 * nSum1 + nSum2 * nSum2 ) < lThres2 ) - pWriteAcc->SetPixel( nY1, nXDst, aWhite ); + pWriteAcc->SetPixelIndex( nY1, nXDst, nWhiteIdx ); else - pWriteAcc->SetPixel( nY1, nXDst, aBlack ); + pWriteAcc->SetPixelIndex( nY1, nXDst, nBlackIdx ); } } diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 266492712cd8..9606a963771b 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -94,11 +94,11 @@ Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, C { if(pArray[(a * 8) + b]) { - pContent->SetPixel(b, a, sal_uInt8(1)); + pContent->SetPixelIndex(b, a, 1); } else { - pContent->SetPixel(b, a, sal_uInt8(0)); + pContent->SetPixelIndex(b, a, 0); } } } |