28 const bool kLittleEndian =
false;
29 const uint8_t kSig[] = {
30 'A',
'p',
'p',
'l',
'e',
' ',
'i',
'O',
'S', 0, 0, 1,
'M',
'M',
32 if (!
data ||
data->size() <
sizeof(kSig)) {
35 if (memcmp(
data->data(), kSig,
sizeof(kSig)) != 0) {
39 std::move(
data), kLittleEndian,
sizeof(kSig));
46 bool hasMaker33 =
false;
47 bool hasMaker48 =
false;
50 for (uint32_t
i = 0;
i < ifd->getNumEntries(); ++
i) {
51 switch (ifd->getEntryTag(
i)) {
54 hasMaker33 = ifd->getEntrySignedRational(
i, 1, &maker33);
59 hasMaker48 = ifd->getEntrySignedRational(
i, 1, &maker48);
72 if (maker48 <= 0.01f) {
73 stops = -20.0f * maker48 + 1.8f;
75 stops = -0.101f * maker48 + 1.601f;
78 if (maker48 <= 0.01f) {
79 stops = -70.0f * maker48 + 3.0f;
81 stops = -0.303f * maker48 + 2.303f;
84 return std::pow(2.f,
std::max(stops, 0.f));
89 std::unique_ptr<SkTiff::ImageFileDirectory> ifd,
95 for (uint32_t
i = 0;
i < ifd->getNumEntries(); ++
i) {
96 switch (ifd->getEntryTag(
i)) {
99 if (!exif.
fOrigin.has_value() && ifd->getEntryUnsignedShort(
i, 1, &
value)) {
108 if (
auto makerNoteData = ifd->getEntryUndefinedData(
i)) {
114 uint32_t subIfdOffset = 0;
115 if (isRoot && ifd->getEntryUnsignedLong(
i, 1, &subIfdOffset)) {
117 data, littleEndian, subIfdOffset,
true);
151 uint16_t value16 = 0;
153 ifd->getEntryUnsignedShort(
i, 1, &value16)) {
156 uint32_t value32 = 0;
158 ifd->getEntryUnsignedLong(
i, 1, &value32)) {
164 uint16_t value16 = 0;
166 ifd->getEntryUnsignedShort(
i, 1, &value16)) {
169 uint32_t value32 = 0;
171 ifd->getEntryUnsignedLong(
i, 1, &value32)) {
183 bool littleEndian =
false;
184 uint32_t ifdOffset = 0;
188 dataRef, littleEndian, ifdOffset,
true);
189 parse_ifd(metadata, std::move(dataRef), std::move(ifd), littleEndian,
true);
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
static bool ParseHeader(const SkData *data, bool *outLittleEndian, uint32_t *outIfdOffset)
static std::unique_ptr< ImageFileDirectory > MakeFromOffset(sk_sp< SkData > data, bool littleEndian, uint32_t ifdOffset, bool allowTruncated=false)
static float max(float r, float g, float b)
constexpr uint16_t kMarkerNoteTag
static void parse_ifd(Metadata &exif, sk_sp< SkData > data, std::unique_ptr< SkTiff::ImageFileDirectory > ifd, bool littleEndian, bool isRoot)
constexpr uint16_t kSubIFDOffsetTag
static constexpr uint16_t kResolutionUnitTag
static constexpr uint16_t kPixelXDimensionTag
static constexpr uint16_t kPixelYDimensionTag
static constexpr uint16_t kOriginTag
static std::optional< float > get_maker_note_hdr_headroom(sk_sp< SkData > data)
static constexpr uint16_t kXResolutionTag
void SK_API Parse(Metadata &metadata, const SkData *data)
static constexpr uint16_t kYResolutionTag
std::shared_ptr< const fml::Mapping > data