Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkExif.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkExif_DEFINED
9#define SkExif_DEFINED
10
12#include "include/core/SkData.h"
15
16#include <cstdint>
17
19public:
20 /*
21 * Parse the metadata specified in |data|.
22 */
23 SkExifMetadata(const sk_sp<SkData> data);
24
25 /*
26 * If the image encoded origin is specified, populate |out| and return true. Otherwise return
27 * false.
28 */
29 bool getOrigin(SkEncodedOrigin* out) const {
30 if (fOriginPresent && out) *out = fOriginValue;
31 return fOriginPresent;
32 }
33
34 /*
35 * If the HDR headroom is specified, populate |out| and return true. Otherwise return false.
36 */
37 bool getHdrHeadroom(float* out) const {
38 if (fHdrHeadroomPresent && out) *out = fHdrHeadroomValue;
39 return fHdrHeadroomPresent;
40 }
41
42 /*
43 * If resolution unit, x, or y is specified, populate |out| and return true. Otherwise return
44 * false.
45 */
46 bool getResolutionUnit(uint16_t* out) const {
47 if (fResolutionUnitPresent && out) *out = fResolutionUnitValue;
48 return fResolutionUnitPresent;
49 }
50 bool getXResolution(float* out) const {
51 if (fXResolutionPresent && out) *out = fXResolutionValue;
52 return fXResolutionPresent;
53 }
54 bool getYResolution(float* out) const {
55 if (fYResolutionPresent && out) *out = fYResolutionValue;
56 return fYResolutionPresent;
57 }
58
59 /*
60 * If pixel dimension x or y is specified, populate |out| and return true. Otherwise return
61 * false.
62 */
63 bool getPixelXDimension(uint32_t* out) const {
64 if (fPixelXDimensionPresent && out) *out = fPixelXDimensionValue;
65 return fPixelXDimensionPresent;
66 }
67 bool getPixelYDimension(uint32_t* out) const {
68 if (fPixelYDimensionPresent && out) *out = fPixelYDimensionValue;
69 return fPixelYDimensionPresent;
70 }
71
72private:
73 // Helper functions and constants for parsing the data.
74 void parseIfd(uint32_t ifdOffset, bool littleEndian, bool isRoot);
75
76 // The input data.
77 const sk_sp<SkData> fData;
78
79 // The origin property.
80 bool fOriginPresent = false;
82
83 // The HDR headroom property.
84 bool fHdrHeadroomPresent = false;
85 float fHdrHeadroomValue = 1.f;
86
87 // Resolution.
88 bool fResolutionUnitPresent = false;
89 uint16_t fResolutionUnitValue = 0;
90 bool fXResolutionPresent = false;
91 float fXResolutionValue = 0;
92 bool fYResolutionPresent = false;
93 float fYResolutionValue = 0;
94
95 // Size in pixels.
96 bool fPixelXDimensionPresent = false;
97 uint32_t fPixelXDimensionValue = 0;
98 bool fPixelYDimensionPresent = false;
99 uint32_t fPixelYDimensionValue = 0;
100};
101
102#endif
#define SK_API
Definition SkAPI.h:35
SkEncodedOrigin
@ kTopLeft_SkEncodedOrigin
bool getPixelYDimension(uint32_t *out) const
Definition SkExif.h:67
bool getResolutionUnit(uint16_t *out) const
Definition SkExif.h:46
bool getHdrHeadroom(float *out) const
Definition SkExif.h:37
bool getYResolution(float *out) const
Definition SkExif.h:54
bool getXResolution(float *out) const
Definition SkExif.h:50
bool getPixelXDimension(uint32_t *out) const
Definition SkExif.h:63
bool getOrigin(SkEncodedOrigin *out) const
Definition SkExif.h:29