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

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

Issue 818363006: fix a few linux compilation warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Restore origina cmslut.c Created 5 years, 11 months 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 "../../../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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } else { 188 } else {
189 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceRGB")); 189 pDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceRGB"));
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 FX_BOOL bDeleteMask = FALSE;
198 const CFX_DIBitmap* pMaskBitmap = NULL; 199 const CFX_DIBitmap* pMaskBitmap = NULL;
199 if (pBitmap->HasAlpha()) { 200 if (pBitmap->HasAlpha()) {
200 pMaskBitmap = pBitmap->GetAlphaMask(); 201 pMaskBitmap = pBitmap->GetAlphaMask();
202 if (pMaskBitmap) {
203 bDeleteMask = TRUE;
204 }
201 } 205 }
202 if (!pMaskBitmap && pMask) { 206 if (!pMaskBitmap && pMask) {
203 FXDIB_Format maskFormat = pMask->GetFormat(); 207 FXDIB_Format maskFormat = pMask->GetFormat();
204 if (maskFormat == FXDIB_1bppMask || maskFormat == FXDIB_8bppMask) { 208 if (maskFormat == FXDIB_1bppMask || maskFormat == FXDIB_8bppMask) {
205 pMaskBitmap = pMask; 209 pMaskBitmap = pMask;
206 } 210 }
207 } 211 }
208 if (pMaskBitmap) { 212 if (pMaskBitmap) {
209 FX_INT32 maskWidth = pMaskBitmap->GetWidth(); 213 FX_INT32 maskWidth = pMaskBitmap->GetWidth();
210 FX_INT32 maskHeight = pMaskBitmap->GetHeight(); 214 FX_INT32 maskHeight = pMaskBitmap->GetHeight();
211 FX_LPBYTE mask_buf = NULL; 215 FX_LPBYTE mask_buf = NULL;
212 FX_STRSIZE mask_size; 216 FX_STRSIZE mask_size;
213 FX_BOOL bDeleteMask = TRUE;
214 CPDF_Dictionary* pMaskDict = FX_NEW CPDF_Dictionary; 217 CPDF_Dictionary* pMaskDict = FX_NEW CPDF_Dictionary;
215 pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject")); 218 pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject"));
216 pMaskDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); 219 pMaskDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image"));
217 pMaskDict->SetAtInteger(FX_BSTRC("Width"), maskWidth); 220 pMaskDict->SetAtInteger(FX_BSTRC("Width"), maskWidth);
218 pMaskDict->SetAtInteger(FX_BSTRC("Height"), maskHeight); 221 pMaskDict->SetAtInteger(FX_BSTRC("Height"), maskHeight);
219 pMaskDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray")); 222 pMaskDict->SetAtName(FX_BSTRC("ColorSpace"), FX_BSTRC("DeviceGray"));
220 pMaskDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8); 223 pMaskDict->SetAtInteger(FX_BSTRC("BitsPerComponent"), 8);
221 if (pMaskBitmap->GetBPP() == 8 && (iCompress & PDF_IMAGE_MASK_LOSSY_COMP RESS) != 0) { 224 if (pMaskBitmap->GetBPP() == 8 && (iCompress & PDF_IMAGE_MASK_LOSSY_COMP RESS) != 0) {
222 _DCTEncodeBitmap(pMaskDict, pMaskBitmap, pParam ? pParam->nQuality : 75, mask_buf, mask_size); 225 _DCTEncodeBitmap(pMaskDict, pMaskBitmap, pParam ? pParam->nQuality : 75, mask_buf, mask_size);
223 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { 226 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) {
(...skipping 12 matching lines...) Expand all
236 int a, r, g, b; 239 int a, r, g, b;
237 ArgbDecode(*(pParam->pMatteColor), a, r, g, b); 240 ArgbDecode(*(pParam->pMatteColor), a, r, g, b);
238 CPDF_Array* pMatte = FX_NEW CPDF_Array; 241 CPDF_Array* pMatte = FX_NEW CPDF_Array;
239 pMatte->AddInteger(r); 242 pMatte->AddInteger(r);
240 pMatte->AddInteger(g); 243 pMatte->AddInteger(g);
241 pMatte->AddInteger(b); 244 pMatte->AddInteger(b);
242 pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte); 245 pMaskDict->SetAt(FX_BSTRC("Matte"), pMatte);
243 } 246 }
244 pMaskStream = FX_NEW CPDF_Stream(mask_buf, mask_size, pMaskDict); 247 pMaskStream = FX_NEW CPDF_Stream(mask_buf, mask_size, pMaskDict);
245 m_pDocument->AddIndirectObject(pMaskStream); 248 m_pDocument->AddIndirectObject(pMaskStream);
246 bDeleteMask = FALSE;
247 pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream); 249 pDict->SetAtReference(FX_BSTRC("SMask"), m_pDocument, pMaskStream);
248 } 250 }
249 if (pBitmap->HasAlpha()) { 251 if (bDeleteMask) {
250 delete pMaskBitmap; 252 delete pMaskBitmap;
251 } 253 }
252 } 254 }
253 FX_BOOL bStream = pFileWrite != NULL && pFileRead != NULL; 255 FX_BOOL bStream = pFileWrite != NULL && pFileRead != NULL;
254 if (opType == 0) { 256 if (opType == 0) {
255 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { 257 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) {
256 if (pBitmap->GetBPP() == 1) { 258 if (pBitmap->GetBPP() == 1) {
257 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_s ize, TRUE); 259 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_s ize, TRUE);
258 } 260 }
259 } else { 261 } else {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 m_Width = BitmapWidth; 367 m_Width = BitmapWidth;
366 m_Height = BitmapHeight; 368 m_Height = BitmapHeight;
367 if (dest_buf) { 369 if (dest_buf) {
368 FX_Free(dest_buf); 370 FX_Free(dest_buf);
369 } 371 }
370 } 372 }
371 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) 373 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap)
372 { 374 {
373 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 375 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
374 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698