1 /***************************************************************************
2 * Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "rotationjob_p.h"
12 #include <QtGui/QMatrix>
14 using namespace Okular
;
16 RotationJob::RotationJob( const QImage
&image
, Rotation oldRotation
, Rotation newRotation
, int id
)
17 : mImage( image
), mOldRotation( oldRotation
), mNewRotation( newRotation
), mId( id
), m_pd( 0 )
21 void RotationJob::setPage( PagePrivate
* pd
)
26 QImage
RotationJob::image() const
31 Rotation
RotationJob::rotation() const
36 int RotationJob::id() const
41 PagePrivate
* RotationJob::page() const
46 void RotationJob::run()
48 if ( mOldRotation
== mNewRotation
) {
49 mRotatedImage
= mImage
;
53 QMatrix matrix
= rotationMatrix( mOldRotation
, mNewRotation
);
55 mRotatedImage
= mImage
.transformed( matrix
);
58 QMatrix
RotationJob::rotationMatrix( Rotation from
, Rotation to
)
62 if ( from
== Rotation0
) {
63 if ( to
== Rotation90
)
65 else if ( to
== Rotation180
)
67 else if ( to
== Rotation270
)
69 } else if ( from
== Rotation90
) {
70 if ( to
== Rotation180
)
72 else if ( to
== Rotation270
)
74 else if ( to
== Rotation0
)
76 } else if ( from
== Rotation180
) {
77 if ( to
== Rotation270
)
79 else if ( to
== Rotation0
)
81 else if ( to
== Rotation90
)
83 } else if ( from
== Rotation270
) {
84 if ( to
== Rotation0
)
86 else if ( to
== Rotation90
)
88 else if ( to
== Rotation180
)
95 #include "rotationjob_p.moc"