From ef10a585224ced0062a8bdb652eac52cc0231c41 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 6 Jan 2024 23:44:02 -0500 Subject: [PATCH] LibGfx: Remove ExifOrientedBitmap::Orientation in favor of TIFF's enum ExifOrientedBitmap was implemented before the introduction of the TIFF decoder. So we had to provide a definition of the Orientation enum. Now that we have a TIFF implementation that comes with some enum definitions, we should prefer this source. --- .../LibGfx/ImageFormats/ExifOrientedBitmap.h | 22 +++++-------------- .../LibGfx/ImageFormats/JPEGXLLoader.cpp | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h b/Userland/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h index 66722ed1db..9070bebb4c 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h @@ -8,24 +8,13 @@ #include #include +#include namespace Gfx { class ExifOrientedBitmap { public: - // In the EXIF 3.0 specification, 4.6.5.1.6. Orientation - enum class Orientation { - None = 1, - FlipHorizontally = 2, - Rotate180 = 3, - FlipVertically = 4, - Rotate90ClockwiseThenFlipHorizontally = 5, - Rotate90Clockwise = 6, - FlipHorizontallyThenRotate90Clockwise = 7, - Rotate90CounterClockwise = 8, - }; - template - static ErrorOr create(BitmapFormat format, IntSize size, Orientation orientation) + static ErrorOr create(BitmapFormat format, IntSize size, TIFF::Orientation orientation) { auto bitmap = TRY(Bitmap::create(format, oriented_size(size, orientation))); return ExifOrientedBitmap(move(bitmap), size, orientation); @@ -43,6 +32,8 @@ public: } private: + using Orientation = TIFF::Orientation; + ExifOrientedBitmap(NonnullRefPtr bitmap, IntSize size, Orientation orientation) : m_bitmap(move(bitmap)) , m_orientation(orientation) @@ -54,8 +45,7 @@ private: static IntSize oriented_size(IntSize size, Orientation orientation) { switch (orientation) { - - case Orientation::None: + case Orientation::Default: case Orientation::FlipHorizontally: case Orientation::Rotate180: case Orientation::FlipVertically: @@ -80,7 +70,7 @@ private: }; switch (m_orientation) { - case Orientation::None: + case Orientation::Default: return point; case Orientation::FlipHorizontally: return flip_horizontally(point); diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp index 72caef594a..655d464432 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp @@ -1718,7 +1718,7 @@ public: auto const width = m_channels[0].width(); auto const height = m_channels[0].height(); - auto const orientation = static_cast(metadata.orientation); + auto const orientation = static_cast(metadata.orientation); auto oriented_bitmap = TRY(ExifOrientedBitmap::create(BitmapFormat::BGRA8888, { width, height }, orientation)); auto const alpha_channel = metadata.alpha_channel();