MythTV  master
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Orientation Class Reference

Encapsulates Exif orientation processing. More...

#include <libmythmetadata/imagemetadata.h>

Collaboration diagram for Orientation:
[legend]

Public Member Functions

 Orientation (int composite)
 
 Orientation (int current, int file)
 
int Composite () const
 Encode original & current orientation to a single Db field. More...
 
int Transform (int transform)
 Adjust orientation to apply a transform to an image. More...
 
int GetCurrent (bool compensate)
 Determines orientation required for an image. More...
 
QString Description () const
 Generate text description of orientation. More...
 

Static Public Member Functions

static int FromRotation (const QString &degrees)
 Convert degrees of rotation into Exif orientation code. More...
 

Private Types

using Matrix = QHash< int, QHash< int, int > >
 

Private Member Functions

int Apply (int transform) const
 Adjust current orientation code to apply a transform to an image. More...
 

Static Private Member Functions

static QString AsText (int orientation)
 Converts orientation code to text description for info display. More...
 
static Matrix InitOrientationMatrix ()
 Initialises conversion matrix for Qt 5.4.1. More...
 

Private Attributes

int m_current
 The orientation to use: the file orientation with user transformations applied. More...
 
int m_file
 The orientation of the raw file image, as specified by the camera. More...
 

Static Private Attributes

static const bool krunningQt541 = (strcmp(qVersion(), "5.4.1") == 0)
 True when using Qt 5.4.1 with its deviant orientation behaviour. More...
 
static const Matrix kQt541_orientation
 Orientation conversions for proper display on Qt 5.4.1. More...
 

Detailed Description

Encapsulates Exif orientation processing.

The exif code indicates how the raw image should be rotated/mirrored in order to display correctly. This manipulation is expensive, so done once only. User transformations are applied to the code to achieve the required effect. Both file orientation and current orientation are stored in the Db (together) to cope with deviant Qt versions. This composite code is 2-digits where 1st = current orientation, 2nd = original file orientation

Definition at line 62 of file imagemetadata.h.

Member Typedef Documentation

◆ Matrix

using Orientation::Matrix = QHash<int, QHash<int, int> >
private

Definition at line 83 of file imagemetadata.h.

Constructor & Destructor Documentation

◆ Orientation() [1/2]

Orientation::Orientation ( int  composite)
inlineexplicit

Definition at line 66 of file imagemetadata.h.

◆ Orientation() [2/2]

Orientation::Orientation ( int  current,
int  file 
)
inline

Definition at line 68 of file imagemetadata.h.

Member Function Documentation

◆ Composite()

int Orientation::Composite ( ) const
inline

Encode original & current orientation to a single Db field.

Definition at line 71 of file imagemetadata.h.

Referenced by ImageScanThread< ImageDbSg >::SyncFile(), and Transform().

◆ Transform()

int Orientation::Transform ( int  transform)

Adjust orientation to apply a transform to an image.

Parameters
transformRotation/flip/reset to apply
Returns
int Adjusted composite orientation of the image

Definition at line 26 of file imagemetadata.cpp.

Referenced by ImageHandler< ImageDbSg >::HandleTransform().

◆ GetCurrent()

int Orientation::GetCurrent ( bool  compensate)

Determines orientation required for an image.

Some Qt versions automatically apply file orientation when an image is loaded. This compensates for that to ensure images are always orientated correctly.

Parameters
compensateWhether to compensate for Qt auto-rotation
Returns
Exif orientation code to apply after the image has been loaded.

Definition at line 83 of file imagemetadata.cpp.

Referenced by ThumbThread< ImageDbSg >::CreateThumbnail(), Slide::LoadSlide(), and ImageScanThread< ImageDbSg >::SyncFile().

◆ Description()

QString Orientation::Description ( ) const

Generate text description of orientation.

Reports code & its interpretation of file orientation and, if different, the Db orientation

Returns
Text description of orientation

Definition at line 226 of file imagemetadata.cpp.

Referenced by ReadMetaThread::run().

◆ FromRotation()

int Orientation::FromRotation ( const QString &  degrees)
static

Convert degrees of rotation into Exif orientation code.

Parameters
degreesCW rotation required to show video correctly
Returns
QString Orientation code as per Exif spec.

Definition at line 210 of file imagemetadata.cpp.

Referenced by VideoMetaData::GetOrientation().

◆ AsText()

QString Orientation::AsText ( int  orientation)
staticprivate

Converts orientation code to text description for info display.

Parameters
orientationExif code
Returns
QString Description text

Definition at line 240 of file imagemetadata.cpp.

Referenced by Description().

◆ Apply()

int Orientation::Apply ( int  transform) const
private

Adjust current orientation code to apply a transform to an image.

When displayed the image will be orientated iaw its orientation code. The transform is effected by applying the reverse transform to the orientation code.

See also
http://jpegclub.org/exif_orientation.html
Parameters
transformRotation/flip to apply
Returns
int New orientation code that will apply the transform to the image

Definition at line 112 of file imagemetadata.cpp.

Referenced by Transform().

◆ InitOrientationMatrix()

Orientation::Matrix Orientation::InitOrientationMatrix ( )
staticprivate

Initialises conversion matrix for Qt 5.4.1.

Returns
Matrix of orientation codes such that: Qt 5.4.1 orientation = matrix(file orientation, current orientation)

Definition at line 38 of file imagemetadata.cpp.

Member Data Documentation

◆ krunningQt541

const bool Orientation::krunningQt541 = (strcmp(qVersion(), "5.4.1") == 0)
staticprivate

True when using Qt 5.4.1 with its deviant orientation behaviour.

Definition at line 86 of file imagemetadata.h.

Referenced by GetCurrent(), and InitOrientationMatrix().

◆ kQt541_orientation

const Orientation::Matrix Orientation::kQt541_orientation
staticprivate
Initial value:

Orientation conversions for proper display on Qt 5.4.1.

Definition at line 88 of file imagemetadata.h.

Referenced by GetCurrent().

◆ m_current

int Orientation::m_current
private

The orientation to use: the file orientation with user transformations applied.

Definition at line 92 of file imagemetadata.h.

Referenced by Apply(), Description(), GetCurrent(), and Transform().

◆ m_file

int Orientation::m_file
private

The orientation of the raw file image, as specified by the camera.

Definition at line 94 of file imagemetadata.h.

Referenced by Apply(), Description(), and GetCurrent().


The documentation for this class was generated from the following files:
Orientation::InitOrientationMatrix
static Matrix InitOrientationMatrix()
Initialises conversion matrix for Qt 5.4.1.
Definition: imagemetadata.cpp:38