Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp |
| diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp |
| index a5a91ebc53ba719e09d0a6705c601a5aa9acfced..acc0f5d29f93aea81c98825f6f86e8ca61a23910 100644 |
| --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp |
| +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp |
| @@ -190,8 +190,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F |
| } |
| } |
| const CFX_DIBitmap* pMaskBitmap = NULL; |
| + FX_BOOL bDeleteMask = FALSE; |
| if (pBitmap->HasAlpha()) { |
| pMaskBitmap = pBitmap->GetAlphaMask(); |
| + bDeleteMask = TRUE; |
| } |
| if (!pMaskBitmap && pMask) { |
| FXDIB_Format maskFormat = pMask->GetFormat(); |
| @@ -204,7 +206,6 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F |
| FX_INT32 maskHeight = pMaskBitmap->GetHeight(); |
| FX_LPBYTE mask_buf = NULL; |
| FX_STRSIZE mask_size; |
| - FX_BOOL bDeleteMask = TRUE; |
| CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; |
| pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject")); |
| pMaskDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); |
| @@ -223,24 +224,21 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F |
| FXSYS_memcpy32(mask_buf + a * maskWidth, pMaskBitmap->GetScanline(a), maskWidth); |
| } |
| } |
| - if (pMaskDict) { |
| - pMaskDict->SetAtInteger(FX_BSTRC("Length"), mask_size); |
| - CPDF_Stream* pMaskStream = NULL; |
| - if (bUseMatte) { |
| - int a, r, g, b; |
| - ArgbDecode(*(pParam->pMatteColor), a, r, g, b); |
| - CPDF_Array* pMatte = new CPDF_Array; |
| - pMatte->AddInteger(r); |
| - pMatte->AddInteger(g); |
| - pMatte->AddInteger(b); |
| - pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte); |
| - } |
| - pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); |
| - m_pDocument->AddIndirectObject(pMaskStream); |
| - bDeleteMask = FALSE; |
| - pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream); |
| + pMaskDict->SetAtInteger(FX_BSTRC("Length"), mask_size); |
| + CPDF_Stream* pMaskStream = NULL; |
|
Lei Zhang
2015/05/21 00:29:36
declare below where first used??
Tom Sepez
2015/05/21 21:53:21
Done.
|
| + if (bUseMatte) { |
| + int a, r, g, b; |
| + ArgbDecode(*(pParam->pMatteColor), a, r, g, b); |
| + CPDF_Array* pMatte = new CPDF_Array; |
| + pMatte->AddInteger(r); |
| + pMatte->AddInteger(g); |
| + pMatte->AddInteger(b); |
| + pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte); |
| } |
| - if (pBitmap->HasAlpha()) { |
| + pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); |
| + m_pDocument->AddIndirectObject(pMaskStream); |
| + pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream); |
| + if (bDeleteMask) { |
| delete pMaskBitmap; |
| } |
| } |