michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_IMAGELIB_ORIENTATION_H_ michael@0: #define MOZILLA_IMAGELIB_ORIENTATION_H_ michael@0: michael@0: #include michael@0: #include "mozilla/TypedEnum.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(Angle, uint8_t) michael@0: D0, michael@0: D90, michael@0: D180, michael@0: D270 michael@0: MOZ_END_ENUM_CLASS(Angle) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(Flip, uint8_t) michael@0: Unflipped, michael@0: Horizontal michael@0: MOZ_END_ENUM_CLASS(Flip) michael@0: michael@0: /** michael@0: * A struct that describes an image's orientation as a rotation optionally michael@0: * followed by a reflection. This may be used to be indicate an image's inherent michael@0: * orientation or a desired orientation for the image. michael@0: */ michael@0: struct Orientation michael@0: { michael@0: Orientation(Angle aRotation = Angle::D0, Flip mFlip = Flip::Unflipped) michael@0: : rotation(aRotation) michael@0: , flip(mFlip) michael@0: { } michael@0: michael@0: bool IsIdentity() const { michael@0: return (rotation == Angle::D0) && (flip == Flip::Unflipped); michael@0: } michael@0: michael@0: bool SwapsWidthAndHeight() const { michael@0: return (rotation == Angle::D90) || (rotation == Angle::D270); michael@0: } michael@0: michael@0: bool operator==(const Orientation& aOther) const { michael@0: return (rotation == aOther.rotation) && (flip == aOther.flip); michael@0: } michael@0: michael@0: bool operator!=(const Orientation& aOther) const { michael@0: return !(*this == aOther); michael@0: } michael@0: michael@0: Angle rotation; michael@0: Flip flip; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif