25 {
26
27
28 const bool kLittleEndian = false;
29 const uint8_t kSig[] = {
30 'A', 'p', 'p', 'l', 'e', ' ', 'i', 'O', 'S', 0, 0, 1, 'M', 'M',
31 };
32 if (!
data ||
data->size() <
sizeof(kSig)) {
33 return std::nullopt;
34 }
35 if (memcmp(
data->data(), kSig,
sizeof(kSig)) != 0) {
36 return std::nullopt;
37 }
39 std::move(
data), kLittleEndian,
sizeof(kSig));
40 if (!ifd) {
41 return std::nullopt;
42 }
43
44
45
46 bool hasMaker33 = false;
47 bool hasMaker48 = false;
48 float maker33 = 0.f;
49 float maker48 = 0.f;
50 for (uint32_t
i = 0;
i < ifd->getNumEntries(); ++
i) {
51 switch (ifd->getEntryTag(
i)) {
52 case 33:
53 if (!hasMaker33) {
54 hasMaker33 = ifd->getEntrySignedRational(
i, 1, &maker33);
55 }
56 break;
57 case 48:
58 if (!hasMaker48) {
59 hasMaker48 = ifd->getEntrySignedRational(
i, 1, &maker48);
60 }
61 break;
62 default:
63 break;
64 }
65 }
66
67 if (!hasMaker33) {
68 return std::nullopt;
69 }
70 float stops = 0.f;
71 if (maker33 < 1.0f) {
72 if (maker48 <= 0.01f) {
73 stops = -20.0f * maker48 + 1.8f;
74 } else {
75 stops = -0.101f * maker48 + 1.601f;
76 }
77 } else {
78 if (maker48 <= 0.01f) {
79 stops = -70.0f * maker48 + 3.0f;
80 } else {
81 stops = -0.303f * maker48 + 2.303f;
82 }
83 }
84 return std::pow(2.f,
std::max(stops, 0.f));
85}
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)
std::shared_ptr< const fml::Mapping > data