Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Andi Sardina Ramos
Okular
Commits
70423d2f
Commit
70423d2f
authored
Jun 25, 2006
by
Pino Toscano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be able to rotate fax documents.
svn path=/trunk/playground/graphics/okular/; revision=554987
parent
dba40494
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
26 deletions
+46
-26
generators/fax/faxrenderer.cpp
generators/fax/faxrenderer.cpp
+40
-26
generators/fax/faxrenderer.h
generators/fax/faxrenderer.h
+6
-0
No files found.
generators/fax/faxrenderer.cpp
View file @
70423d2f
...
...
@@ -18,12 +18,11 @@
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <kmessagebox.h>
#include <kdebug.h>
#include <kimageeffect.h>
#include <klocale.h>
#include <qfileinfo.h>
#include <qpainter.h>
#include <qpaintdevice.h>
#include <qpixmap.h>
#include <QX11Info>
#include "faxrenderer.h"
...
...
@@ -50,12 +49,12 @@ void FaxRenderer::generatePixmap( PixmapRequest * request )
<<
endl
;
// Wait for all access to this documentRenderer to finish
QPixmap
*
pix
=
new
QPixmap
(
request
->
width
,
request
->
height
);
pix
->
fill
();
QPainter
p
(
pix
);
QImage
img
=
fax
.
page
(
request
->
pageNumber
).
scaled
(
request
->
width
,
request
->
height
,
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
);
p
.
drawImage
(
0
,
0
,
img
,
0
,
0
,
img
.
width
(),
img
.
height
());
int
rotation
=
request
->
documentRotation
;
if
(
rotation
>
0
)
img
=
KImageEffect
::
rotate
(
img
,
(
KImageEffect
::
RotateDirection
)(
rotation
-
1
)
);
QPixmap
*
pix
=
new
QPixmap
();
*
pix
=
QPixmap
::
fromImage
(
img
);
/*
SimplePageSize psize = pageSizes[page->getPageNumber() - 1];
if (psize.isValid()) {
...
...
@@ -126,30 +125,45 @@ bool FaxRenderer::loadDocument( const QString & fileName, QVector< KPDFPage * >
return
false
;
}
loadPages
(
pagesVector
,
0
);
// the return value 'true' indicates that this operation was not successful.
// mutex.unlock();
return
true
;
}
void
FaxRenderer
::
setOrientation
(
QVector
<
KPDFPage
*>
&
pagesVector
,
int
orientation
)
{
loadPages
(
pagesVector
,
orientation
);
}
void
FaxRenderer
::
loadPages
(
QVector
<
KPDFPage
*>
&
pagesVector
,
int
rotation
)
{
// Set the number of pages page sizes
quint16
pages
=
fax
.
numPages
();
pagesVector
.
resize
(
pages
);
for
(
quint16
pg
=
0
;
pg
<
pages
;
pg
++
)
for
(
quint16
pg
=
0
;
pg
<
pages
;
++
pg
)
{
QSize
pageSize
=
fax
.
page_size
(
pg
);
QPoint
dpi
=
fax
.
page_dpi
(
pg
);
double
dpix
=
dpi
.
x
();
double
dpiy
=
dpi
.
y
();
if
(
dpix
*
dpiy
<
1.0
)
{
QSize
pageSize
=
fax
.
page_size
(
pg
);
// how about rotation?
QPoint
dpi
=
fax
.
page_dpi
(
pg
);
double
dpix
=
dpi
.
x
();
double
dpiy
=
dpi
.
y
();
if
(
dpix
*
dpiy
<
1.0
)
{
kError
()
<<
"File invalid resolutions, dpi x = "
<<
dpix
<<
", dpi y = "
<<
dpiy
<<
". This information will be ignored and 75 DPI assumed."
<<
endl
;
dpix
=
dpiy
=
75.0
;
}
pagesVector
[
pg
]
=
new
KPDFPage
(
pg
,
QX11Info
::
appDpiX
()
*
pageSize
.
width
()
/
dpix
,
QX11Info
::
appDpiY
()
*
pageSize
.
height
()
/
dpiy
,
0
);
}
kError
()
<<
"File invalid resolutions, dpi x = "
<<
dpix
<<
", dpi y = "
<<
dpiy
<<
". This information will be ignored and 75 DPI assumed."
<<
endl
;
dpix
=
dpiy
=
75.0
;
}
int
width
=
QX11Info
::
appDpiX
()
*
pageSize
.
width
()
/
dpix
;
int
height
=
QX11Info
::
appDpiY
()
*
pageSize
.
height
()
/
dpiy
;
if
(
rotation
%
2
==
1
)
qSwap
(
width
,
height
);
// the return value 'true' indicates that this operation was not successful.
//
mutex.unlock(
);
return
true
;
delete
pagesVector
[
pg
];
pagesVector
[
pg
]
=
new
KPDFPage
(
pg
,
width
,
height
,
rotation
);
}
}
...
...
generators/fax/faxrenderer.h
View file @
70423d2f
...
...
@@ -78,7 +78,13 @@ public:
void
generatePixmap
(
PixmapRequest
*
request
);
bool
canGeneratePixmap
(
bool
async
)
{
return
!
mutex
.
locked
();
};
// rotation
bool
supportsRotation
()
{
return
true
;
};
void
setOrientation
(
QVector
<
KPDFPage
*>
&
pagesVector
,
int
orientation
);
private:
void
loadPages
(
QVector
<
KPDFPage
*>
&
pagesVector
,
int
rotation
);
/** This class holds the fax file */
KFaxImage
fax
;
QMutex
mutex
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment