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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 22 matching lines...) Expand all
33 return 1; 33 return 1;
34 return 4; 34 return 4;
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family) 39 CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family)
40 : CPDF_ColorSpace(pDoc, family, ComponentsForFamily(family)) { 40 : CPDF_ColorSpace(pDoc, family, ComponentsForFamily(family)) {
41 } 41 }
42 42
43 FX_BOOL CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT & B) const 43 bool CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B ) const
44 { 44 {
45 if (m_Family == PDFCS_DEVICERGB) { 45 if (m_Family == PDFCS_DEVICERGB) {
46 R = pBuf[0]; 46 R = pBuf[0];
47 if (R < 0) { 47 if (R < 0) {
48 R = 0; 48 R = 0;
49 } else if (R > 1) { 49 } else if (R > 1) {
50 R = 1; 50 R = 1;
51 } 51 }
52 G = pBuf[1]; 52 G = pBuf[1];
53 if (G < 0) { 53 if (G < 0) {
(...skipping 20 matching lines...) Expand all
74 AdobeCMYK_to_sRGB(pBuf[0], pBuf[1], pBuf[2], pBuf[3], R, G, B); 74 AdobeCMYK_to_sRGB(pBuf[0], pBuf[1], pBuf[2], pBuf[3], R, G, B);
75 } else { 75 } else {
76 FX_FLOAT k = pBuf[3]; 76 FX_FLOAT k = pBuf[3];
77 R = 1.0f - FX_MIN(1.0f, pBuf[0] + k); 77 R = 1.0f - FX_MIN(1.0f, pBuf[0] + k);
78 G = 1.0f - FX_MIN(1.0f, pBuf[1] + k); 78 G = 1.0f - FX_MIN(1.0f, pBuf[1] + k);
79 B = 1.0f - FX_MIN(1.0f, pBuf[2] + k); 79 B = 1.0f - FX_MIN(1.0f, pBuf[2] + k);
80 } 80 }
81 } else { 81 } else {
82 ASSERT(m_Family == PDFCS_PATTERN); 82 ASSERT(m_Family == PDFCS_PATTERN);
83 R = G = B = 0; 83 R = G = B = 0;
84 return FALSE; 84 return false;
85 } 85 }
86 return TRUE; 86 return true;
87 } 87 }
88 FX_BOOL CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FL OAT& y, FX_FLOAT& k) const 88 bool CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT & y, FX_FLOAT& k) const
89 { 89 {
90 if (m_Family != PDFCS_DEVICECMYK) { 90 if (m_Family != PDFCS_DEVICECMYK) {
91 return FALSE; 91 return false;
92 } 92 }
93 c = pBuf[0]; 93 c = pBuf[0];
94 m = pBuf[1]; 94 m = pBuf[1];
95 y = pBuf[2]; 95 y = pBuf[2];
96 k = pBuf[3]; 96 k = pBuf[3];
97 return TRUE; 97 return true;
98 } 98 }
99 FX_BOOL CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B ) const 99 bool CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) c onst
100 { 100 {
101 if (m_Family == PDFCS_DEVICERGB) { 101 if (m_Family == PDFCS_DEVICERGB) {
102 pBuf[0] = R; 102 pBuf[0] = R;
103 pBuf[1] = G; 103 pBuf[1] = G;
104 pBuf[2] = B; 104 pBuf[2] = B;
105 return TRUE; 105 return true;
106 } else if (m_Family == PDFCS_DEVICEGRAY) { 106 } else if (m_Family == PDFCS_DEVICEGRAY) {
107 if (R == G && R == B) { 107 if (R == G && R == B) {
108 *pBuf = R; 108 *pBuf = R;
109 return TRUE; 109 return true;
110 } else { 110 } else {
111 return FALSE; 111 return false;
112 } 112 }
113 } else if (m_Family == PDFCS_DEVICECMYK) { 113 } else if (m_Family == PDFCS_DEVICECMYK) {
114 sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]); 114 sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]);
115 return TRUE; 115 return true;
116 } 116 }
117 return FALSE; 117 return false;
118 } 118 }
119 FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA T y, FX_FLOAT k) const 119 bool CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y , FX_FLOAT k) const
120 { 120 {
121 if (m_Family == PDFCS_DEVICERGB) { 121 if (m_Family == PDFCS_DEVICERGB) {
122 AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]); 122 AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]);
123 return TRUE; 123 return true;
124 } else if (m_Family == PDFCS_DEVICEGRAY) { 124 } else if (m_Family == PDFCS_DEVICEGRAY) {
125 return FALSE; 125 return false;
126 } else if (m_Family == PDFCS_DEVICECMYK) { 126 } else if (m_Family == PDFCS_DEVICECMYK) {
127 pBuf[0] = c; 127 pBuf[0] = c;
128 pBuf[1] = m; 128 pBuf[1] = m;
129 pBuf[2] = y; 129 pBuf[2] = y;
130 pBuf[3] = k; 130 pBuf[3] = k;
131 return TRUE; 131 return true;
132 } 132 }
133 return FALSE; 133 return false;
134 } 134 }
135 static void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) 135 static void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels)
136 { 136 {
137 if (pDestBuf == pSrcBuf) 137 if (pDestBuf == pSrcBuf)
138 for (int i = 0; i < pixels; i ++) { 138 for (int i = 0; i < pixels; i ++) {
139 uint8_t temp = pDestBuf[2]; 139 uint8_t temp = pDestBuf[2];
140 pDestBuf[2] = pDestBuf[0]; 140 pDestBuf[2] = pDestBuf[0];
141 pDestBuf[0] = temp; 141 pDestBuf[0] = temp;
142 pDestBuf += 3; 142 pDestBuf += 3;
143 } 143 }
144 else 144 else
145 for (int i = 0; i < pixels; i ++) { 145 for (int i = 0; i < pixels; i ++) {
146 *pDestBuf ++ = pSrcBuf[2]; 146 *pDestBuf ++ = pSrcBuf[2];
147 *pDestBuf ++ = pSrcBuf[1]; 147 *pDestBuf ++ = pSrcBuf[1];
148 *pDestBuf ++ = pSrcBuf[0]; 148 *pDestBuf ++ = pSrcBuf[0];
149 pSrcBuf += 3; 149 pSrcBuf += 3;
150 } 150 }
151 } 151 }
152 void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf , int pixels, int image_width, int image_height, FX_BOOL bTransMask) const 152 void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf , int pixels, int image_width, int image_height, bool bTransMask) const
153 { 153 {
154 if (bTransMask && m_Family == PDFCS_DEVICECMYK) { 154 if (bTransMask && m_Family == PDFCS_DEVICECMYK) {
155 for (int i = 0; i < pixels; i ++) { 155 for (int i = 0; i < pixels; i ++) {
156 int k = 255 - pSrcBuf[3]; 156 int k = 255 - pSrcBuf[3];
157 pDestBuf[0] = ((255 - pSrcBuf[0]) * k) / 255; 157 pDestBuf[0] = ((255 - pSrcBuf[0]) * k) / 255;
158 pDestBuf[1] = ((255 - pSrcBuf[1]) * k) / 255; 158 pDestBuf[1] = ((255 - pSrcBuf[1]) * k) / 255;
159 pDestBuf[2] = ((255 - pSrcBuf[2]) * k) / 255; 159 pDestBuf[2] = ((255 - pSrcBuf[2]) * k) / 255;
160 pDestBuf += 3; 160 pDestBuf += 3;
161 pSrcBuf += 4; 161 pSrcBuf += 4;
162 } 162 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 R = RGB_Conversion(RGB.a); 267 R = RGB_Conversion(RGB.a);
268 G = RGB_Conversion(RGB.b); 268 G = RGB_Conversion(RGB.b);
269 B = RGB_Conversion(RGB.c); 269 B = RGB_Conversion(RGB.c);
270 } 270 }
271 class CPDF_CalGray : public CPDF_ColorSpace 271 class CPDF_CalGray : public CPDF_ColorSpace
272 { 272 {
273 public: 273 public:
274 explicit CPDF_CalGray(CPDF_Document* pDoc) 274 explicit CPDF_CalGray(CPDF_Document* pDoc)
275 : CPDF_ColorSpace(pDoc, PDFCS_CALGRAY, 1) { 275 : CPDF_ColorSpace(pDoc, PDFCS_CALGRAY, 1) {
276 } 276 }
277 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 277 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
278 FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const override; 278 bool GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const ove rride;
279 FX_BOOL» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override; 279 bool» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override;
280 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width, 280 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width,
281 int image_height, FX_BOOL bTransMask = FALSE) const override; 281 int image_height, bool bTransMask = false) const ove rride;
282 282
283 private: 283 private:
284 FX_FLOAT m_WhitePoint[3]; 284 FX_FLOAT m_WhitePoint[3];
285 FX_FLOAT m_BlackPoint[3]; 285 FX_FLOAT m_BlackPoint[3];
286 FX_FLOAT m_Gamma; 286 FX_FLOAT m_Gamma;
287 }; 287 };
288 288
289 FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 289 bool CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
290 { 290 {
291 CPDF_Dictionary* pDict = pArray->GetDict(1); 291 CPDF_Dictionary* pDict = pArray->GetDict(1);
292 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); 292 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
293 int i; 293 int i;
294 for (i = 0; i < 3; i ++) { 294 for (i = 0; i < 3; i ++) {
295 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; 295 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
296 } 296 }
297 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); 297 pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
298 for (i = 0; i < 3; i ++) { 298 for (i = 0; i < 3; i ++) {
299 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; 299 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0;
300 } 300 }
301 m_Gamma = pDict->GetNumber(FX_BSTRC("Gamma")); 301 m_Gamma = pDict->GetNumber(FX_BSTRC("Gamma"));
302 if (m_Gamma == 0) { 302 if (m_Gamma == 0) {
303 m_Gamma = 1.0f; 303 m_Gamma = 1.0f;
304 } 304 }
305 return TRUE; 305 return true;
306 } 306 }
307 FX_BOOL CPDF_CalGray::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const 307 bool CPDF_CalGray::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
308 { 308 {
309 R = G = B = *pBuf; 309 R = G = B = *pBuf;
310 return TRUE; 310 return true;
311 } 311 }
312 FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const 312 bool CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) co nst
313 { 313 {
314 if (R == G && R == B) { 314 if (R == G && R == B) {
315 *pBuf = R; 315 *pBuf = R;
316 return TRUE; 316 return true;
317 } else { 317 } else {
318 return FALSE; 318 return false;
319 } 319 }
320 } 320 }
321 void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const 321 void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, bool bTransMask) const
322 { 322 {
323 for (int i = 0; i < pixels; i ++) { 323 for (int i = 0; i < pixels; i ++) {
324 *pDestBuf ++ = pSrcBuf[i]; 324 *pDestBuf ++ = pSrcBuf[i];
325 *pDestBuf ++ = pSrcBuf[i]; 325 *pDestBuf ++ = pSrcBuf[i];
326 *pDestBuf ++ = pSrcBuf[i]; 326 *pDestBuf ++ = pSrcBuf[i];
327 } 327 }
328 } 328 }
329 class CPDF_CalRGB : public CPDF_ColorSpace 329 class CPDF_CalRGB : public CPDF_ColorSpace
330 { 330 {
331 public: 331 public:
332 explicit CPDF_CalRGB(CPDF_Document* pDoc) 332 explicit CPDF_CalRGB(CPDF_Document* pDoc)
333 : CPDF_ColorSpace(pDoc, PDFCS_CALRGB, 3) { 333 : CPDF_ColorSpace(pDoc, PDFCS_CALRGB, 3) {
334 } 334 }
335 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 335 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
336 FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const override; 336 bool GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const ove rride;
337 FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const ove rride; 337 bool SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const overri de;
338 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width, 338 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width,
339 int image_height, FX_BOOL bTransMask = FALSE) const override; 339 int image_height, bool bTransMask = false) const ove rride;
340 340
341 FX_FLOAT m_WhitePoint[3]; 341 FX_FLOAT m_WhitePoint[3];
342 FX_FLOAT m_BlackPoint[3]; 342 FX_FLOAT m_BlackPoint[3];
343 FX_FLOAT m_Gamma[3]; 343 FX_FLOAT m_Gamma[3];
344 FX_FLOAT m_Matrix[9]; 344 FX_FLOAT m_Matrix[9];
345 FX_BOOL m_bGamma; 345 bool m_bGamma;
346 FX_BOOL m_bMatrix; 346 bool m_bMatrix;
347 }; 347 };
348 FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 348 bool CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
349 { 349 {
350 CPDF_Dictionary* pDict = pArray->GetDict(1); 350 CPDF_Dictionary* pDict = pArray->GetDict(1);
351 if (!pDict) 351 if (!pDict)
352 return FALSE; 352 return false;
353 353
354 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); 354 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
355 int i; 355 int i;
356 for (i = 0; i < 3; i ++) { 356 for (i = 0; i < 3; i ++) {
357 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; 357 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
358 } 358 }
359 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); 359 pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
360 for (i = 0; i < 3; i ++) { 360 for (i = 0; i < 3; i ++) {
361 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; 361 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0;
362 } 362 }
363 pParam = pDict->GetArray(FX_BSTRC("Gamma")); 363 pParam = pDict->GetArray(FX_BSTRC("Gamma"));
364 if (pParam) { 364 if (pParam) {
365 m_bGamma = TRUE; 365 m_bGamma = true;
366 for (i = 0; i < 3; i ++) { 366 for (i = 0; i < 3; i ++) {
367 m_Gamma[i] = pParam->GetNumber(i); 367 m_Gamma[i] = pParam->GetNumber(i);
368 } 368 }
369 } else { 369 } else {
370 m_bGamma = FALSE; 370 m_bGamma = false;
371 } 371 }
372 pParam = pDict->GetArray(FX_BSTRC("Matrix")); 372 pParam = pDict->GetArray(FX_BSTRC("Matrix"));
373 if (pParam) { 373 if (pParam) {
374 m_bMatrix = TRUE; 374 m_bMatrix = true;
375 for (i = 0; i < 9; i ++) { 375 for (i = 0; i < 9; i ++) {
376 m_Matrix[i] = pParam->GetNumber(i); 376 m_Matrix[i] = pParam->GetNumber(i);
377 } 377 }
378 } else { 378 } else {
379 m_bMatrix = FALSE; 379 m_bMatrix = false;
380 } 380 }
381 return TRUE; 381 return true;
382 } 382 }
383 FX_BOOL CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const 383 bool CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
384 { 384 {
385 FX_FLOAT A_ = pBuf[0]; 385 FX_FLOAT A_ = pBuf[0];
386 FX_FLOAT B_ = pBuf[1]; 386 FX_FLOAT B_ = pBuf[1];
387 FX_FLOAT C_ = pBuf[2]; 387 FX_FLOAT C_ = pBuf[2];
388 if (m_bGamma) { 388 if (m_bGamma) {
389 A_ = (FX_FLOAT)FXSYS_pow(A_, m_Gamma[0]); 389 A_ = (FX_FLOAT)FXSYS_pow(A_, m_Gamma[0]);
390 B_ = (FX_FLOAT)FXSYS_pow(B_, m_Gamma[1]); 390 B_ = (FX_FLOAT)FXSYS_pow(B_, m_Gamma[1]);
391 C_ = (FX_FLOAT)FXSYS_pow(C_, m_Gamma[2]); 391 C_ = (FX_FLOAT)FXSYS_pow(C_, m_Gamma[2]);
392 } 392 }
393 FX_FLOAT X, Y, Z; 393 FX_FLOAT X, Y, Z;
394 if (m_bMatrix) { 394 if (m_bMatrix) {
395 X = m_Matrix[0] * A_ + m_Matrix[3] * B_ + m_Matrix[6] * C_; 395 X = m_Matrix[0] * A_ + m_Matrix[3] * B_ + m_Matrix[6] * C_;
396 Y = m_Matrix[1] * A_ + m_Matrix[4] * B_ + m_Matrix[7] * C_; 396 Y = m_Matrix[1] * A_ + m_Matrix[4] * B_ + m_Matrix[7] * C_;
397 Z = m_Matrix[2] * A_ + m_Matrix[5] * B_ + m_Matrix[8] * C_; 397 Z = m_Matrix[2] * A_ + m_Matrix[5] * B_ + m_Matrix[8] * C_;
398 } else { 398 } else {
399 X = A_; 399 X = A_;
400 Y = B_; 400 Y = B_;
401 Z = C_; 401 Z = C_;
402 } 402 }
403 XYZ_to_sRGB_WhitePoint(X, Y, Z, R, G, B, m_WhitePoint[0], m_WhitePoint[1], m _WhitePoint[2]); 403 XYZ_to_sRGB_WhitePoint(X, Y, Z, R, G, B, m_WhitePoint[0], m_WhitePoint[1], m _WhitePoint[2]);
404 return TRUE; 404 return true;
405 } 405 }
406 FX_BOOL CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const 406 bool CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) con st
407 { 407 {
408 pBuf[0] = R; 408 pBuf[0] = R;
409 pBuf[1] = G; 409 pBuf[1] = G;
410 pBuf[2] = B; 410 pBuf[2] = B;
411 return TRUE; 411 return true;
412 } 412 }
413 void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const 413 void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, bool bTransMask) const
414 { 414 {
415 if (bTransMask) { 415 if (bTransMask) {
416 FX_FLOAT Cal[3]; 416 FX_FLOAT Cal[3];
417 FX_FLOAT R, G, B; 417 FX_FLOAT R, G, B;
418 for(int i = 0; i < pixels; i ++) { 418 for(int i = 0; i < pixels; i ++) {
419 Cal[0] = ((FX_FLOAT)pSrcBuf[2]) / 255; 419 Cal[0] = ((FX_FLOAT)pSrcBuf[2]) / 255;
420 Cal[1] = ((FX_FLOAT)pSrcBuf[1]) / 255; 420 Cal[1] = ((FX_FLOAT)pSrcBuf[1]) / 255;
421 Cal[2] = ((FX_FLOAT)pSrcBuf[0]) / 255; 421 Cal[2] = ((FX_FLOAT)pSrcBuf[0]) / 255;
422 GetRGB(Cal, R, G, B); 422 GetRGB(Cal, R, G, B);
423 pDestBuf[0] = FXSYS_round(B * 255); 423 pDestBuf[0] = FXSYS_round(B * 255);
424 pDestBuf[1] = FXSYS_round(G * 255); 424 pDestBuf[1] = FXSYS_round(G * 255);
425 pDestBuf[2] = FXSYS_round(R * 255); 425 pDestBuf[2] = FXSYS_round(R * 255);
426 pSrcBuf += 3; 426 pSrcBuf += 3;
427 pDestBuf += 3; 427 pDestBuf += 3;
428 } 428 }
429 } 429 }
430 ReverseRGB(pDestBuf, pSrcBuf, pixels); 430 ReverseRGB(pDestBuf, pSrcBuf, pixels);
431 } 431 }
432 class CPDF_LabCS : public CPDF_ColorSpace 432 class CPDF_LabCS : public CPDF_ColorSpace
433 { 433 {
434 public: 434 public:
435 explicit CPDF_LabCS(CPDF_Document* pDoc) 435 explicit CPDF_LabCS(CPDF_Document* pDoc)
436 : CPDF_ColorSpace(pDoc, PDFCS_LAB, 3) { 436 : CPDF_ColorSpace(pDoc, PDFCS_LAB, 3) {
437 } 437 }
438 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override; 438 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override;
439 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 439 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
440 FX_BOOL» GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) co nst override; 440 bool» GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) co nst override;
441 FX_BOOL» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override; 441 bool» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override;
442 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width, 442 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width,
443 int image_height, FX_BOOL bTransMask = FALSE) const; 443 int image_height, bool bTransMask = false) const;
444 444
445 FX_FLOAT m_WhitePoint[3]; 445 FX_FLOAT m_WhitePoint[3];
446 FX_FLOAT m_BlackPoint[3]; 446 FX_FLOAT m_BlackPoint[3];
447 FX_FLOAT m_Ranges[4]; 447 FX_FLOAT m_Ranges[4];
448 }; 448 };
449 FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 449 bool CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
450 { 450 {
451 CPDF_Dictionary* pDict = pArray->GetDict(1); 451 CPDF_Dictionary* pDict = pArray->GetDict(1);
452 if (!pDict) { 452 if (!pDict) {
453 return FALSE; 453 return false;
454 } 454 }
455 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); 455 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint"));
456 int i; 456 int i;
457 for (i = 0; i < 3; i ++) { 457 for (i = 0; i < 3; i ++) {
458 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; 458 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0;
459 } 459 }
460 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); 460 pParam = pDict->GetArray(FX_BSTRC("BlackPoint"));
461 for (i = 0; i < 3; i ++) { 461 for (i = 0; i < 3; i ++) {
462 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; 462 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0;
463 } 463 }
464 pParam = pDict->GetArray(FX_BSTRC("Range")); 464 pParam = pDict->GetArray(FX_BSTRC("Range"));
465 const FX_FLOAT def_ranges[4] = { -100 * 1.0f, 100 * 1.0f, -100 * 1.0f, 100 * 1.0f}; 465 const FX_FLOAT def_ranges[4] = { -100 * 1.0f, 100 * 1.0f, -100 * 1.0f, 100 * 1.0f};
466 for (i = 0; i < 4; i ++) { 466 for (i = 0; i < 4; i ++) {
467 m_Ranges[i] = pParam ? pParam->GetNumber(i) : def_ranges[i]; 467 m_Ranges[i] = pParam ? pParam->GetNumber(i) : def_ranges[i];
468 } 468 }
469 return TRUE; 469 return true;
470 } 470 }
471 void CPDF_LabCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const 471 void CPDF_LabCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
472 { 472 {
473 assert(iComponent < 3); 473 assert(iComponent < 3);
474 value = 0; 474 value = 0;
475 if (iComponent == 0) { 475 if (iComponent == 0) {
476 min = 0; 476 min = 0;
477 max = 100 * 1.0f; 477 max = 100 * 1.0f;
478 } else { 478 } else {
479 min = m_Ranges[iComponent * 2 - 2]; 479 min = m_Ranges[iComponent * 2 - 2];
480 max = m_Ranges[iComponent * 2 - 1]; 480 max = m_Ranges[iComponent * 2 - 1];
481 if (value < min) { 481 if (value < min) {
482 value = min; 482 value = min;
483 } else if (value > max) { 483 } else if (value > max) {
484 value = max; 484 value = max;
485 } 485 }
486 } 486 }
487 } 487 }
488 FX_BOOL CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B ) const 488 bool CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) c onst
489 { 489 {
490 FX_FLOAT Lstar = pBuf[0]; 490 FX_FLOAT Lstar = pBuf[0];
491 FX_FLOAT astar = pBuf[1]; 491 FX_FLOAT astar = pBuf[1];
492 FX_FLOAT bstar = pBuf[2]; 492 FX_FLOAT bstar = pBuf[2];
493 FX_FLOAT M = (Lstar + 16.0f) / 116.0f; 493 FX_FLOAT M = (Lstar + 16.0f) / 116.0f;
494 FX_FLOAT L = M + astar / 500.0f; 494 FX_FLOAT L = M + astar / 500.0f;
495 FX_FLOAT N = M - bstar / 200.0f; 495 FX_FLOAT N = M - bstar / 200.0f;
496 FX_FLOAT X, Y, Z; 496 FX_FLOAT X, Y, Z;
497 if (L < 0.2069f) { 497 if (L < 0.2069f) {
498 X = 0.957f * 0.12842f * (L - 0.1379f); 498 X = 0.957f * 0.12842f * (L - 0.1379f);
499 } else { 499 } else {
500 X = 0.957f * L * L * L; 500 X = 0.957f * L * L * L;
501 } 501 }
502 if (M < 0.2069f) { 502 if (M < 0.2069f) {
503 Y = 0.12842f * (M - 0.1379f); 503 Y = 0.12842f * (M - 0.1379f);
504 } else { 504 } else {
505 Y = M * M * M; 505 Y = M * M * M;
506 } 506 }
507 if (N < 0.2069f) { 507 if (N < 0.2069f) {
508 Z = 1.0889f * 0.12842f * (N - 0.1379f); 508 Z = 1.0889f * 0.12842f * (N - 0.1379f);
509 } else { 509 } else {
510 Z = 1.0889f * N * N * N; 510 Z = 1.0889f * N * N * N;
511 } 511 }
512 XYZ_to_sRGB(X, Y, Z, R, G, B); 512 XYZ_to_sRGB(X, Y, Z, R, G, B);
513 return TRUE; 513 return true;
514 } 514 }
515 FX_BOOL CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) c onst 515 bool CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) cons t
516 { 516 {
517 return FALSE; 517 return false;
518 } 518 }
519 void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, i nt pixels, int image_width, int image_height, FX_BOOL bTransMask) const 519 void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, i nt pixels, int image_width, int image_height, bool bTransMask) const
520 { 520 {
521 for (int i = 0; i < pixels; i ++) { 521 for (int i = 0; i < pixels; i ++) {
522 FX_FLOAT lab[3]; 522 FX_FLOAT lab[3];
523 FX_FLOAT R, G, B; 523 FX_FLOAT R, G, B;
524 lab[0] = (pSrcBuf[0] * 100 / 255.0f); 524 lab[0] = (pSrcBuf[0] * 100 / 255.0f);
525 lab[1] = (FX_FLOAT)(pSrcBuf[1] - 128); 525 lab[1] = (FX_FLOAT)(pSrcBuf[1] - 128);
526 lab[2] = (FX_FLOAT)(pSrcBuf[2] - 128); 526 lab[2] = (FX_FLOAT)(pSrcBuf[2] - 128);
527 GetRGB(lab, R, G, B); 527 GetRGB(lab, R, G, B);
528 pDestBuf[0] = (int32_t)(B * 255); 528 pDestBuf[0] = (int32_t)(B * 255);
529 pDestBuf[1] = (int32_t)(G * 255); 529 pDestBuf[1] = (int32_t)(G * 255);
530 pDestBuf[2] = (int32_t)(R * 255); 530 pDestBuf[2] = (int32_t)(R * 255);
531 pDestBuf += 3; 531 pDestBuf += 3;
532 pSrcBuf += 3; 532 pSrcBuf += 3;
533 } 533 }
534 } 534 }
535 CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize): 535 CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize):
536 m_bsRGB(FALSE), 536 m_bsRGB(false),
537 m_pTransform(NULL), 537 m_pTransform(NULL),
538 m_nSrcComponents(0) 538 m_nSrcComponents(0)
539 { 539 {
540 if (dwSize == 3144 && FXSYS_memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) = = 0) { 540 if (dwSize == 3144 && FXSYS_memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) = = 0) {
541 m_bsRGB = TRUE; 541 m_bsRGB = true;
542 m_nSrcComponents = 3; 542 m_nSrcComponents = 3;
543 } 543 }
544 else if (CPDF_ModuleMgr::Get()->GetIccModule()) { 544 else if (CPDF_ModuleMgr::Get()->GetIccModule()) {
545 m_pTransform = CPDF_ModuleMgr::Get()->GetIccModule()->CreateTransform_sR GB(pData, dwSize, m_nSrcComponents); 545 m_pTransform = CPDF_ModuleMgr::Get()->GetIccModule()->CreateTransform_sR GB(pData, dwSize, m_nSrcComponents);
546 } 546 }
547 } 547 }
548 CPDF_IccProfile::~CPDF_IccProfile() 548 CPDF_IccProfile::~CPDF_IccProfile()
549 { 549 {
550 if (m_pTransform) { 550 if (m_pTransform) {
551 CPDF_ModuleMgr::Get()->GetIccModule()->DestroyTransform(m_pTransform); 551 CPDF_ModuleMgr::Get()->GetIccModule()->DestroyTransform(m_pTransform);
552 } 552 }
553 } 553 }
554 class CPDF_ICCBasedCS : public CPDF_ColorSpace 554 class CPDF_ICCBasedCS : public CPDF_ColorSpace
555 { 555 {
556 public: 556 public:
557 explicit CPDF_ICCBasedCS(CPDF_Document* pDoc) 557 explicit CPDF_ICCBasedCS(CPDF_Document* pDoc)
558 : CPDF_ColorSpace(pDoc, PDFCS_ICCBASED, 0), 558 : CPDF_ColorSpace(pDoc, PDFCS_ICCBASED, 0),
559 m_pAlterCS(nullptr), 559 m_pAlterCS(nullptr),
560 m_pProfile(nullptr), 560 m_pProfile(nullptr),
561 m_pCache(nullptr), 561 m_pCache(nullptr),
562 m_pRanges(nullptr), 562 m_pRanges(nullptr),
563 m_bOwn(FALSE) { 563 m_bOwn(false) {
564 } 564 }
565 ~CPDF_ICCBasedCS() override; 565 ~CPDF_ICCBasedCS() override;
566 566
567 FX_BOOL» v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 567 bool» v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
568 FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const override; 568 bool GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const ove rride;
569 FX_BOOL» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override; 569 bool» SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const override;
570 FX_BOOL» v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const override; 570 bool» v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const override;
571 void EnableStdConversion(FX_BOOL bEnabled) override; 571 void EnableStdConversion(bool bEnabled) override;
572 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width, 572 void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixel s, int image_width,
573 int image_height, FX_BOOL bTransMask = FALSE) const override; 573 int image_height, bool bTransMask = false) const ove rride;
574 574
575 CPDF_ColorSpace* m_pAlterCS; 575 CPDF_ColorSpace* m_pAlterCS;
576 CPDF_IccProfile* m_pProfile; 576 CPDF_IccProfile* m_pProfile;
577 uint8_t* m_pCache; 577 uint8_t* m_pCache;
578 FX_FLOAT* m_pRanges; 578 FX_FLOAT* m_pRanges;
579 FX_BOOL» m_bOwn; 579 bool» m_bOwn;
580 }; 580 };
581 581
582 CPDF_ICCBasedCS::~CPDF_ICCBasedCS() 582 CPDF_ICCBasedCS::~CPDF_ICCBasedCS()
583 { 583 {
584 if (m_pCache) { 584 if (m_pCache) {
585 FX_Free(m_pCache); 585 FX_Free(m_pCache);
586 } 586 }
587 if (m_pRanges) { 587 if (m_pRanges) {
588 FX_Free(m_pRanges); 588 FX_Free(m_pRanges);
589 } 589 }
590 if (m_pAlterCS && m_bOwn) { 590 if (m_pAlterCS && m_bOwn) {
591 m_pAlterCS->ReleaseCS(); 591 m_pAlterCS->ReleaseCS();
592 } 592 }
593 if (m_pProfile && m_pDocument) { 593 if (m_pProfile && m_pDocument) {
594 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile); 594 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile);
595 } 595 }
596 } 596 }
597 597
598 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 598 bool CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
599 { 599 {
600 CPDF_Stream* pStream = pArray->GetStream(1); 600 CPDF_Stream* pStream = pArray->GetStream(1);
601 if (pStream == NULL) { 601 if (pStream == NULL) {
602 return FALSE; 602 return false;
603 } 603 }
604 m_pProfile = pDoc->LoadIccProfile(pStream); 604 m_pProfile = pDoc->LoadIccProfile(pStream);
605 if (!m_pProfile) { 605 if (!m_pProfile) {
606 return FALSE; 606 return false;
607 } 607 }
608 m_nComponents = m_pProfile->GetComponents(); //Try using the nComponents fro m ICC profile 608 m_nComponents = m_pProfile->GetComponents(); //Try using the nComponents fro m ICC profile
609 CPDF_Dictionary* pDict = pStream->GetDict(); 609 CPDF_Dictionary* pDict = pStream->GetDict();
610 if (m_pProfile->m_pTransform == NULL) { // No valid ICC profile or using sRG B 610 if (m_pProfile->m_pTransform == NULL) { // No valid ICC profile or using sRG B
611 CPDF_Object* pAlterCSObj = pDict ? pDict->GetElementValue(FX_BSTRC("Alte rnate")) : NULL; 611 CPDF_Object* pAlterCSObj = pDict ? pDict->GetElementValue(FX_BSTRC("Alte rnate")) : NULL;
612 if (pAlterCSObj) { 612 if (pAlterCSObj) {
613 CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj) ; 613 CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj) ;
614 if (pAlterCS) { 614 if (pAlterCS) {
615 if (m_nComponents == 0) { // NO valid ICC profile 615 if (m_nComponents == 0) { // NO valid ICC profile
616 if (pAlterCS->CountComponents() > 0) { // Use Alternative co lorspace 616 if (pAlterCS->CountComponents() > 0) { // Use Alternative co lorspace
617 m_nComponents = pAlterCS->CountComponents(); 617 m_nComponents = pAlterCS->CountComponents();
618 m_pAlterCS = pAlterCS; 618 m_pAlterCS = pAlterCS;
619 m_bOwn = TRUE; 619 m_bOwn = true;
620 } 620 }
621 else { // No valid alternative colorspace 621 else { // No valid alternative colorspace
622 pAlterCS->ReleaseCS(); 622 pAlterCS->ReleaseCS();
623 int32_t nDictComponents = pDict ? pDict->GetInteger(FX_B STRC("N")) : 0; 623 int32_t nDictComponents = pDict ? pDict->GetInteger(FX_B STRC("N")) : 0;
624 if (nDictComponents != 1 && nDictComponents != 3 && nDic tComponents != 4) { 624 if (nDictComponents != 1 && nDictComponents != 3 && nDic tComponents != 4) {
625 return FALSE; 625 return false;
626 } 626 }
627 m_nComponents = nDictComponents; 627 m_nComponents = nDictComponents;
628 } 628 }
629 629
630 } 630 }
631 else { // Using sRGB 631 else { // Using sRGB
632 if (pAlterCS->CountComponents() != m_nComponents) { 632 if (pAlterCS->CountComponents() != m_nComponents) {
633 pAlterCS->ReleaseCS(); 633 pAlterCS->ReleaseCS();
634 } 634 }
635 else { 635 else {
636 m_pAlterCS = pAlterCS; 636 m_pAlterCS = pAlterCS;
637 m_bOwn = TRUE; 637 m_bOwn = true;
638 } 638 }
639 } 639 }
640 } 640 }
641 } 641 }
642 if (!m_pAlterCS) { 642 if (!m_pAlterCS) {
643 if (m_nComponents == 1) { 643 if (m_nComponents == 1) {
644 m_pAlterCS = GetStockCS(PDFCS_DEVICEGRAY); 644 m_pAlterCS = GetStockCS(PDFCS_DEVICEGRAY);
645 } 645 }
646 else if (m_nComponents == 3) { 646 else if (m_nComponents == 3) {
647 m_pAlterCS = GetStockCS(PDFCS_DEVICERGB); 647 m_pAlterCS = GetStockCS(PDFCS_DEVICERGB);
648 } 648 }
649 else if (m_nComponents == 4) { 649 else if (m_nComponents == 4) {
650 m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK); 650 m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK);
651 } 651 }
652 } 652 }
653 } 653 }
654 CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range")); 654 CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range"));
655 m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2); 655 m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2);
656 for (int i = 0; i < m_nComponents * 2; i ++) { 656 for (int i = 0; i < m_nComponents * 2; i ++) {
657 if (pRanges) { 657 if (pRanges) {
658 m_pRanges[i] = pRanges->GetNumber(i); 658 m_pRanges[i] = pRanges->GetNumber(i);
659 } else if (i % 2) { 659 } else if (i % 2) {
660 m_pRanges[i] = 1.0f; 660 m_pRanges[i] = 1.0f;
661 } else { 661 } else {
662 m_pRanges[i] = 0; 662 m_pRanges[i] = 0;
663 } 663 }
664 } 664 }
665 return TRUE; 665 return true;
666 } 666 }
667 FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLO AT& B) const 667 bool CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
668 { 668 {
669 if (m_pProfile && m_pProfile->m_bsRGB) { 669 if (m_pProfile && m_pProfile->m_bsRGB) {
670 R = pBuf[0]; 670 R = pBuf[0];
671 G = pBuf[1]; 671 G = pBuf[1];
672 B = pBuf[2]; 672 B = pBuf[2];
673 return TRUE; 673 return true;
674 } 674 }
675 ICodec_IccModule *pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); 675 ICodec_IccModule *pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
676 if (m_pProfile->m_pTransform == NULL || pIccModule == NULL) { 676 if (m_pProfile->m_pTransform == NULL || pIccModule == NULL) {
677 if (m_pAlterCS) { 677 if (m_pAlterCS) {
678 m_pAlterCS->GetRGB(pBuf, R, G, B); 678 m_pAlterCS->GetRGB(pBuf, R, G, B);
679 } else { 679 } else {
680 R = G = B = 0.0f; 680 R = G = B = 0.0f;
681 } 681 }
682 return TRUE; 682 return true;
683 } 683 }
684 FX_FLOAT rgb[3]; 684 FX_FLOAT rgb[3];
685 pIccModule->SetComponents(m_nComponents); 685 pIccModule->SetComponents(m_nComponents);
686 pIccModule->Translate(m_pProfile->m_pTransform, pBuf, rgb); 686 pIccModule->Translate(m_pProfile->m_pTransform, pBuf, rgb);
687 R = rgb[0]; 687 R = rgb[0];
688 G = rgb[1]; 688 G = rgb[1];
689 B = rgb[2]; 689 B = rgb[2];
690 return TRUE; 690 return true;
691 } 691 }
692 FX_BOOL CPDF_ICCBasedCS::v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_ FLOAT& y, FX_FLOAT& k) const 692 bool CPDF_ICCBasedCS::v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLO AT& y, FX_FLOAT& k) const
693 { 693 {
694 if (m_nComponents != 4) { 694 if (m_nComponents != 4) {
695 return FALSE; 695 return false;
696 } 696 }
697 c = pBuf[0]; 697 c = pBuf[0];
698 m = pBuf[1]; 698 m = pBuf[1];
699 y = pBuf[2]; 699 y = pBuf[2];
700 k = pBuf[3]; 700 k = pBuf[3];
701 return TRUE; 701 return true;
702 } 702 }
703 FX_BOOL CPDF_ICCBasedCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const 703 bool CPDF_ICCBasedCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const
704 { 704 {
705 return FALSE; 705 return false;
706 } 706 }
707 void CPDF_ICCBasedCS::EnableStdConversion(FX_BOOL bEnabled) 707 void CPDF_ICCBasedCS::EnableStdConversion(bool bEnabled)
708 { 708 {
709 CPDF_ColorSpace::EnableStdConversion(bEnabled); 709 CPDF_ColorSpace::EnableStdConversion(bEnabled);
710 if (m_pAlterCS) { 710 if (m_pAlterCS) {
711 m_pAlterCS->EnableStdConversion(bEnabled); 711 m_pAlterCS->EnableStdConversion(bEnabled);
712 } 712 }
713 } 713 }
714 void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcB uf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const 714 void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcB uf, int pixels, int image_width, int image_height, bool bTransMask) const
715 { 715 {
716 if (m_pProfile->m_bsRGB) { 716 if (m_pProfile->m_bsRGB) {
717 ReverseRGB(pDestBuf, pSrcBuf, pixels); 717 ReverseRGB(pDestBuf, pSrcBuf, pixels);
718 } else if (m_pProfile->m_pTransform) { 718 } else if (m_pProfile->m_pTransform) {
719 int nMaxColors = 1; 719 int nMaxColors = 1;
720 for (int i = 0; i < m_nComponents; i ++) { 720 for (int i = 0; i < m_nComponents; i ++) {
721 nMaxColors *= 52; 721 nMaxColors *= 52;
722 } 722 }
723 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2 ) { 723 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2 ) {
724 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(m_pProfile- >m_pTransform, pDestBuf, pSrcBuf, pixels); 724 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(m_pProfile- >m_pTransform, pDestBuf, pSrcBuf, pixels);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 { 759 {
760 public: 760 public:
761 explicit CPDF_IndexedCS(CPDF_Document* pDoc) 761 explicit CPDF_IndexedCS(CPDF_Document* pDoc)
762 : CPDF_ColorSpace(pDoc, PDFCS_INDEXED, 1), 762 : CPDF_ColorSpace(pDoc, PDFCS_INDEXED, 1),
763 m_pBaseCS(nullptr), 763 m_pBaseCS(nullptr),
764 m_pCountedBaseCS(nullptr), 764 m_pCountedBaseCS(nullptr),
765 m_pCompMinMax(nullptr) { 765 m_pCompMinMax(nullptr) {
766 } 766 }
767 ~CPDF_IndexedCS() override; 767 ~CPDF_IndexedCS() override;
768 768
769 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 769 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
770 FX_BOOL» GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) co nst override; 770 bool» GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) co nst override;
771 CPDF_ColorSpace* GetBaseCS() const override; 771 CPDF_ColorSpace* GetBaseCS() const override;
772 void EnableStdConversion(FX_BOOL bEnabled) override; 772 void EnableStdConversion(bool bEnabled) override;
773 773
774 CPDF_ColorSpace* m_pBaseCS; 774 CPDF_ColorSpace* m_pBaseCS;
775 CPDF_CountedColorSpace* m_pCountedBaseCS; 775 CPDF_CountedColorSpace* m_pCountedBaseCS;
776 int m_nBaseComponents; 776 int m_nBaseComponents;
777 int m_MaxIndex; 777 int m_MaxIndex;
778 CFX_ByteString m_Table; 778 CFX_ByteString m_Table;
779 FX_FLOAT* m_pCompMinMax; 779 FX_FLOAT* m_pCompMinMax;
780 }; 780 };
781 CPDF_IndexedCS::~CPDF_IndexedCS() 781 CPDF_IndexedCS::~CPDF_IndexedCS()
782 { 782 {
783 if (m_pCompMinMax) { 783 if (m_pCompMinMax) {
784 FX_Free(m_pCompMinMax); 784 FX_Free(m_pCompMinMax);
785 } 785 }
786 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL; 786 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL;
787 if (pCS && m_pDocument) { 787 if (pCS && m_pDocument) {
788 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); 788 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
789 } 789 }
790 } 790 }
791 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 791 bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
792 { 792 {
793 if (pArray->GetCount() < 4) { 793 if (pArray->GetCount() < 4) {
794 return FALSE; 794 return false;
795 } 795 }
796 CPDF_Object* pBaseObj = pArray->GetElementValue(1); 796 CPDF_Object* pBaseObj = pArray->GetElementValue(1);
797 if (pBaseObj == m_pArray) { 797 if (pBaseObj == m_pArray) {
798 return FALSE; 798 return false;
799 } 799 }
800 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); 800 CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
801 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL); 801 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL);
802 if (m_pBaseCS == NULL) { 802 if (m_pBaseCS == NULL) {
803 return FALSE; 803 return false;
804 } 804 }
805 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); 805 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray());
806 m_nBaseComponents = m_pBaseCS->CountComponents(); 806 m_nBaseComponents = m_pBaseCS->CountComponents();
807 m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2); 807 m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2);
808 FX_FLOAT defvalue; 808 FX_FLOAT defvalue;
809 for (int i = 0; i < m_nBaseComponents; i ++) { 809 for (int i = 0; i < m_nBaseComponents; i ++) {
810 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], m_pCompMin Max[i * 2 + 1]); 810 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], m_pCompMin Max[i * 2 + 1]);
811 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2]; 811 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2];
812 } 812 }
813 m_MaxIndex = pArray->GetInteger(2); 813 m_MaxIndex = pArray->GetInteger(2);
814 CPDF_Object* pTableObj = pArray->GetElementValue(3); 814 CPDF_Object* pTableObj = pArray->GetElementValue(3);
815 if (pTableObj == NULL) { 815 if (pTableObj == NULL) {
816 return FALSE; 816 return false;
817 } 817 }
818 if (pTableObj->GetType() == PDFOBJ_STRING) { 818 if (pTableObj->GetType() == PDFOBJ_STRING) {
819 m_Table = ((CPDF_String*)pTableObj)->GetString(); 819 m_Table = ((CPDF_String*)pTableObj)->GetString();
820 } else if (pTableObj->GetType() == PDFOBJ_STREAM) { 820 } else if (pTableObj->GetType() == PDFOBJ_STREAM) {
821 CPDF_StreamAcc acc; 821 CPDF_StreamAcc acc;
822 acc.LoadAllData((CPDF_Stream*)pTableObj, FALSE); 822 acc.LoadAllData((CPDF_Stream*)pTableObj, false);
823 m_Table = CFX_ByteStringC(acc.GetData(), acc.GetSize()); 823 m_Table = CFX_ByteStringC(acc.GetData(), acc.GetSize());
824 } 824 }
825 return TRUE; 825 return true;
826 } 826 }
827 827
828 FX_BOOL CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOA T& B) const 828 bool CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
829 { 829 {
830 int index = (int32_t)(*pBuf); 830 int index = (int32_t)(*pBuf);
831 if (index < 0 || index > m_MaxIndex) { 831 if (index < 0 || index > m_MaxIndex) {
832 return FALSE; 832 return false;
833 } 833 }
834 if (m_nBaseComponents) { 834 if (m_nBaseComponents) {
835 if (index == INT_MAX || (index + 1) > INT_MAX / m_nBaseComponents || 835 if (index == INT_MAX || (index + 1) > INT_MAX / m_nBaseComponents ||
836 (index + 1)*m_nBaseComponents > (int)m_Table.GetLength()) { 836 (index + 1)*m_nBaseComponents > (int)m_Table.GetLength()) {
837 R = G = B = 0; 837 R = G = B = 0;
838 return FALSE; 838 return false;
839 } 839 }
840 } 840 }
841 CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents); 841 CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents);
842 FX_FLOAT* comps = Comps; 842 FX_FLOAT* comps = Comps;
843 const uint8_t* pTable = m_Table; 843 const uint8_t* pTable = m_Table;
844 for (int i = 0; i < m_nBaseComponents; i ++) { 844 for (int i = 0; i < m_nBaseComponents; i ++) {
845 comps[i] = m_pCompMinMax[i * 2] + m_pCompMinMax[i * 2 + 1] * pTable[inde x * m_nBaseComponents + i] / 255; 845 comps[i] = m_pCompMinMax[i * 2] + m_pCompMinMax[i * 2 + 1] * pTable[inde x * m_nBaseComponents + i] / 255;
846 } 846 }
847 m_pBaseCS->GetRGB(comps, R, G, B); 847 m_pBaseCS->GetRGB(comps, R, G, B);
848 return TRUE; 848 return true;
849 } 849 }
850 CPDF_ColorSpace*CPDF_IndexedCS::GetBaseCS() const 850 CPDF_ColorSpace*CPDF_IndexedCS::GetBaseCS() const
851 { 851 {
852 return m_pBaseCS; 852 return m_pBaseCS;
853 } 853 }
854 void CPDF_IndexedCS::EnableStdConversion(FX_BOOL bEnabled) 854 void CPDF_IndexedCS::EnableStdConversion(bool bEnabled)
855 { 855 {
856 CPDF_ColorSpace::EnableStdConversion(bEnabled); 856 CPDF_ColorSpace::EnableStdConversion(bEnabled);
857 if (m_pBaseCS) { 857 if (m_pBaseCS) {
858 m_pBaseCS->EnableStdConversion(bEnabled); 858 m_pBaseCS->EnableStdConversion(bEnabled);
859 } 859 }
860 } 860 }
861 #define MAX_PATTERN_COLORCOMPS 16 861 #define MAX_PATTERN_COLORCOMPS 16
862 typedef struct _PatternValue { 862 typedef struct _PatternValue {
863 CPDF_Pattern* m_pPattern; 863 CPDF_Pattern* m_pPattern;
864 CPDF_CountedPattern* m_pCountedPattern; 864 CPDF_CountedPattern* m_pCountedPattern;
865 int m_nComps; 865 int m_nComps;
866 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; 866 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS];
867 } PatternValue; 867 } PatternValue;
868 CPDF_PatternCS::~CPDF_PatternCS() 868 CPDF_PatternCS::~CPDF_PatternCS()
869 { 869 {
870 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL; 870 CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL;
871 if (pCS && m_pDocument) { 871 if (pCS && m_pDocument) {
872 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); 872 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
873 } 873 }
874 } 874 }
875 FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 875 bool CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
876 { 876 {
877 CPDF_Object* pBaseCS = pArray->GetElementValue(1); 877 CPDF_Object* pBaseCS = pArray->GetElementValue(1);
878 if (pBaseCS == m_pArray) { 878 if (pBaseCS == m_pArray) {
879 return FALSE; 879 return false;
880 } 880 }
881 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); 881 CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
882 m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL); 882 m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL);
883 if (m_pBaseCS) { 883 if (m_pBaseCS) {
884 if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) { 884 if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) {
885 return FALSE; 885 return false;
886 } 886 }
887 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray() ); 887 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray() );
888 m_nComponents = m_pBaseCS->CountComponents() + 1; 888 m_nComponents = m_pBaseCS->CountComponents() + 1;
889 if (m_pBaseCS->CountComponents() > MAX_PATTERN_COLORCOMPS) { 889 if (m_pBaseCS->CountComponents() > MAX_PATTERN_COLORCOMPS) {
890 return FALSE; 890 return false;
891 } 891 }
892 } else { 892 } else {
893 m_nComponents = 1; 893 m_nComponents = 1;
894 } 894 }
895 return TRUE; 895 return true;
896 } 896 }
897 FX_BOOL CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOA T& B) const 897 bool CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
898 { 898 {
899 if (m_pBaseCS) { 899 if (m_pBaseCS) {
900 ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); 900 ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN);
901 PatternValue* pvalue = (PatternValue*)pBuf; 901 PatternValue* pvalue = (PatternValue*)pBuf;
902 if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) { 902 if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) {
903 return TRUE; 903 return true;
904 } 904 }
905 } 905 }
906 R = G = B = 0.75f; 906 R = G = B = 0.75f;
907 return FALSE; 907 return false;
908 } 908 }
909 CPDF_ColorSpace* CPDF_PatternCS::GetBaseCS() const 909 CPDF_ColorSpace* CPDF_PatternCS::GetBaseCS() const
910 { 910 {
911 return m_pBaseCS; 911 return m_pBaseCS;
912 } 912 }
913 class CPDF_SeparationCS : public CPDF_ColorSpace 913 class CPDF_SeparationCS : public CPDF_ColorSpace
914 { 914 {
915 public: 915 public:
916 CPDF_SeparationCS(CPDF_Document* pDoc) 916 CPDF_SeparationCS(CPDF_Document* pDoc)
917 : CPDF_ColorSpace(pDoc, PDFCS_SEPARATION, 1), 917 : CPDF_ColorSpace(pDoc, PDFCS_SEPARATION, 1),
918 m_pAltCS(nullptr), 918 m_pAltCS(nullptr),
919 m_pFunc(nullptr) { 919 m_pFunc(nullptr) {
920 } 920 }
921 ~CPDF_SeparationCS() override; 921 ~CPDF_SeparationCS() override;
922 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override; 922 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override;
923 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 923 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
924 FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const override; 924 bool GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const ove rride;
925 void EnableStdConversion(FX_BOOL bEnabled) override; 925 void EnableStdConversion(bool bEnabled) override;
926 926
927 CPDF_ColorSpace* m_pAltCS; 927 CPDF_ColorSpace* m_pAltCS;
928 CPDF_Function* m_pFunc; 928 CPDF_Function* m_pFunc;
929 enum { None, All, Colorant } m_Type; 929 enum { None, All, Colorant } m_Type;
930 }; 930 };
931 CPDF_SeparationCS::~CPDF_SeparationCS() 931 CPDF_SeparationCS::~CPDF_SeparationCS()
932 { 932 {
933 if (m_pAltCS) { 933 if (m_pAltCS) {
934 m_pAltCS->ReleaseCS(); 934 m_pAltCS->ReleaseCS();
935 } 935 }
936 delete m_pFunc; 936 delete m_pFunc;
937 } 937 }
938 void CPDF_SeparationCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOA T& min, FX_FLOAT& max) const 938 void CPDF_SeparationCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOA T& min, FX_FLOAT& max) const
939 { 939 {
940 value = 1.0f; 940 value = 1.0f;
941 min = 0; 941 min = 0;
942 max = 1.0f; 942 max = 1.0f;
943 } 943 }
944 FX_BOOL CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 944 bool CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
945 { 945 {
946 CFX_ByteString name = pArray->GetString(1); 946 CFX_ByteString name = pArray->GetString(1);
947 if (name == FX_BSTRC("None")) { 947 if (name == FX_BSTRC("None")) {
948 m_Type = None; 948 m_Type = None;
949 } else { 949 } else {
950 m_Type = Colorant; 950 m_Type = Colorant;
951 CPDF_Object* pAltCS = pArray->GetElementValue(2); 951 CPDF_Object* pAltCS = pArray->GetElementValue(2);
952 if (pAltCS == m_pArray) { 952 if (pAltCS == m_pArray) {
953 return FALSE; 953 return false;
954 } 954 }
955 m_pAltCS = Load(pDoc, pAltCS); 955 m_pAltCS = Load(pDoc, pAltCS);
956 if (!m_pAltCS) { 956 if (!m_pAltCS) {
957 return FALSE; 957 return false;
958 } 958 }
959 CPDF_Object* pFuncObj = pArray->GetElementValue(3); 959 CPDF_Object* pFuncObj = pArray->GetElementValue(3);
960 if (pFuncObj && pFuncObj->GetType() != PDFOBJ_NAME) { 960 if (pFuncObj && pFuncObj->GetType() != PDFOBJ_NAME) {
961 m_pFunc = CPDF_Function::Load(pFuncObj); 961 m_pFunc = CPDF_Function::Load(pFuncObj);
962 } 962 }
963 if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { 963 if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) {
964 delete m_pFunc; 964 delete m_pFunc;
965 m_pFunc = NULL; 965 m_pFunc = NULL;
966 } 966 }
967 } 967 }
968 return TRUE; 968 return true;
969 } 969 }
970 FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_F LOAT& B) const 970 bool CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOA T& B) const
971 { 971 {
972 if (m_Type == None) { 972 if (m_Type == None) {
973 return FALSE; 973 return false;
974 } 974 }
975 if (m_pFunc == NULL) { 975 if (m_pFunc == NULL) {
976 if (m_pAltCS == NULL) { 976 if (m_pAltCS == NULL) {
977 return FALSE; 977 return false;
978 } 978 }
979 int nComps = m_pAltCS->CountComponents(); 979 int nComps = m_pAltCS->CountComponents();
980 CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps); 980 CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps);
981 for (int i = 0; i < nComps; i ++) { 981 for (int i = 0; i < nComps; i ++) {
982 results[i] = *pBuf; 982 results[i] = *pBuf;
983 } 983 }
984 m_pAltCS->GetRGB(results, R, G, B); 984 m_pAltCS->GetRGB(results, R, G, B);
985 return TRUE; 985 return true;
986 } 986 }
987 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); 987 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
988 int nresults = 0; 988 int nresults = 0;
989 m_pFunc->Call(pBuf, 1, results, nresults); 989 m_pFunc->Call(pBuf, 1, results, nresults);
990 if (nresults == 0) { 990 if (nresults == 0) {
991 return FALSE; 991 return false;
992 } 992 }
993 if (m_pAltCS) { 993 if (m_pAltCS) {
994 m_pAltCS->GetRGB(results, R, G, B); 994 m_pAltCS->GetRGB(results, R, G, B);
995 return TRUE; 995 return true;
996 } else { 996 } else {
997 R = G = B = 0; 997 R = G = B = 0;
998 return FALSE; 998 return false;
999 } 999 }
1000 } 1000 }
1001 void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) 1001 void CPDF_SeparationCS::EnableStdConversion(bool bEnabled)
1002 { 1002 {
1003 CPDF_ColorSpace::EnableStdConversion(bEnabled); 1003 CPDF_ColorSpace::EnableStdConversion(bEnabled);
1004 if (m_pAltCS) { 1004 if (m_pAltCS) {
1005 m_pAltCS->EnableStdConversion(bEnabled); 1005 m_pAltCS->EnableStdConversion(bEnabled);
1006 } 1006 }
1007 } 1007 }
1008 class CPDF_DeviceNCS : public CPDF_ColorSpace 1008 class CPDF_DeviceNCS : public CPDF_ColorSpace
1009 { 1009 {
1010 public: 1010 public:
1011 CPDF_DeviceNCS(CPDF_Document* pDoc) 1011 CPDF_DeviceNCS(CPDF_Document* pDoc)
1012 : CPDF_ColorSpace(pDoc, PDFCS_DEVICEN, 0), 1012 : CPDF_ColorSpace(pDoc, PDFCS_DEVICEN, 0),
1013 m_pAltCS(nullptr), 1013 m_pAltCS(nullptr),
1014 m_pFunc(nullptr) { 1014 m_pFunc(nullptr) {
1015 } 1015 }
1016 ~CPDF_DeviceNCS() override; 1016 ~CPDF_DeviceNCS() override;
1017 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override; 1017 void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOA T& max) const override;
1018 FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; 1018 bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override;
1019 FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const override; 1019 bool GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const ove rride;
1020 void EnableStdConversion(FX_BOOL bEnabled) override; 1020 void EnableStdConversion(bool bEnabled) override;
1021 1021
1022 CPDF_ColorSpace* m_pAltCS; 1022 CPDF_ColorSpace* m_pAltCS;
1023 CPDF_Function* m_pFunc; 1023 CPDF_Function* m_pFunc;
1024 }; 1024 };
1025 CPDF_DeviceNCS::~CPDF_DeviceNCS() 1025 CPDF_DeviceNCS::~CPDF_DeviceNCS()
1026 { 1026 {
1027 delete m_pFunc; 1027 delete m_pFunc;
1028 if (m_pAltCS) { 1028 if (m_pAltCS) {
1029 m_pAltCS->ReleaseCS(); 1029 m_pAltCS->ReleaseCS();
1030 } 1030 }
1031 } 1031 }
1032 void CPDF_DeviceNCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const 1032 void CPDF_DeviceNCS::GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const
1033 { 1033 {
1034 value = 1.0f; 1034 value = 1.0f;
1035 min = 0; 1035 min = 0;
1036 max = 1.0f; 1036 max = 1.0f;
1037 } 1037 }
1038 FX_BOOL CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) 1038 bool CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
1039 { 1039 {
1040 CPDF_Object* pObj = pArray->GetElementValue(1); 1040 CPDF_Object* pObj = pArray->GetElementValue(1);
1041 if (!pObj) { 1041 if (!pObj) {
1042 return FALSE; 1042 return false;
1043 } 1043 }
1044 if (pObj->GetType() != PDFOBJ_ARRAY) { 1044 if (pObj->GetType() != PDFOBJ_ARRAY) {
1045 return FALSE; 1045 return false;
1046 } 1046 }
1047 m_nComponents = ((CPDF_Array*)pObj)->GetCount(); 1047 m_nComponents = ((CPDF_Array*)pObj)->GetCount();
1048 CPDF_Object* pAltCS = pArray->GetElementValue(2); 1048 CPDF_Object* pAltCS = pArray->GetElementValue(2);
1049 if (!pAltCS || pAltCS == m_pArray) { 1049 if (!pAltCS || pAltCS == m_pArray) {
1050 return FALSE; 1050 return false;
1051 } 1051 }
1052 m_pAltCS = Load(pDoc, pAltCS); 1052 m_pAltCS = Load(pDoc, pAltCS);
1053 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3)); 1053 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3));
1054 if (m_pAltCS == NULL || m_pFunc == NULL) { 1054 if (m_pAltCS == NULL || m_pFunc == NULL) {
1055 return FALSE; 1055 return false;
1056 } 1056 }
1057 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { 1057 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) {
1058 return FALSE; 1058 return false;
1059 } 1059 }
1060 return TRUE; 1060 return true;
1061 } 1061 }
1062 FX_BOOL CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOA T& B) const 1062 bool CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const
1063 { 1063 {
1064 if (m_pFunc == NULL) { 1064 if (m_pFunc == NULL) {
1065 return FALSE; 1065 return false;
1066 } 1066 }
1067 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); 1067 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
1068 int nresults = 0; 1068 int nresults = 0;
1069 m_pFunc->Call(pBuf, m_nComponents, results, nresults); 1069 m_pFunc->Call(pBuf, m_nComponents, results, nresults);
1070 if (nresults == 0) { 1070 if (nresults == 0) {
1071 return FALSE; 1071 return false;
1072 } 1072 }
1073 m_pAltCS->GetRGB(results, R, G, B); 1073 m_pAltCS->GetRGB(results, R, G, B);
1074 return TRUE; 1074 return true;
1075 } 1075 }
1076 void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) 1076 void CPDF_DeviceNCS::EnableStdConversion(bool bEnabled)
1077 { 1077 {
1078 CPDF_ColorSpace::EnableStdConversion(bEnabled); 1078 CPDF_ColorSpace::EnableStdConversion(bEnabled);
1079 if (m_pAltCS) { 1079 if (m_pAltCS) {
1080 m_pAltCS->EnableStdConversion(bEnabled); 1080 m_pAltCS->EnableStdConversion(bEnabled);
1081 } 1081 }
1082 } 1082 }
1083 CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) 1083 CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family)
1084 { 1084 {
1085 return CPDF_ModuleMgr::Get()->GetPageModule()->GetStockCS(family);; 1085 return CPDF_ModuleMgr::Get()->GetPageModule()->GetStockCS(family);;
1086 } 1086 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 return sizeof(PatternValue); 1192 return sizeof(PatternValue);
1193 } 1193 }
1194 return m_nComponents * sizeof(FX_FLOAT); 1194 return m_nComponents * sizeof(FX_FLOAT);
1195 } 1195 }
1196 FX_FLOAT* CPDF_ColorSpace::CreateBuf() 1196 FX_FLOAT* CPDF_ColorSpace::CreateBuf()
1197 { 1197 {
1198 int size = GetBufSize(); 1198 int size = GetBufSize();
1199 uint8_t* pBuf = FX_Alloc(uint8_t, size); 1199 uint8_t* pBuf = FX_Alloc(uint8_t, size);
1200 return (FX_FLOAT*)pBuf; 1200 return (FX_FLOAT*)pBuf;
1201 } 1201 }
1202 FX_BOOL CPDF_ColorSpace::sRGB() const 1202 bool CPDF_ColorSpace::sRGB() const
1203 { 1203 {
1204 if (m_Family == PDFCS_DEVICERGB) { 1204 if (m_Family == PDFCS_DEVICERGB) {
1205 return TRUE; 1205 return true;
1206 } 1206 }
1207 if (m_Family != PDFCS_ICCBASED) { 1207 if (m_Family != PDFCS_ICCBASED) {
1208 return FALSE; 1208 return false;
1209 } 1209 }
1210 CPDF_ICCBasedCS* pCS = (CPDF_ICCBasedCS*)this; 1210 CPDF_ICCBasedCS* pCS = (CPDF_ICCBasedCS*)this;
1211 return pCS->m_pProfile->m_bsRGB; 1211 return pCS->m_pProfile->m_bsRGB;
1212 } 1212 }
1213 FX_BOOL CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FL OAT& y, FX_FLOAT& k) const 1213 bool CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT & y, FX_FLOAT& k) const
1214 { 1214 {
1215 if (v_GetCMYK(pBuf, c, m, y, k)) { 1215 if (v_GetCMYK(pBuf, c, m, y, k)) {
1216 return TRUE; 1216 return true;
1217 } 1217 }
1218 FX_FLOAT R, G, B; 1218 FX_FLOAT R, G, B;
1219 if (!GetRGB(pBuf, R, G, B)) { 1219 if (!GetRGB(pBuf, R, G, B)) {
1220 return FALSE; 1220 return false;
1221 } 1221 }
1222 sRGB_to_AdobeCMYK(R, G, B, c, m, y, k); 1222 sRGB_to_AdobeCMYK(R, G, B, c, m, y, k);
1223 return TRUE; 1223 return true;
1224 } 1224 }
1225 FX_BOOL CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA T y, FX_FLOAT k) const 1225 bool CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y , FX_FLOAT k) const
1226 { 1226 {
1227 if (v_SetCMYK(pBuf, c, m, y, k)) { 1227 if (v_SetCMYK(pBuf, c, m, y, k)) {
1228 return TRUE; 1228 return true;
1229 } 1229 }
1230 FX_FLOAT R, G, B; 1230 FX_FLOAT R, G, B;
1231 AdobeCMYK_to_sRGB(c, m, y, k, R, G, B); 1231 AdobeCMYK_to_sRGB(c, m, y, k, R, G, B);
1232 return SetRGB(pBuf, R, G, B); 1232 return SetRGB(pBuf, R, G, B);
1233 } 1233 }
1234 void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const 1234 void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const
1235 { 1235 {
1236 if (buf == NULL || m_Family == PDFCS_PATTERN) { 1236 if (buf == NULL || m_Family == PDFCS_PATTERN) {
1237 return; 1237 return;
1238 } 1238 }
1239 FX_FLOAT min, max; 1239 FX_FLOAT min, max;
1240 for (int i = 0; i < m_nComponents; i ++) { 1240 for (int i = 0; i < m_nComponents; i ++) {
1241 GetDefaultValue(i, buf[i], min, max); 1241 GetDefaultValue(i, buf[i], min, max);
1242 } 1242 }
1243 } 1243 }
1244 int CPDF_ColorSpace::GetMaxIndex() const 1244 int CPDF_ColorSpace::GetMaxIndex() const
1245 { 1245 {
1246 if (m_Family != PDFCS_INDEXED) { 1246 if (m_Family != PDFCS_INDEXED) {
1247 return 0; 1247 return 0;
1248 } 1248 }
1249 CPDF_IndexedCS* pCS = (CPDF_IndexedCS*)this; 1249 CPDF_IndexedCS* pCS = (CPDF_IndexedCS*)this;
1250 return pCS->m_MaxIndex; 1250 return pCS->m_MaxIndex;
1251 } 1251 }
1252 void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, const uint8_t* src_b uf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const 1252 void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, const uint8_t* src_b uf, int pixels, int image_width, int image_height, bool bTransMask) const
1253 { 1253 {
1254 CFX_FixedBufGrow<FX_FLOAT, 16> srcbuf(m_nComponents); 1254 CFX_FixedBufGrow<FX_FLOAT, 16> srcbuf(m_nComponents);
1255 FX_FLOAT* src = srcbuf; 1255 FX_FLOAT* src = srcbuf;
1256 FX_FLOAT R, G, B; 1256 FX_FLOAT R, G, B;
1257 for (int i = 0; i < pixels; i ++) { 1257 for (int i = 0; i < pixels; i ++) {
1258 for (int j = 0; j < m_nComponents; j ++) 1258 for (int j = 0; j < m_nComponents; j ++)
1259 if (m_Family == PDFCS_INDEXED) { 1259 if (m_Family == PDFCS_INDEXED) {
1260 src[j] = (FX_FLOAT)(*src_buf ++); 1260 src[j] = (FX_FLOAT)(*src_buf ++);
1261 } else { 1261 } else {
1262 src[j] = (FX_FLOAT)(*src_buf ++) / 255; 1262 src[j] = (FX_FLOAT)(*src_buf ++) / 255;
1263 } 1263 }
1264 GetRGB(src, R, G, B); 1264 GetRGB(src, R, G, B);
1265 *dest_buf ++ = (int32_t)(B * 255); 1265 *dest_buf ++ = (int32_t)(B * 255);
1266 *dest_buf ++ = (int32_t)(G * 255); 1266 *dest_buf ++ = (int32_t)(G * 255);
1267 *dest_buf ++ = (int32_t)(R * 255); 1267 *dest_buf ++ = (int32_t)(R * 255);
1268 } 1268 }
1269 } 1269 }
1270 void CPDF_ColorSpace::EnableStdConversion(FX_BOOL bEnabled) 1270 void CPDF_ColorSpace::EnableStdConversion(bool bEnabled)
1271 { 1271 {
1272 if (bEnabled) { 1272 if (bEnabled) {
1273 m_dwStdConversion ++; 1273 m_dwStdConversion ++;
1274 } else if (m_dwStdConversion) { 1274 } else if (m_dwStdConversion) {
1275 m_dwStdConversion --; 1275 m_dwStdConversion --;
1276 } 1276 }
1277 } 1277 }
1278 CPDF_Color::CPDF_Color(int family) 1278 CPDF_Color::CPDF_Color(int family)
1279 { 1279 {
1280 m_pCS = CPDF_ColorSpace::GetStockCS(family); 1280 m_pCS = CPDF_ColorSpace::GetStockCS(family);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 } 1392 }
1393 } 1393 }
1394 if (m_pCS == NULL) { 1394 if (m_pCS == NULL) {
1395 return; 1395 return;
1396 } 1396 }
1397 m_pBuffer = m_pCS->CreateBuf(); 1397 m_pBuffer = m_pCS->CreateBuf();
1398 FXSYS_memcpy(m_pBuffer, pSrc->m_pBuffer, m_pCS->GetBufSize()); 1398 FXSYS_memcpy(m_pBuffer, pSrc->m_pBuffer, m_pCS->GetBufSize());
1399 if (m_pCS->GetFamily() == PDFCS_PATTERN) { 1399 if (m_pCS->GetFamily() == PDFCS_PATTERN) {
1400 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1400 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1401 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) { 1401 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
1402 pvalue->m_pPattern = pvalue->m_pPattern->m_pDocument->GetPageData()- >GetPattern(pvalue->m_pPattern->m_pPatternObj, FALSE, &pvalue->m_pPattern->m_Par entMatrix); 1402 pvalue->m_pPattern = pvalue->m_pPattern->m_pDocument->GetPageData()- >GetPattern(pvalue->m_pPattern->m_pPatternObj, false, &pvalue->m_pPattern->m_Par entMatrix);
1403 } 1403 }
1404 } 1404 }
1405 } 1405 }
1406 FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const 1406 bool CPDF_Color::GetRGB(int& R, int& G, int& B) const
1407 { 1407 {
1408 if (m_pCS == NULL || m_pBuffer == NULL) { 1408 if (m_pCS == NULL || m_pBuffer == NULL) {
1409 return FALSE; 1409 return false;
1410 } 1410 }
1411 FX_FLOAT r=0.0f, g=0.0f, b=0.0f; 1411 FX_FLOAT r=0.0f, g=0.0f, b=0.0f;
1412 if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) { 1412 if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) {
1413 return FALSE; 1413 return false;
1414 } 1414 }
1415 R = (int32_t)(r * 255 + 0.5f); 1415 R = (int32_t)(r * 255 + 0.5f);
1416 G = (int32_t)(g * 255 + 0.5f); 1416 G = (int32_t)(g * 255 + 0.5f);
1417 B = (int32_t)(b * 255 + 0.5f); 1417 B = (int32_t)(b * 255 + 0.5f);
1418 return TRUE; 1418 return true;
1419 } 1419 }
1420 CPDF_Pattern* CPDF_Color::GetPattern() const 1420 CPDF_Pattern* CPDF_Color::GetPattern() const
1421 { 1421 {
1422 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1422 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
1423 return NULL; 1423 return NULL;
1424 } 1424 }
1425 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1425 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1426 return pvalue->m_pPattern; 1426 return pvalue->m_pPattern;
1427 } 1427 }
1428 CPDF_ColorSpace* CPDF_Color::GetPatternCS() const 1428 CPDF_ColorSpace* CPDF_Color::GetPatternCS() const
1429 { 1429 {
1430 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1430 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
1431 return NULL; 1431 return NULL;
1432 } 1432 }
1433 return m_pCS->GetBaseCS(); 1433 return m_pCS->GetBaseCS();
1434 } 1434 }
1435 FX_FLOAT* CPDF_Color::GetPatternColor() const 1435 FX_FLOAT* CPDF_Color::GetPatternColor() const
1436 { 1436 {
1437 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1437 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
1438 return NULL; 1438 return NULL;
1439 } 1439 }
1440 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1440 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1441 return pvalue->m_nComps ? pvalue->m_Comps : NULL; 1441 return pvalue->m_nComps ? pvalue->m_Comps : NULL;
1442 } 1442 }
1443 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const 1443 bool CPDF_Color::IsEqual(const CPDF_Color& other) const
1444 { 1444 {
1445 if (m_pCS != other.m_pCS || m_pCS == NULL) { 1445 if (m_pCS != other.m_pCS || m_pCS == NULL) {
1446 return FALSE; 1446 return false;
1447 } 1447 }
1448 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; 1448 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
1449 } 1449 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698