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

Unified Diff: core/src/fxcodec/codec/fx_codec_icc.cpp

Issue 493163003: Use number of components from ICC profile and alternateCS (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« core/src/fpdfapi/fpdf_page/pageint.h ('K') | « core/src/fxcodec/codec/codec_int.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/codec/fx_codec_icc.cpp
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index b10d9c48683db2318857d6e230130750fecd06a8..f0ece07c31b56b5e23e454e75af78400b565be4c 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -7,6 +7,12 @@
#include "../../../include/fxcodec/fx_codec.h"
#include "codec_int.h"
#include "../lcms2/include/fx_lcms2.h"
+#define N_COMPONENT_LAB 3
jun_fang 2014/08/25 18:56:51 It's better to use const variables rather than mac
Bo Xu 2014/08/25 20:28:18 Done.
+#define N_COMPONENT_GRAY 1
+#define N_COMPONENT_RGB 3
+#define N_COMPONENT_CMYK 4
+#define N_COMPONENT_DEFAULT 3
+
FX_BOOL MD5ComputeID( FX_LPCVOID buf, FX_DWORD dwSize, FX_BYTE ID[16] )
{
return cmsMD5computeIDExt(buf, dwSize, ID);
@@ -59,14 +65,35 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs, int nComponents, FX_BOOL bDst
}
return TRUE;
}
-void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
- const unsigned char* pDstProfileData, unsigned int dwDstProfileSize, int nDstComponents,
+FX_INT32 GetCSComponents(cmsColorSpaceSignature cs)
+{
jun_fang 2014/08/25 18:56:51 FX_DWORD components = N_COMPONENT_DEFAULT;
Bo Xu 2014/08/25 20:28:18 Done.
+ switch (cs) {
+ case cmsSigLabData:
+ return N_COMPONENT_LAB;
jun_fang 2014/08/25 18:56:51 use |components = N_COMPONENT_LAB| to replace the
+ break;
+ case cmsSigGrayData:
+ return N_COMPONENT_GRAY;
+ break;
+ case cmsSigRgbData:
+ return N_COMPONENT_RGB;
+ break;
+ case cmsSigCmykData:
+ return N_COMPONENT_CMYK;
+ break;
+ default:
+ return N_COMPONENT_DEFAULT;
+ break;
+ }
jun_fang 2014/08/25 18:56:51 return components;
+}
+void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32* nSrcComponents,
+ const unsigned char* pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 nDstComponents,
int intent, FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT)
{
cmsHPROFILE srcProfile = NULL;
cmsHPROFILE dstProfile = NULL;
cmsHTRANSFORM hTransform = NULL;
CLcmsCmm* pCmm = NULL;
+ *nSrcComponents = 0;
jun_fang 2014/08/25 18:56:51 Need to check whether nSrcComponents is NULL.
Bo Xu 2014/08/25 20:28:18 I have changed nSrcComponents from pointer to refe
srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
if (srcProfile == NULL) {
return NULL;
@@ -83,16 +110,12 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, unsigned int
int srcFormat;
FX_BOOL bLab = FALSE;
cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile);
- if (!CheckComponents(srcCS, nSrcComponents, FALSE)) {
- cmsCloseProfile(srcProfile);
- cmsCloseProfile(dstProfile);
- return NULL;
- }
+ *nSrcComponents = GetCSComponents(srcCS);
if (srcCS == cmsSigLabData) {
- srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0);
+ srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(0);
bLab = TRUE;
} else {
- srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(nSrcComponents) | BYTES_SH(1);
+ srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(1);
if (srcCS == cmsSigRgbData && T_DOSWAP(dwSrcFormat)) {
srcFormat |= DOSWAP_SH(1);
}
@@ -127,7 +150,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, unsigned int
if (pCmm == NULL) {
return NULL;
}
- pCmm->m_nSrcComponents = nSrcComponents;
+ pCmm->m_nSrcComponents = *nSrcComponents;
pCmm->m_nDstComponents = nDstComponents;
pCmm->m_hTransform = hTransform;
pCmm->m_bLab = bLab;
@@ -135,7 +158,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, unsigned int
cmsCloseProfile(dstProfile);
return pCmm;
}
-void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, unsigned int dwProfileSize, int nComponents, int intent, FX_DWORD dwSrcFormat)
+void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dwProfileSize, FX_INT32* nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat)
{
return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, 0, 3, intent, dwSrcFormat);
}
@@ -192,7 +215,7 @@ void IccLib_Translate(void* pTransform, FX_DWORD nSrcComponents, FX_FLOAT* pSrcV
break;
}
}
-void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, int pixels)
+void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, FX_INT32 pixels)
{
cmsDoTransform(((CLcmsCmm*)pTransform)->m_hTransform, (void*)pSrc, pDest, pixels);
}
@@ -242,7 +265,7 @@ ICodec_IccModule::IccCS GetProfileCSFromHandle(FX_LPVOID pProfile)
return ICodec_IccModule::IccCS_Unknown;
}
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(FX_LPCBYTE pProfileData, unsigned int dwProfileSize)
+ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize)
{
ICodec_IccModule::IccCS cs;
cmsHPROFILE hProfile = cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
@@ -517,12 +540,12 @@ CCodec_IccModule::~CCodec_IccModule()
}
}
}
-void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, unsigned int dwProfileSize, int nComponents, int intent, FX_DWORD dwSrcFormat)
+void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, FX_INT32* nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat)
{
return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, intent, dwSrcFormat);
}
-void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
- FX_LPCBYTE pDstProfileData, unsigned int dwDstProfileSize, int intent,
+void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32* nSrcComponents,
+ FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 intent,
FX_DWORD dwSrcFormat , FX_DWORD dwDstFormat)
{
return IccLib_CreateTransform(pSrcProfileData, dwSrcProfileSize, nSrcComponents,
@@ -536,7 +559,7 @@ void CCodec_IccModule::Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOA
{
IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues);
}
-void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, int pixels)
+void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, FX_INT32 pixels)
{
IccLib_TranslateImage(pTransform, pDest, pSrc, pixels);
}
« core/src/fpdfapi/fpdf_page/pageint.h ('K') | « 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