Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_iccprofile.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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 <utility>
10
11#include "core/fpdfapi/parser/cpdf_stream.h"
12#include "core/fxcodec/icc/icc_transform.h"
13
14namespace {
15
16bool DetectSRGB(pdfium::span<const uint8_t> span) {
17 static const char kSRGB[] = "sRGB IEC61966-2.1";
18 return span.size() == 3144 && memcmp(&span[400], kSRGB, strlen(kSRGB)) == 0;
19}
20
21} // namespace
22
23CPDF_IccProfile::CPDF_IccProfile(RetainPtr<const CPDF_Stream> pStream,
24 pdfium::span<const uint8_t> span,
25 uint32_t expected_components)
26 : m_bsRGB(DetectSRGB(span)), m_pStream(std::move(pStream)) {
27 if (m_bsRGB) {
28 m_nSrcComponents = 3;
29 return;
30 }
31
32 auto transform = fxcodec::IccTransform::CreateTransformSRGB(span);
33 if (!transform) {
34 return;
35 }
36
37 uint32_t components = transform->components();
38 if (components != expected_components) {
39 return;
40 }
41
42 m_nSrcComponents = components;
43 m_Transform = std::move(transform);
44}
45
46CPDF_IccProfile::~CPDF_IccProfile() = default;
47
48bool CPDF_IccProfile::IsNormal() const {
49 return m_Transform->IsNormal();
50}
51
52void CPDF_IccProfile::Translate(pdfium::span<const float> pSrcValues,
53 pdfium::span<float> pDestValues) {
54 m_Transform->Translate(pSrcValues, pDestValues);
55}
56
57void CPDF_IccProfile::TranslateScanline(pdfium::span<uint8_t> pDest,
58 pdfium::span<const uint8_t> pSrc,
59 int pixels) {
60 m_Transform->TranslateScanline(pDest, pSrc, pixels);
61}
bool IsNormal() const
void TranslateScanline(pdfium::span< uint8_t > pDest, pdfium::span< const uint8_t > pSrc, int pixels)
void Translate(pdfium::span< const float > pSrcValues, pdfium::span< float > pDestValues)
~CPDF_IccProfile() override