| 1 |
/* |
| 2 |
* Copyright 2018 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 |
#include "src/codec/SkParseEncodedOrigin.h" |
| 9 |
|
| 10 |
#include "include/core/SkData.h" |
| 11 |
#include "include/core/SkRefCnt.h" |
| 12 |
#include "include/private/SkExif.h" |
| 13 |
#include "include/private/base/SkAssert.h" |
| 14 |
|
| 15 |
#include <optional> |
| 16 |
|
| 17 |
bool SkParseEncodedOrigin(const void* data, size_t data_length, SkEncodedOrigin* orientation) { |
| 18 |
SkASSERT(orientation); |
| 19 |
SkExif::Metadata exif; |
| 20 |
SkExif::Parse(exif, SkData::MakeWithoutCopy(data, data_length).get()); |
| 21 |
if (exif.fOrigin.has_value()) { |
| 22 |
*orientation = exif.fOrigin.value(); |
| 23 |
return true; |
| 24 |
} |
| 25 |
return false; |
| 26 |
} |