SkAnimatedImage: consider exif orientation
Bug: skia:11968
In the simple constructor without an SkImageInfo, cropRect, etc, read
the orientation and swap the width and height if necessary. Although
SkAnimatedImage respects the orientation at decode time, initializing
with backwards width/height results in treating them as a scale.
Change-Id: I0500c3e9a99701c0ec2bba8994c356587a3c876c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406456
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/src/android/SkAnimatedImage.cpp b/src/android/SkAnimatedImage.cpp
index d18cb5f..4c87596 100644
--- a/src/android/SkAnimatedImage.cpp
+++ b/src/android/SkAnimatedImage.cpp
@@ -44,8 +44,12 @@
return nullptr;
}
- const auto& decodeInfo = codec->getInfo();
- const auto cropRect = SkIRect::MakeSize(decodeInfo.dimensions());
+ auto decodeInfo = codec->getInfo();
+ const auto origin = codec->codec()->getOrigin();
+ if (SkEncodedOriginSwapsWidthHeight(origin)) {
+ decodeInfo = decodeInfo.makeWH(decodeInfo.height(), decodeInfo.width());
+ }
+ const auto cropRect = SkIRect::MakeSize(decodeInfo.dimensions());
return Make(std::move(codec), decodeInfo, cropRect, nullptr);
}