CreateAlphaMask + CreateColorBitmap -> SplitIntoColorAndAlpha

See commit f7b67e6c8c5981790fb9ac162dcc68e470b53112 (pdfexport: reduce
the number of times we split images, 2026-08-19) for rationale.

Change-Id: Ieef19e0725dcdf0c9b17444b8f0e8b9eefaf74ee
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/9521
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 0c72a1c0c7fd9da268a80038fad3ccb46a515834)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209513
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Mike Kaganski
2026-08-23 13:27:57 +02:00
committed by Xisco Fauli
parent c47c991c85
commit 9bfa8c6843
+9 -6
View File
@@ -1693,8 +1693,7 @@ bool ReadRawDIB(
if (rTarget.HasAlpha())
{
// Need to preserve the targets alpha information
Bitmap aTmp(rTarget.CreateColorBitmap());
AlphaMask aTmpMask(rTarget.CreateAlphaMask());
auto [ aTmp, aTmpMask ] = rTarget.SplitIntoColorAndAlpha();
{
BitmapScopedWriteAccess pWriteAccess(aTmp);
for (int nRow = 0; nRow < nHeight; ++nRow)
@@ -1736,16 +1735,20 @@ bool WriteDIBBitmapEx(
const Bitmap& rSource,
SvStream& rOStm)
{
if(ImplWriteDIB(rSource.CreateColorBitmap(), rOStm, true, true))
Bitmap tmpColor(rSource);
AlphaMask tmpAlpha;
if (rSource.HasAlpha())
std::tie(tmpColor, tmpAlpha) = rSource.SplitIntoColorAndAlpha();
if (ImplWriteDIB(tmpColor, rOStm, true, true))
{
rOStm.WriteUInt32( 0x25091962 );
rOStm.WriteUInt32( 0xACB20201 );
rOStm.WriteUChar( rSource.HasAlpha() ? 2 : 0 ); // Used to be TransparentType enum
rOStm.WriteUChar(tmpAlpha.IsEmpty() ? 0 : 2); // Used to be TransparentType enum
if(rSource.HasAlpha())
if (!tmpAlpha.IsEmpty())
{
// invert the alpha because the other routines actually want transparency
AlphaMask tmpAlpha = rSource.CreateAlphaMask();
tmpAlpha.Invert();
return ImplWriteDIB(tmpAlpha.GetBitmap(), rOStm, true, true);
}