• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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/fpdfdoc/cpdf_icon.h"
8 
9 #include "core/fpdfapi/parser/cpdf_dictionary.h"
10 #include "core/fpdfapi/parser/cpdf_stream.h"
11 
CPDF_Icon(CPDF_Stream * pStream)12 CPDF_Icon::CPDF_Icon(CPDF_Stream* pStream) : m_pStream(pStream) {}
13 
14 CPDF_Icon::~CPDF_Icon() = default;
15 
GetImageSize() const16 CFX_SizeF CPDF_Icon::GetImageSize() const {
17   CPDF_Dictionary* pDict = m_pStream->GetDict();
18   if (!pDict)
19     return CFX_SizeF();
20 
21   CFX_FloatRect rect = pDict->GetRectFor("BBox");
22   return {rect.right - rect.left, rect.top - rect.bottom};
23 }
24 
GetImageMatrix() const25 CFX_Matrix CPDF_Icon::GetImageMatrix() const {
26   CPDF_Dictionary* pDict = m_pStream->GetDict();
27   if (!pDict)
28     return CFX_Matrix();
29 
30   return pDict->GetMatrixFor("Matrix");
31 }
32 
GetImageAlias() const33 ByteString CPDF_Icon::GetImageAlias() const {
34   CPDF_Dictionary* pDict = m_pStream->GetDict();
35   if (!pDict)
36     return ByteString();
37 
38   return pDict->GetStringFor("Name");
39 }
40