7#include "core/fpdfdoc/cpdf_iconfit.h"
12#include "core/fpdfapi/parser/cpdf_array.h"
13#include "core/fpdfapi/parser/cpdf_dictionary.h"
14#include "core/fxcrt/fx_string.h"
18constexpr float kDefaultPosition = 0.5f;
33 ByteString csSW = m_pDict->GetByteStringFor(
"SW",
"A");
44 return !m_pDict || m_pDict->GetByteStringFor(
"S",
"P") !=
"A";
48 float fLeft = kDefaultPosition;
49 float fBottom = kDefaultPosition;
51 return {fLeft, fBottom};
55 return {fLeft, fBottom};
57 size_t dwCount = pA->size();
59 fLeft = pA->GetFloatAt(0);
61 fBottom = pA->GetFloatAt(1);
62 return {fLeft, fBottom};
66 return m_pDict && m_pDict->GetBooleanFor(
"FB",
false);
77 size_t dwCount = pA->size();
78 return {dwCount > 0 ? pA->GetFloatAt(0) : 0.0f,
79 dwCount > 1 ? pA->GetFloatAt(1) : 0.0f};
86 const float fPlateWidth = rcPlate
.Width();
87 const float fPlateHeight = rcPlate
.Height();
88 const float fImageWidth = image_size.width;
89 const float fImageHeight = image_size.height;
92 fHScale = fPlateWidth /
std::max(fImageWidth, 1.0f);
93 fVScale = fPlateHeight /
std::max(fImageHeight, 1.0f);
96 if (fPlateWidth < fImageWidth)
97 fHScale = fPlateWidth /
std::max(fImageWidth, 1.0f);
98 if (fPlateHeight < fImageHeight)
99 fVScale = fPlateHeight /
std::max(fImageHeight, 1.0f);
102 if (fPlateWidth > fImageWidth)
103 fHScale = fPlateWidth /
std::max(fImageWidth, 1.0f);
104 if (fPlateHeight > fImageHeight)
105 fVScale = fPlateHeight /
std::max(fImageHeight, 1.0f);
112 float min_scale =
std::min(fHScale, fVScale);
116 return {fHScale, fVScale};
122 const CFX_PointF icon_position = GetIconPosition();
123 const float fImageFactWidth = image_size.width * scale.x;
124 const float fImageFactHeight = image_size.height * scale.y;
125 return {(rcPlate
.Width() - fImageFactWidth) * icon_position.x,
126 (rcPlate
.Height() - fImageFactHeight) * icon_position.y};
fxcrt::ByteString ByteString
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
ScaleMethod GetScaleMethod() const
bool GetFittingBounds() const
CFX_VectorF GetImageOffset(const CFX_SizeF &image_size, const CFX_VectorF &scale, const CFX_FloatRect &rcPlate) const
CFX_PointF GetIconBottomLeftPosition() const
bool IsProportionalScale() const
CFX_VectorF GetScale(const CFX_SizeF &image_size, const CFX_FloatRect &rcPlate) const
CPDF_IconFit(RetainPtr< const CPDF_Dictionary > pDict)
CPDF_IconFit(const CPDF_IconFit &that)
bool operator==(const char *ptr) const
CFX_VTemplate< float > CFX_VectorF
CFX_PTemplate< float > CFX_PointF
CFX_STemplate< float > CFX_SizeF