• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fpdfapi/page/cpdf_iccprofile.h"
8 
9 #include "core/fpdfapi/parser/cpdf_stream.h"
10 #include "core/fxcodec/icc/iccmodule.h"
11 
12 namespace {
13 
DetectSRGB(pdfium::span<const uint8_t> span)14 bool DetectSRGB(pdfium::span<const uint8_t> span) {
15   static const char kSRGB[] = "sRGB IEC61966-2.1";
16   return span.size() == 3144 && memcmp(&span[400], kSRGB, strlen(kSRGB)) == 0;
17 }
18 
19 }  // namespace
20 
CPDF_IccProfile(const CPDF_Stream * pStream,pdfium::span<const uint8_t> span)21 CPDF_IccProfile::CPDF_IccProfile(const CPDF_Stream* pStream,
22                                  pdfium::span<const uint8_t> span)
23     : m_bsRGB(DetectSRGB(span)), m_pStream(pStream) {
24   if (m_bsRGB) {
25     m_nSrcComponents = 3;
26     return;
27   }
28 
29   m_Transform = IccModule::CreateTransformSRGB(span);
30   if (m_Transform)
31     m_nSrcComponents = m_Transform->components();
32 }
33 
34 CPDF_IccProfile::~CPDF_IccProfile() = default;
35