ImageOrientation.h [plain text]
#ifndef ImageOrientation_h
#define ImageOrientation_h
namespace WebCore {
class AffineTransform;
class FloatSize;
enum ImageOrientationEnum {
OriginTopLeft = 1, OriginTopRight = 2, OriginBottomRight = 3, OriginBottomLeft = 4, OriginLeftTop = 5, OriginRightTop = 6, OriginRightBottom = 7, OriginLeftBottom = 8, DefaultImageOrientation = OriginTopLeft,
};
enum RespectImageOrientationEnum {
DoNotRespectImageOrientation = 0,
RespectImageOrientation = 1
};
struct ImageOrientationDescription {
ImageOrientationDescription(RespectImageOrientationEnum shouldRespectImageOrientation,
ImageOrientationEnum orientation)
: m_respectOrientation(shouldRespectImageOrientation)
, m_orientation(orientation)
{
}
ImageOrientationDescription()
: m_respectOrientation(DoNotRespectImageOrientation)
, m_orientation(DefaultImageOrientation)
{
}
ImageOrientationDescription(RespectImageOrientationEnum shouldRespectImageOrientation)
: m_respectOrientation(shouldRespectImageOrientation)
, m_orientation(DefaultImageOrientation)
{
}
void setRespectImageOrientation(RespectImageOrientationEnum shouldRespectImageOrientation) { m_respectOrientation = shouldRespectImageOrientation; }
RespectImageOrientationEnum respectImageOrientation() { return m_respectOrientation; }
void setImageOrientationEnum(ImageOrientationEnum orientation) { m_orientation = orientation; }
ImageOrientationEnum imageOrientation() { return m_orientation; }
RespectImageOrientationEnum m_respectOrientation;
ImageOrientationEnum m_orientation;
};
class ImageOrientation {
public:
ImageOrientation()
: m_orientation(DefaultImageOrientation)
{
}
explicit ImageOrientation(ImageOrientationEnum orientation)
: m_orientation(orientation)
{
}
bool usesWidthAsHeight() const
{
return m_orientation >= OriginLeftTop;
}
static ImageOrientation fromEXIFValue(int exifValue)
{
if (exifValue < OriginTopLeft || exifValue > OriginLeftBottom)
return ImageOrientation();
return ImageOrientation(static_cast<ImageOrientationEnum>(exifValue));
}
AffineTransform transformFromDefault(const FloatSize& drawnSize) const;
inline operator ImageOrientationEnum() const { return m_orientation; }
inline bool operator==(const ImageOrientation& other) const { return other.m_orientation == m_orientation; }
inline bool operator!=(const ImageOrientation& other) const { return !(*this == other); }
private:
ImageOrientationEnum m_orientation;
};
}
#endif // ImageOrientation_h