| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 FX_Free(pData); | 77 FX_Free(pData); |
| 78 if (!pDict && size > dwEstimateSize) { | 78 if (!pDict && size > dwEstimateSize) { |
| 79 pData = FX_Alloc(uint8_t, size); | 79 pData = FX_Alloc(uint8_t, size); |
| 80 pFile->ReadBlock(pData, 0, size); | 80 pFile->ReadBlock(pData, 0, size); |
| 81 pDict = InitJPEG(pData, size); | 81 pDict = InitJPEG(pData, size); |
| 82 FX_Free(pData); | 82 FX_Free(pData); |
| 83 } | 83 } |
| 84 if (!pDict) { | 84 if (!pDict) { |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 m_pStream->InitStream(pFile, pDict); | 87 m_pStream->InitStreamFromFile(pFile, pDict); |
| 88 } | 88 } |
| 89 void _DCTEncodeBitmap(CPDF_Dictionary* pBitmapDict, | 89 void _DCTEncodeBitmap(CPDF_Dictionary* pBitmapDict, |
| 90 const CFX_DIBitmap* pBitmap, | 90 const CFX_DIBitmap* pBitmap, |
| 91 int quality, | 91 int quality, |
| 92 uint8_t*& buf, | 92 uint8_t*& buf, |
| 93 FX_STRSIZE& size) {} | 93 FX_STRSIZE& size) {} |
| 94 void _JBIG2EncodeBitmap(CPDF_Dictionary* pBitmapDict, | 94 void _JBIG2EncodeBitmap(CPDF_Dictionary* pBitmapDict, |
| 95 const CFX_DIBitmap* pBitmap, | 95 const CFX_DIBitmap* pBitmap, |
| 96 CPDF_Document* pDoc, | 96 CPDF_Document* pDoc, |
| 97 uint8_t*& buf, | 97 uint8_t*& buf, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 pCS->AddInteger(iPalette - 1); | 170 pCS->AddInteger(iPalette - 1); |
| 171 uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3); | 171 uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3); |
| 172 uint8_t* ptr = pColorTable; | 172 uint8_t* ptr = pColorTable; |
| 173 for (int32_t i = 0; i < iPalette; i++) { | 173 for (int32_t i = 0; i < iPalette; i++) { |
| 174 FX_DWORD argb = pBitmap->GetPaletteArgb(i); | 174 FX_DWORD argb = pBitmap->GetPaletteArgb(i); |
| 175 ptr[0] = (uint8_t)(argb >> 16); | 175 ptr[0] = (uint8_t)(argb >> 16); |
| 176 ptr[1] = (uint8_t)(argb >> 8); | 176 ptr[1] = (uint8_t)(argb >> 8); |
| 177 ptr[2] = (uint8_t)argb; | 177 ptr[2] = (uint8_t)argb; |
| 178 ptr += 3; | 178 ptr += 3; |
| 179 } | 179 } |
| 180 CPDF_Stream* pCTS = CPDF_Stream::Create(pColorTable, iPalette * 3, | 180 CPDF_Stream* pCTS = |
| 181 CPDF_Dictionary::Create()); | 181 new CPDF_Stream(pColorTable, iPalette * 3, new CPDF_Dictionary); |
| 182 m_pDocument->AddIndirectObject(pCTS); | 182 m_pDocument->AddIndirectObject(pCTS); |
| 183 pCS->AddReference(m_pDocument, pCTS); | 183 pCS->AddReference(m_pDocument, pCTS); |
| 184 pDict->SetAtReference(FX_BSTRC("ColorSpace"), m_pDocument, pCS); | 184 pDict->SetAtReference(FX_BSTRC("ColorSpace"), m_pDocument, pCS); |
| 185 } else { | 185 } else { |
| 186 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); | 186 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); |
| 187 } | 187 } |
| 188 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); | 188 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); |
| 189 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { | 189 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { |
| 190 dest_pitch = BitmapWidth; | 190 dest_pitch = BitmapWidth; |
| 191 opType = 1; | 191 opType = 1; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 dest_buf = NULL; | 366 dest_buf = NULL; |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 if (m_pStream == NULL) { | 369 if (m_pStream == NULL) { |
| 370 m_pStream = new CPDF_Stream(NULL, 0, NULL); | 370 m_pStream = new CPDF_Stream(NULL, 0, NULL); |
| 371 } | 371 } |
| 372 if (!bStream) { | 372 if (!bStream) { |
| 373 m_pStream->InitStream(dest_buf, dest_size, pDict); | 373 m_pStream->InitStream(dest_buf, dest_size, pDict); |
| 374 } else { | 374 } else { |
| 375 pFileWrite->Flush(); | 375 pFileWrite->Flush(); |
| 376 m_pStream->InitStream(pFileRead, pDict); | 376 m_pStream->InitStreamFromFile(pFileRead, pDict); |
| 377 } | 377 } |
| 378 m_bIsMask = pBitmap->IsAlphaMask(); | 378 m_bIsMask = pBitmap->IsAlphaMask(); |
| 379 m_Width = BitmapWidth; | 379 m_Width = BitmapWidth; |
| 380 m_Height = BitmapHeight; | 380 m_Height = BitmapHeight; |
| 381 FX_Free(dest_buf); | 381 FX_Free(dest_buf); |
| 382 } | 382 } |
| 383 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { | 383 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { |
| 384 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); | 384 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); |
| 385 } | 385 } |
| OLD | NEW |