diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-27 12:32:56 +0100 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-11-28 00:13:11 -0500 |
commit | 5805073cbd2260675ef206d228bb029ad5e94b51 (patch) | |
tree | 0341daf5ab69f9bbddee887087d53435168bf6c8 | |
parent | 0a4ea263aca16eb05dd6c8d4ccb5ed2aca2b4a63 (diff) |
move bitmap allocation after palette read
Change-Id: Ie7b2d64bde48d49c6e389c0770f2456187107bda
(cherry picked from commit 155886c99ba55ef28bd902cfe7256cbc1f4d2d01)
-rw-r--r-- | vcl/source/gdi/dibtools.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index fc3722577d3a..323fa3f4db25 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -897,15 +897,6 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u } const Size aSizePixel(aHeader.nWidth, aHeader.nHeight); - BitmapPalette aPalette; - Bitmap aNewBmp(aSizePixel, nBitCount, &aPalette); - Bitmap::ScopedWriteAccess pAcc(aNewBmp); - if (!pAcc) - return false; - if (pAcc->Width() != aHeader.nWidth || pAcc->Height() != aHeader.nHeight) - { - return false; - } AlphaMask aNewBmpAlpha; AlphaMask::ScopedWriteAccess pAccAlpha; bool bAlphaPossible(pBmpAlpha && aHeader.nBitCount == 32); @@ -933,16 +924,25 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u } // read palette + BitmapPalette aPalette; if (nColors) { aPalette.SetEntryCount(nColors); ImplReadDIBPalette(*pIStm, aPalette, aHeader.nSize != DIBCOREHEADERSIZE); - pAcc->SetPalette(aPalette); } if (pIStm->GetError()) return false; + Bitmap aNewBmp(aSizePixel, nBitCount, &aPalette); + Bitmap::ScopedWriteAccess pAcc(aNewBmp); + if (!pAcc) + return false; + if (pAcc->Width() != aHeader.nWidth || pAcc->Height() != aHeader.nHeight) + { + return false; + } + if(nOffset) { pIStm->SeekRel(nOffset - (pIStm->Tell() - nStmPos)); |