OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
8 #include "../../../include/fpdfapi/fpdf_page.h" | 8 #include "../../../include/fpdfapi/fpdf_page.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); | 190 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); |
191 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { | 191 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { |
192 dest_pitch = BitmapWidth * 3; | 192 dest_pitch = BitmapWidth * 3; |
193 opType = 2; | 193 opType = 2; |
194 } else { | 194 } else { |
195 opType = 0; | 195 opType = 0; |
196 } | 196 } |
197 } | 197 } |
198 const CFX_DIBitmap* pMaskBitmap = NULL; | 198 const CFX_DIBitmap* pMaskBitmap = NULL; |
199 if (pBitmap->HasAlpha()) { | 199 if (pBitmap->HasAlpha()) { |
200 pMaskBitmap = pBitmap->GetAlphaMask(); | 200 pMaskBitmap = pBitmap->GetAlphaMask(); |
Tom Sepez
2015/04/17 16:20:16
// Despite it's name, GetAlphaMask() does the |new
Lei Zhang
2015/05/08 05:40:38
I'm punting on this file as well for now. Will rev
| |
201 } | 201 } |
202 if (!pMaskBitmap && pMask) { | 202 if (!pMaskBitmap && pMask) { |
203 FXDIB_Format maskFormat = pMask->GetFormat(); | 203 FXDIB_Format maskFormat = pMask->GetFormat(); |
204 if (maskFormat == FXDIB_1bppMask || maskFormat == FXDIB_8bppMask) { | 204 if (maskFormat == FXDIB_1bppMask || maskFormat == FXDIB_8bppMask) { |
205 pMaskBitmap = pMask; | 205 pMaskBitmap = pMask; |
Tom Sepez
2015/04/17 16:20:16
// presumably this is the non-allocating path.
| |
206 } | 206 } |
207 } | 207 } |
208 if (pMaskBitmap) { | 208 if (pMaskBitmap) { |
209 FX_INT32 maskWidth = pMaskBitmap->GetWidth(); | 209 FX_INT32 maskWidth = pMaskBitmap->GetWidth(); |
210 FX_INT32 maskHeight = pMaskBitmap->GetHeight(); | 210 FX_INT32 maskHeight = pMaskBitmap->GetHeight(); |
211 FX_LPBYTE mask_buf = NULL; | 211 FX_LPBYTE mask_buf = NULL; |
212 FX_STRSIZE mask_size; | 212 FX_STRSIZE mask_size; |
213 FX_BOOL bDeleteMask = TRUE; | |
214 CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; | 213 CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; |
215 pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject")); | 214 pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject")); |
216 pMaskDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); | 215 pMaskDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); |
217 pMaskDict->SetAtInteger(FX_BSTRC("Width"), maskWidth); | 216 pMaskDict->SetAtInteger(FX_BSTRC("Width"), maskWidth); |
218 pMaskDict->SetAtInteger(FX_BSTRC("Height"), maskHeight); | 217 pMaskDict->SetAtInteger(FX_BSTRC("Height"), maskHeight); |
219 pMaskDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); | 218 pMaskDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); |
220 pMaskDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); | 219 pMaskDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); |
221 if (pMaskBitmap->GetBPP() == 8 && (iCompress & PDF_IMAGE_MASK_LOSSY_COMP RESS) != 0) { | 220 if (pMaskBitmap->GetBPP() == 8 && (iCompress & PDF_IMAGE_MASK_LOSSY_COMP RESS) != 0) { |
222 _DCTEncodeBitmap(pMaskDict, pMaskBitmap, pParam ? pParam->nQuality : 75, mask_buf, mask_size); | 221 _DCTEncodeBitmap(pMaskDict, pMaskBitmap, pParam ? pParam->nQuality : 75, mask_buf, mask_size); |
223 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { | 222 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { |
(...skipping 12 matching lines...) Expand all Loading... | |
236 int a, r, g, b; | 235 int a, r, g, b; |
237 ArgbDecode(*(pParam->pMatteColor), a, r, g, b); | 236 ArgbDecode(*(pParam->pMatteColor), a, r, g, b); |
238 CPDF_Array* pMatte = new CPDF_Array; | 237 CPDF_Array* pMatte = new CPDF_Array; |
239 pMatte->AddInteger(r); | 238 pMatte->AddInteger(r); |
240 pMatte->AddInteger(g); | 239 pMatte->AddInteger(g); |
241 pMatte->AddInteger(b); | 240 pMatte->AddInteger(b); |
242 pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte); | 241 pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte); |
243 } | 242 } |
244 pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); | 243 pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); |
245 m_pDocument->AddIndirectObject(pMaskStream); | 244 m_pDocument->AddIndirectObject(pMaskStream); |
246 bDeleteMask = FALSE; | |
247 pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream); | 245 pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream); |
248 } | 246 } |
249 if (pBitmap->HasAlpha()) { | 247 if (pBitmap->HasAlpha()) { |
Tom Sepez
2015/04/17 16:20:16
This duplicates the test that lead to the allocati
| |
250 delete pMaskBitmap; | 248 delete pMaskBitmap; |
251 } | 249 } |
252 } | 250 } |
253 FX_BOOL bStream = pFileWrite != NULL && pFileRead != NULL; | 251 FX_BOOL bStream = pFileWrite != NULL && pFileRead != NULL; |
254 if (opType == 0) { | 252 if (opType == 0) { |
255 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { | 253 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { |
256 if (pBitmap->GetBPP() == 1) { | 254 if (pBitmap->GetBPP() == 1) { |
257 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_s ize, TRUE); | 255 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_s ize, TRUE); |
258 } | 256 } |
259 } else { | 257 } else { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 m_Width = BitmapWidth; | 363 m_Width = BitmapWidth; |
366 m_Height = BitmapHeight; | 364 m_Height = BitmapHeight; |
367 if (dest_buf) { | 365 if (dest_buf) { |
368 FX_Free(dest_buf); | 366 FX_Free(dest_buf); |
369 } | 367 } |
370 } | 368 } |
371 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) | 369 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) |
372 { | 370 { |
373 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); | 371 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); |
374 } | 372 } |
OLD | NEW |