Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
SkExif.cpp File Reference
#include "include/private/SkExif.h"
#include "include/core/SkData.h"
#include "src/codec/SkCodecPriv.h"
#include "src/codec/SkTiffUtility.h"
#include <algorithm>
#include <cmath>
#include <cstring>
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

static bool get_maker_note_hdr_headroom (sk_sp< SkData > data, float *hdrHeadroom)
 

Variables

constexpr uint16_t kSubIFDOffsetTag = 0x8769
 
constexpr uint16_t kOriginTag = 0x112
 
constexpr uint16_t kMarkerNoteTag = 0x927c
 
constexpr uint16_t kXResolutionTag = 0x011a
 
constexpr uint16_t kYResolutionTag = 0x011b
 
constexpr uint16_t kResolutionUnitTag = 0x0128
 
constexpr uint16_t kPixelXDimensionTag = 0xa002
 
constexpr uint16_t kPixelYDimensionTag = 0xa003
 

Function Documentation

◆ get_maker_note_hdr_headroom()

static bool get_maker_note_hdr_headroom ( sk_sp< SkData data,
float *  hdrHeadroom 
)
static

Definition at line 33 of file SkExif.cpp.

33 {
34 // No little endian images that specify this data have been observed. Do not add speculative
35 // support.
36 const bool kLittleEndian = false;
37 const uint8_t kSig[] = {
38 'A', 'p', 'p', 'l', 'e', ' ', 'i', 'O', 'S', 0, 0, 1, 'M', 'M', //
39 };
40 if (!data || data->size() < sizeof(kSig)) {
41 return false;
42 }
43 if (memcmp(data->data(), kSig, sizeof(kSig)) != 0) {
44 return false;
45 }
46 auto ifd =
47 SkTiffImageFileDirectory::MakeFromOffset(std::move(data), kLittleEndian, sizeof(kSig));
48 if (!ifd) {
49 return false;
50 }
51
52 // See documentation at:
53 // https://developer.apple.com/documentation/appkit/images_and_pdf/applying_apple_hdr_effect_to_your_photos
54 bool hasMaker33 = false;
55 bool hasMaker48 = false;
56 float maker33 = 0.f;
57 float maker48 = 0.f;
58 for (uint32_t i = 0; i < ifd->getNumEntries(); ++i) {
59 switch (ifd->getEntryTag(i)) {
60 case 33:
61 if (!hasMaker33) {
62 hasMaker33 = ifd->getEntrySignedRational(i, 1, &maker33);
63 }
64 break;
65 case 48:
66 if (!hasMaker48) {
67 hasMaker48 = ifd->getEntrySignedRational(i, 1, &maker48);
68 }
69 break;
70 default:
71 break;
72 }
73 }
74 if (!hasMaker33 || !hasMaker48) {
75 return false;
76 }
77 float stops = 0.f;
78 if (maker33 < 1.0f) {
79 if (maker48 <= 0.01f) {
80 stops = -20.0f * maker48 + 1.8f;
81 } else {
82 stops = -0.101f * maker48 + 1.601f;
83 }
84 } else {
85 if (maker48 <= 0.01f) {
86 stops = -70.0f * maker48 + 3.0f;
87 } else {
88 stops = -0.303f * maker48 + 2.303f;
89 }
90 }
91 *hdrHeadroom = std::pow(2.f, std::max(stops, 0.f));
92 return true;
93}
static std::unique_ptr< SkTiffImageFileDirectory > MakeFromOffset(sk_sp< SkData > data, bool littleEndian, uint32_t ifdOffset)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

Variable Documentation

◆ kMarkerNoteTag

constexpr uint16_t kMarkerNoteTag = 0x927c
constexpr

Definition at line 22 of file SkExif.cpp.

◆ kOriginTag

constexpr uint16_t kOriginTag = 0x112
constexpr

Definition at line 21 of file SkExif.cpp.

◆ kPixelXDimensionTag

constexpr uint16_t kPixelXDimensionTag = 0xa002
constexpr

Definition at line 30 of file SkExif.cpp.

◆ kPixelYDimensionTag

constexpr uint16_t kPixelYDimensionTag = 0xa003
constexpr

Definition at line 31 of file SkExif.cpp.

◆ kResolutionUnitTag

constexpr uint16_t kResolutionUnitTag = 0x0128
constexpr

Definition at line 27 of file SkExif.cpp.

◆ kSubIFDOffsetTag

constexpr uint16_t kSubIFDOffsetTag = 0x8769
constexpr

Definition at line 20 of file SkExif.cpp.

◆ kXResolutionTag

constexpr uint16_t kXResolutionTag = 0x011a
constexpr

Definition at line 25 of file SkExif.cpp.

◆ kYResolutionTag

constexpr uint16_t kYResolutionTag = 0x011b
constexpr

Definition at line 26 of file SkExif.cpp.