Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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_acc.h"
12
#
include
"core/fxcodec/icc/icc_transform.h"
13
14
namespace
{
15
16
bool
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
23
CPDF_IccProfile::CPDF_IccProfile(
RetainPtr
<
const
CPDF_StreamAcc> stream_acc,
24
uint32_t expected_components)
25
: m_pStreamAcc(std::move(stream_acc)),
26
m_bsRGB(expected_components == 3 && DetectSRGB(m_pStreamAcc->GetSpan())) {
27
if
(m_bsRGB) {
28
m_nSrcComponents = 3;
29
return
;
30
}
31
32
auto
transform =
33
fxcodec::IccTransform::CreateTransformSRGB(m_pStreamAcc->GetSpan());
34
if
(!transform) {
35
return
;
36
}
37
38
uint32_t components = transform->components();
39
if
(components != expected_components) {
40
return
;
41
}
42
43
m_nSrcComponents = components;
44
m_Transform = std::move(transform);
45
}
46
47
CPDF_IccProfile::~
CPDF_IccProfile
() =
default
;
48
49
bool
CPDF_IccProfile::
IsNormal
()
const
{
50
return
m_Transform->IsNormal();
51
}
52
53
void
CPDF_IccProfile::
Translate
(pdfium::span<
const
float
> pSrcValues,
54
pdfium::span<
float
> pDestValues) {
55
m_Transform->Translate(pSrcValues, pDestValues);
56
}
57
58
void
CPDF_IccProfile::
TranslateScanline
(pdfium::span<uint8_t> pDest,
59
pdfium::span<
const
uint8_t> pSrc,
60
int
pixels) {
61
m_Transform->TranslateScanline(pDest, pSrc, pixels);
62
}
CPDF_IccProfile::IsNormal
bool IsNormal() const
Definition
cpdf_iccprofile.cpp:49
CPDF_IccProfile::TranslateScanline
void TranslateScanline(pdfium::span< uint8_t > pDest, pdfium::span< const uint8_t > pSrc, int pixels)
Definition
cpdf_iccprofile.cpp:58
CPDF_IccProfile::Translate
void Translate(pdfium::span< const float > pSrcValues, pdfium::span< float > pDestValues)
Definition
cpdf_iccprofile.cpp:53
CPDF_IccProfile::~CPDF_IccProfile
~CPDF_IccProfile() override
fxcrt::RetainPtr
Definition
retain_ptr.h:28
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
page
cpdf_iccprofile.cpp
Generated on
for Qt by
1.18.0