vcl: bitmap::CreateFromData add option to reverse alpha (0xff - a)
Change-Id: If69225f86afb315ad432789178188a66264ab3ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118669 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
3f88c646a9
commit
2a151d1d5b
@@ -46,7 +46,10 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
|
|||||||
@param nStride
|
@param nStride
|
||||||
The number of bytes in a scanline, must be >= (width * bitcount / 8)
|
The number of bytes in a scanline, must be >= (width * bitcount / 8)
|
||||||
*/
|
*/
|
||||||
BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, vcl::PixelFormat ePixelFormat, bool bReversColors = false);
|
BitmapEx VCL_DLLPUBLIC CreateFromData(sal_uInt8 const *pData,
|
||||||
|
sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride,
|
||||||
|
vcl::PixelFormat ePixelFormat,
|
||||||
|
bool bReversColors = false, bool bReverseAlpha = false);
|
||||||
|
|
||||||
BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data );
|
BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data );
|
||||||
|
|
||||||
|
@@ -128,7 +128,9 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
|
|||||||
@param bReversColors
|
@param bReversColors
|
||||||
In case the endianness of pData is wrong, you could reverse colors
|
In case the endianness of pData is wrong, you could reverse colors
|
||||||
*/
|
*/
|
||||||
BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, vcl::PixelFormat ePixelFormat, bool bReversColors )
|
BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight,
|
||||||
|
sal_Int32 nStride, vcl::PixelFormat ePixelFormat,
|
||||||
|
bool bReversColors, bool bReverseAlpha)
|
||||||
{
|
{
|
||||||
auto nBitCount = sal_uInt16(ePixelFormat);
|
auto nBitCount = sal_uInt16(ePixelFormat);
|
||||||
|
|
||||||
@@ -184,7 +186,8 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
|
|||||||
Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
|
Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
|
||||||
for (tools::Long x = 0; x < nWidth; ++x)
|
for (tools::Long x = 0; x < nWidth; ++x)
|
||||||
{
|
{
|
||||||
xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p));
|
const sal_uInt8 nValue = bReverseAlpha ? 0xff - *p : *p;
|
||||||
|
xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(nValue));
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user