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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_icc.cpp

Issue 1783933002: Change colorspace's number of components to be unsigned (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 9 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/fxcodec/codec/codec_int.h ('k') | no next file » | 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 "core/include/fxcodec/fx_codec.h" 7 #include "core/include/fxcodec/fx_codec.h"
8 #include "core/src/fxcodec/codec/codec_int.h" 8 #include "core/src/fxcodec/codec/codec_int.h"
9 #include "third_party/lcms2-2.6/include/lcms2.h" 9 #include "third_party/lcms2-2.6/include/lcms2.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 break; 60 break;
61 default: 61 default:
62 if (nComponents != 3) { 62 if (nComponents != 3) {
63 return FALSE; 63 return FALSE;
64 } 64 }
65 break; 65 break;
66 } 66 }
67 return TRUE; 67 return TRUE;
68 } 68 }
69 int32_t GetCSComponents(cmsColorSpaceSignature cs) { 69
70 FX_DWORD GetCSComponents(cmsColorSpaceSignature cs) {
70 FX_DWORD components; 71 FX_DWORD components;
71 switch (cs) { 72 switch (cs) {
72 case cmsSigLabData: 73 case cmsSigLabData:
73 components = N_COMPONENT_LAB; 74 components = N_COMPONENT_LAB;
74 break; 75 break;
75 case cmsSigGrayData: 76 case cmsSigGrayData:
76 components = N_COMPONENT_GRAY; 77 components = N_COMPONENT_GRAY;
77 break; 78 break;
78 case cmsSigRgbData: 79 case cmsSigRgbData:
79 components = N_COMPONENT_RGB; 80 components = N_COMPONENT_RGB;
80 break; 81 break;
81 case cmsSigCmykData: 82 case cmsSigCmykData:
82 components = N_COMPONENT_CMYK; 83 components = N_COMPONENT_CMYK;
83 break; 84 break;
84 default: 85 default:
85 components = N_COMPONENT_DEFAULT; 86 components = N_COMPONENT_DEFAULT;
86 break; 87 break;
87 } 88 }
88 return components; 89 return components;
89 } 90 }
91
90 void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, 92 void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
91 FX_DWORD dwSrcProfileSize, 93 FX_DWORD dwSrcProfileSize,
92 int32_t& nSrcComponents, 94 FX_DWORD& nSrcComponents,
93 const unsigned char* pDstProfileData, 95 const unsigned char* pDstProfileData,
94 FX_DWORD dwDstProfileSize, 96 FX_DWORD dwDstProfileSize,
95 int32_t nDstComponents, 97 int32_t nDstComponents,
96 int intent, 98 int intent,
97 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, 99 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
98 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) { 100 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) {
99 cmsHPROFILE srcProfile = NULL; 101 cmsHPROFILE srcProfile = NULL;
100 cmsHPROFILE dstProfile = NULL; 102 cmsHPROFILE dstProfile = NULL;
101 cmsHTRANSFORM hTransform = NULL; 103 cmsHTRANSFORM hTransform = NULL;
102 CLcmsCmm* pCmm = NULL; 104 CLcmsCmm* pCmm = NULL;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 pCmm->m_nSrcComponents = nSrcComponents; 164 pCmm->m_nSrcComponents = nSrcComponents;
163 pCmm->m_nDstComponents = nDstComponents; 165 pCmm->m_nDstComponents = nDstComponents;
164 pCmm->m_hTransform = hTransform; 166 pCmm->m_hTransform = hTransform;
165 pCmm->m_bLab = bLab; 167 pCmm->m_bLab = bLab;
166 cmsCloseProfile(srcProfile); 168 cmsCloseProfile(srcProfile);
167 cmsCloseProfile(dstProfile); 169 cmsCloseProfile(dstProfile);
168 return pCmm; 170 return pCmm;
169 } 171 }
170 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, 172 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData,
171 FX_DWORD dwProfileSize, 173 FX_DWORD dwProfileSize,
172 int32_t& nComponents, 174 FX_DWORD& nComponents,
173 int32_t intent, 175 int32_t intent,
174 FX_DWORD dwSrcFormat) { 176 FX_DWORD dwSrcFormat) {
175 return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, 177 return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL,
176 0, 3, intent, dwSrcFormat); 178 0, 3, intent, dwSrcFormat);
177 } 179 }
178 void IccLib_DestroyTransform(void* pTransform) { 180 void IccLib_DestroyTransform(void* pTransform) {
179 if (!pTransform) { 181 if (!pTransform) {
180 return; 182 return;
181 } 183 }
182 cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform); 184 cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 delete pair.second; 531 delete pair.second;
530 } 532 }
531 m_MapProfile.clear(); 533 m_MapProfile.clear();
532 for (const auto& pair : m_MapTranform) { 534 for (const auto& pair : m_MapTranform) {
533 delete pair.second; 535 delete pair.second;
534 } 536 }
535 m_MapTranform.clear(); 537 m_MapTranform.clear();
536 } 538 }
537 void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, 539 void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData,
538 FX_DWORD dwProfileSize, 540 FX_DWORD dwProfileSize,
539 int32_t& nComponents, 541 FX_DWORD& nComponents,
540 int32_t intent, 542 int32_t intent,
541 FX_DWORD dwSrcFormat) { 543 FX_DWORD dwSrcFormat) {
542 return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, 544 return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents,
543 intent, dwSrcFormat); 545 intent, dwSrcFormat);
544 } 546 }
547
545 void* CCodec_IccModule::CreateTransform_CMYK(const uint8_t* pSrcProfileData, 548 void* CCodec_IccModule::CreateTransform_CMYK(const uint8_t* pSrcProfileData,
546 FX_DWORD dwSrcProfileSize, 549 FX_DWORD dwSrcProfileSize,
547 int32_t& nSrcComponents, 550 FX_DWORD& nSrcComponents,
548 const uint8_t* pDstProfileData, 551 const uint8_t* pDstProfileData,
549 FX_DWORD dwDstProfileSize, 552 FX_DWORD dwDstProfileSize,
550 int32_t intent, 553 int32_t intent,
551 FX_DWORD dwSrcFormat, 554 FX_DWORD dwSrcFormat,
552 FX_DWORD dwDstFormat) { 555 FX_DWORD dwDstFormat) {
553 return IccLib_CreateTransform( 556 return IccLib_CreateTransform(
554 pSrcProfileData, dwSrcProfileSize, nSrcComponents, pDstProfileData, 557 pSrcProfileData, dwSrcProfileSize, nSrcComponents, pDstProfileData,
555 dwDstProfileSize, 4, intent, dwSrcFormat, dwDstFormat); 558 dwDstProfileSize, 4, intent, dwSrcFormat, dwDstFormat);
556 } 559 }
560
557 void CCodec_IccModule::DestroyTransform(void* pTransform) { 561 void CCodec_IccModule::DestroyTransform(void* pTransform) {
558 IccLib_DestroyTransform(pTransform); 562 IccLib_DestroyTransform(pTransform);
559 } 563 }
560 void CCodec_IccModule::Translate(void* pTransform, 564 void CCodec_IccModule::Translate(void* pTransform,
561 FX_FLOAT* pSrcValues, 565 FX_FLOAT* pSrcValues,
562 FX_FLOAT* pDestValues) { 566 FX_FLOAT* pDestValues) {
563 IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues); 567 IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues);
564 } 568 }
565 void CCodec_IccModule::TranslateScanline(void* pTransform, 569 void CCodec_IccModule::TranslateScanline(void* pTransform,
566 uint8_t* pDest, 570 uint8_t* pDest,
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 uint8_t c1 = FXSYS_round(c * 255); 1977 uint8_t c1 = FXSYS_round(c * 255);
1974 uint8_t m1 = FXSYS_round(m * 255); 1978 uint8_t m1 = FXSYS_round(m * 255);
1975 uint8_t y1 = FXSYS_round(y * 255); 1979 uint8_t y1 = FXSYS_round(y * 255);
1976 uint8_t k1 = FXSYS_round(k * 255); 1980 uint8_t k1 = FXSYS_round(k * 255);
1977 uint8_t r, g, b; 1981 uint8_t r, g, b;
1978 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); 1982 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b);
1979 R = 1.0f * r / 255; 1983 R = 1.0f * r / 255;
1980 G = 1.0f * g / 255; 1984 G = 1.0f * g / 255;
1981 B = 1.0f * b / 255; 1985 B = 1.0f * b / 255;
1982 } 1986 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698