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_imageloader.cpp
Go to the documentation of this file.
1// Copyright 2016 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_imageloader.h"
8
9#include <utility>
10
11#include "core/fpdfapi/page/cpdf_dib.h"
12#include "core/fpdfapi/page/cpdf_image.h"
13#include "core/fpdfapi/page/cpdf_imageobject.h"
14#include "core/fpdfapi/page/cpdf_pageimagecache.h"
15#include "core/fpdfapi/page/cpdf_transferfunc.h"
16#include "core/fxge/dib/cfx_dibitmap.h"
17#include "third_party/base/check.h"
18
20
22
23bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage,
24 CPDF_PageImageCache* pPageImageCache,
25 const CPDF_Dictionary* pFormResource,
26 const CPDF_Dictionary* pPageResource,
27 bool bStdCS,
28 CPDF_ColorSpace::Family eFamily,
29 bool bLoadMask,
30 const CFX_Size& max_size_required) {
31 m_pCache = pPageImageCache;
32 m_pImageObject = pImage;
33 bool should_continue;
34 if (m_pCache) {
35 should_continue = m_pCache->StartGetCachedBitmap(
36 m_pImageObject->GetImage(), pFormResource, pPageResource, bStdCS,
37 eFamily, bLoadMask, max_size_required);
38 } else {
39 should_continue = m_pImageObject->GetImage()->StartLoadDIBBase(
40 pFormResource, pPageResource, bStdCS, eFamily, bLoadMask,
41 max_size_required);
42 }
43 if (!should_continue) {
44 Finish();
45 }
46 return should_continue;
47}
48
50 bool should_continue = m_pCache
51 ? m_pCache->Continue(pPause)
52 : m_pImageObject->GetImage()->Continue(pPause);
53 if (!should_continue) {
54 Finish();
55 }
56 return should_continue;
57}
58
60 RetainPtr<CPDF_TransferFunc> pTransferFunc) {
61 DCHECK(pTransferFunc);
62 DCHECK(!pTransferFunc->GetIdentity());
63 m_pBitmap = pTransferFunc->TranslateImage(std::move(m_pBitmap));
64 if (m_bCached && m_pMask)
65 m_pMask = m_pMask->Realize();
66 m_bCached = false;
67 return m_pBitmap;
68}
69
70void CPDF_ImageLoader::Finish() {
71 if (m_pCache) {
72 m_bCached = true;
73 m_pBitmap = m_pCache->DetachCurBitmap();
74 m_pMask = m_pCache->DetachCurMask();
75 m_MatteColor = m_pCache->GetCurMatteColor();
76 return;
77 }
78 RetainPtr<CPDF_Image> pImage = m_pImageObject->GetImage();
79 m_bCached = false;
80 m_pBitmap = pImage->DetachBitmap();
81 m_pMask = pImage->DetachMask();
82 m_MatteColor = pImage->GetMatteColor();
83}
RetainPtr< CFX_DIBBase > TranslateImage(RetainPtr< CPDF_TransferFunc > pTransferFunc)
bool Start(const CPDF_ImageObject *pImage, CPDF_PageImageCache *pPageImageCache, const CPDF_Dictionary *pFormResource, const CPDF_Dictionary *pPageResource, bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size &max_size_required)
bool Continue(PauseIndicatorIface *pPause)