1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

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.
This commit is contained in:
Lucas CHOLLET 2024-01-06 23:44:02 -05:00 committed by Andreas Kling
parent e9ebe59081
commit ef10a58522
2 changed files with 7 additions and 17 deletions

View file

@ -8,24 +8,13 @@
#include <AK/NonnullOwnPtr.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageFormats/TIFFMetadata.h>
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<typename... Args>
static ErrorOr<ExifOrientedBitmap> create(BitmapFormat format, IntSize size, Orientation orientation)
static ErrorOr<ExifOrientedBitmap> 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> 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);

View file

@ -1718,7 +1718,7 @@ public:
auto const width = m_channels[0].width();
auto const height = m_channels[0].height();
auto const orientation = static_cast<ExifOrientedBitmap::Orientation>(metadata.orientation);
auto const orientation = static_cast<TIFF::Orientation>(metadata.orientation);
auto oriented_bitmap = TRY(ExifOrientedBitmap::create(BitmapFormat::BGRA8888, { width, height }, orientation));
auto const alpha_channel = metadata.alpha_channel();