Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp

Issue 1418493006: Merge to XFA: Cleanup CPDF_Stream: (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: fix build Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "../fpdf_page/pageint.h" 7 #include "../fpdf_page/pageint.h"
8 #include "../fpdf_render/render_int.h" 8 #include "../fpdf_render/render_int.h"
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 FX_Free(pData); 78 FX_Free(pData);
79 if (!pDict && size > dwEstimateSize) { 79 if (!pDict && size > dwEstimateSize) {
80 pData = FX_Alloc(uint8_t, size); 80 pData = FX_Alloc(uint8_t, size);
81 pFile->ReadBlock(pData, 0, size); 81 pFile->ReadBlock(pData, 0, size);
82 pDict = InitJPEG(pData, size); 82 pDict = InitJPEG(pData, size);
83 FX_Free(pData); 83 FX_Free(pData);
84 } 84 }
85 if (!pDict) { 85 if (!pDict) {
86 return; 86 return;
87 } 87 }
88 m_pStream->InitStream(pFile, pDict); 88 m_pStream->InitStreamFromFile(pFile, pDict);
89 } 89 }
90 void _DCTEncodeBitmap(CPDF_Dictionary* pBitmapDict, 90 void _DCTEncodeBitmap(CPDF_Dictionary* pBitmapDict,
91 const CFX_DIBitmap* pBitmap, 91 const CFX_DIBitmap* pBitmap,
92 int quality, 92 int quality,
93 uint8_t*& buf, 93 uint8_t*& buf,
94 FX_STRSIZE& size) {} 94 FX_STRSIZE& size) {}
95 void _JBIG2EncodeBitmap(CPDF_Dictionary* pBitmapDict, 95 void _JBIG2EncodeBitmap(CPDF_Dictionary* pBitmapDict,
96 const CFX_DIBitmap* pBitmap, 96 const CFX_DIBitmap* pBitmap,
97 CPDF_Document* pDoc, 97 CPDF_Document* pDoc,
98 uint8_t*& buf, 98 uint8_t*& buf,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 pCS->AddInteger(iPalette - 1); 171 pCS->AddInteger(iPalette - 1);
172 uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3); 172 uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3);
173 uint8_t* ptr = pColorTable; 173 uint8_t* ptr = pColorTable;
174 for (int32_t i = 0; i < iPalette; i++) { 174 for (int32_t i = 0; i < iPalette; i++) {
175 FX_DWORD argb = pBitmap->GetPaletteArgb(i); 175 FX_DWORD argb = pBitmap->GetPaletteArgb(i);
176 ptr[0] = (uint8_t)(argb >> 16); 176 ptr[0] = (uint8_t)(argb >> 16);
177 ptr[1] = (uint8_t)(argb >> 8); 177 ptr[1] = (uint8_t)(argb >> 8);
178 ptr[2] = (uint8_t)argb; 178 ptr[2] = (uint8_t)argb;
179 ptr += 3; 179 ptr += 3;
180 } 180 }
181 CPDF_Stream* pCTS = CPDF_Stream::Create(pColorTable, iPalette * 3, 181 CPDF_Stream* pCTS =
182 CPDF_Dictionary::Create()); 182 new CPDF_Stream(pColorTable, iPalette * 3, new CPDF_Dictionary);
183 m_pDocument->AddIndirectObject(pCTS); 183 m_pDocument->AddIndirectObject(pCTS);
184 pCS->AddReference(m_pDocument, pCTS); 184 pCS->AddReference(m_pDocument, pCTS);
185 pDict->SetAtReference(FX_BSTRC("ColorSpace"), m_pDocument, pCS); 185 pDict->SetAtReference(FX_BSTRC("ColorSpace"), m_pDocument, pCS);
186 } else { 186 } else {
187 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); 187 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray"));
188 } 188 }
189 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); 189 pDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8);
190 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { 190 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) {
191 dest_pitch = BitmapWidth; 191 dest_pitch = BitmapWidth;
192 opType = 1; 192 opType = 1;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 dest_buf = NULL; 367 dest_buf = NULL;
368 } 368 }
369 } 369 }
370 if (m_pStream == NULL) { 370 if (m_pStream == NULL) {
371 m_pStream = new CPDF_Stream(NULL, 0, NULL); 371 m_pStream = new CPDF_Stream(NULL, 0, NULL);
372 } 372 }
373 if (!bStream) { 373 if (!bStream) {
374 m_pStream->InitStream(dest_buf, dest_size, pDict); 374 m_pStream->InitStream(dest_buf, dest_size, pDict);
375 } else { 375 } else {
376 pFileWrite->Flush(); 376 pFileWrite->Flush();
377 m_pStream->InitStream(pFileRead, pDict); 377 m_pStream->InitStreamFromFile(pFileRead, pDict);
378 } 378 }
379 m_bIsMask = pBitmap->IsAlphaMask(); 379 m_bIsMask = pBitmap->IsAlphaMask();
380 m_Width = BitmapWidth; 380 m_Width = BitmapWidth;
381 m_Height = BitmapHeight; 381 m_Height = BitmapHeight;
382 FX_Free(dest_buf); 382 FX_Free(dest_buf);
383 } 383 }
384 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { 384 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
385 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 385 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
386 } 386 }
OLDNEW
« no previous file with comments | « core/include/fpdfapi/fpdf_objects.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698