• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "include/codec/SkEncodedOrigin.h"
12 #include "include/private/base/SkAPI.h"
13 
14 #include <cstdint>
15 #include <optional>
16 
17 class SkData;
18 
19 namespace SkExif {
20 
21 // Tag values that are parsed by Parse and stored in Metadata.
22 static constexpr uint16_t kOriginTag = 0x112;
23 static constexpr uint16_t kResolutionUnitTag = 0x0128;
24 static constexpr uint16_t kXResolutionTag = 0x011a;
25 static constexpr uint16_t kYResolutionTag = 0x011b;
26 static constexpr uint16_t kPixelXDimensionTag = 0xa002;
27 static constexpr uint16_t kPixelYDimensionTag = 0xa003;
28 
29 struct Metadata {
30     // The image orientation.
31     std::optional<SkEncodedOrigin> fOrigin;
32 
33     // The HDR headroom property.
34     // https://developer.apple.com/documentation/appkit/images_and_pdf/applying_apple_hdr_effect_to_your_photos
35     std::optional<float> fHdrHeadroom;
36 
37     // Resolution.
38     std::optional<uint16_t> fResolutionUnit;
39     std::optional<float> fXResolution;
40     std::optional<float> fYResolution;
41 
42     // Size in pixels.
43     std::optional<uint32_t> fPixelXDimension;
44     std::optional<uint32_t> fPixelYDimension;
45 };
46 
47 /*
48  * Parse the metadata specified in |data| and write them to |metadata|. Stop only at an
49  * unrecoverable error (allow truncated input).
50  */
51 void SK_API Parse(Metadata& metadata, const SkData* data);
52 
53 }  // namespace SkExif
54 
55 #endif
56