extract in an own static function te calculation of a rotation matrix from both source and destination rotations

svn path=/trunk/KDE/kdegraphics/okular/; revision=708049
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 0d7db7513b
commit 4913076ee9
  1. 41
      core/rotationjob.cpp
  2. 3
      core/rotationjob_p.h

@ -50,39 +50,46 @@ void RotationJob::run()
return;
}
QMatrix matrix = rotationMatrix( mOldRotation, mNewRotation );
mRotatedImage = mImage.transformed( matrix );
}
QMatrix RotationJob::rotationMatrix( Rotation from, Rotation to )
{
QMatrix matrix;
if ( mOldRotation == Rotation0 ) {
if ( mNewRotation == Rotation90 )
if ( from == Rotation0 ) {
if ( to == Rotation90 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation180 )
else if ( to == Rotation180 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation270 )
else if ( to == Rotation270 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation90 ) {
if ( mNewRotation == Rotation180 )
} else if ( from == Rotation90 ) {
if ( to == Rotation180 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation270 )
else if ( to == Rotation270 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation0 )
else if ( to == Rotation0 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation180 ) {
if ( mNewRotation == Rotation270 )
} else if ( from == Rotation180 ) {
if ( to == Rotation270 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation0 )
else if ( to == Rotation0 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation90 )
else if ( to == Rotation90 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation270 ) {
if ( mNewRotation == Rotation0 )
} else if ( from == Rotation270 ) {
if ( to == Rotation0 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation90 )
else if ( to == Rotation90 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation180 )
else if ( to == Rotation180 )
matrix.rotate( 270 );
}
mRotatedImage = mImage.transformed( matrix );
return matrix;
}
#include "rotationjob_p.moc"

@ -11,6 +11,7 @@
#define _OKULAR_ROTATIONJOB_P_H_
#include <QtGui/QImage>
#include <QtGui/QMatrix>
#include <threadweaver/Job.h>
@ -34,6 +35,8 @@ class RotationJob : public ThreadWeaver::Job
int id() const;
PagePrivate * page() const;
static QMatrix rotationMatrix( Rotation from, Rotation to );
protected:
virtual void run();

Loading…
Cancel
Save