summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp131
-rw-r--r--noncore/unsupported/qpdf/fixed.h28
-rw-r--r--noncore/unsupported/qpdf/qpdf.pro2
3 files changed, 89 insertions, 72 deletions
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index 02f269d..15a58b1 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -41,22 +41,18 @@
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qclipboard.h> 42#include <qclipboard.h>
43 43
44 //#define QPDFDBG(x) x // special debug mode
45 #define QPDFDBG(x) // normal compilation
46
44 47
45//------------------------------------------------------------------------ 48//------------------------------------------------------------------------
46// Constants and macros 49// Constants and macros
47//------------------------------------------------------------------------ 50//------------------------------------------------------------------------
48 51
49 52
50static inline int q_rnd ( fp_t d )
51{
52 //qDebug ( "Q_RND: %f -> %d\n", (double) d, (int) ( d >= 0 ? d +0.5 : d - 0.5 ));
53
54 return (int) ( d >= 0 ? d + 0.5 : d - 0.5 );
55}
56
57static inline QColor q_col ( const GfxRGB &rgb ) 53static inline QColor q_col ( const GfxRGB &rgb )
58{ 54{
59 return QColor ( q_rnd ( rgb. r * 255 ), q_rnd ( rgb. g * 255 ), q_rnd ( rgb. b * 255 )); 55 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 ));
60} 56}
61 57
62 58
@@ -110,9 +106,9 @@ QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp
110 } 106 }
111 107
112 // compute size and normalized transform matrix 108 // compute size and normalized transform matrix
113 int size = q_rnd ( sqrt ( m21 * m21 + m22 * m22 )); 109 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 ));
114 110
115 /*qDebug ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n", 111 QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n",
116 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ), 112 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ),
117 size, 113 size,
118 gfxFont-> isBold ( ), 114 gfxFont-> isBold ( ),
@@ -122,8 +118,8 @@ QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp
122 gfxFont-> isSymbolic ( ), 118 gfxFont-> isSymbolic ( ),
123 gfxFont-> isCIDFont ( ), 119 gfxFont-> isCIDFont ( ),
124 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ), 120 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ),
125 (double) m11, (double) m12, (double) m21, (double) m22 ); 121 (double) m11, (double) m12, (double) m21, (double) m22 ));
126*/ 122
127 123
128 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ); 124 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" );
129 125
@@ -185,6 +181,8 @@ QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrol
185 m_pixmap = 0; 181 m_pixmap = 0;
186 m_painter = 0; 182 m_painter = 0;
187 183
184 m_use_string = true;
185
188 // create text object 186 // create text object
189 m_text = new TextPage ( gFalse ); 187 m_text = new TextPage ( gFalse );
190} 188}
@@ -202,10 +200,10 @@ void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
202 delete m_pixmap; 200 delete m_pixmap;
203 delete m_painter; 201 delete m_painter;
204 202
205 m_pixmap = new QPixmap ( q_rnd ( state-> getPageWidth ( )), q_rnd ( state-> getPageHeight ( ))); 203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )));
206 m_painter = new QPainter ( m_pixmap ); 204 m_painter = new QPainter ( m_pixmap );
207 205
208 //qDebug ( "NEW PIXMAP (%d x %d)\n", q_rnd ( state-> getPageWidth ( )), q_rnd ( state-> getPageHeight ( ))); 206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))));
209 207
210 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( )); 208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( ));
211 setContentsPos ( 0, 0 ); 209 setContentsPos ( 0, 0 );
@@ -246,7 +244,7 @@ void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
246 244
247void QOutputDev::saveState ( GfxState */*state*/ ) 245void QOutputDev::saveState ( GfxState */*state*/ )
248{ 246{
249 //qDebug ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )); 247 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
250 248
251 m_painter-> save ( ); 249 m_painter-> save ( );
252} 250}
@@ -257,7 +255,7 @@ void QOutputDev::restoreState ( GfxState */*state*/ )
257 255
258 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ))); 256 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( )));
259 //m_painter-> setClipping ( false ); 257 //m_painter-> setClipping ( false );
260 //qDebug ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )); 258 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
261} 259}
262 260
263void QOutputDev::updateAll ( GfxState *state ) 261void QOutputDev::updateAll ( GfxState *state )
@@ -283,7 +281,7 @@ void QOutputDev::updateLineDash ( GfxState *state )
283void QOutputDev::updateFlatness ( GfxState */*state*/ ) 281void QOutputDev::updateFlatness ( GfxState */*state*/ )
284{ 282{
285 // not supported 283 // not supported
286 //qDebug ( "updateFlatness not supported !\n" ); 284 QPDFDBG( printf ( "updateFlatness not supported !\n" ));
287} 285}
288 286
289void QOutputDev::updateLineJoin ( GfxState *state ) 287void QOutputDev::updateLineJoin ( GfxState *state )
@@ -299,7 +297,7 @@ void QOutputDev::updateLineCap ( GfxState *state )
299// unimplemented 297// unimplemented
300void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) 298void QOutputDev::updateMiterLimit ( GfxState */*state*/ )
301{ 299{
302 //qDebug ( "updateMiterLimit not supported !\n" ); 300 QPDFDBG( printf ( "updateMiterLimit not supported !\n" ));
303} 301}
304 302
305void QOutputDev::updateLineWidth ( GfxState *state ) 303void QOutputDev::updateLineWidth ( GfxState *state )
@@ -317,7 +315,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
317 Qt::PenJoinStyle join; 315 Qt::PenJoinStyle join;
318 int width; 316 int width;
319 317
320 width = q_rnd ( state-> getTransformedLineWidth ( )); 318 width = lrint ( state-> getTransformedLineWidth ( ));
321 319
322 switch ( state-> getLineCap ( )) { 320 switch ( state-> getLineCap ( )) {
323 case 0: cap = FlatCap; break; 321 case 0: cap = FlatCap; break;
@@ -409,7 +407,7 @@ void QOutputDev::stroke ( GfxState *state )
409 // transform points 407 // transform points
410 int n = convertPath ( state, points, lengths ); 408 int n = convertPath ( state, points, lengths );
411 409
412 //qDebug ( "DRAWING: %d POLYS\n", n ); 410 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n ));
413 411
414 // draw each subpath 412 // draw each subpath
415 int j = 0; 413 int j = 0;
@@ -417,10 +415,10 @@ void QOutputDev::stroke ( GfxState *state )
417 int len = lengths [i]; 415 int len = lengths [i];
418 416
419 if ( len >= 2 ) { 417 if ( len >= 2 ) {
420 // qDebug ( " - POLY %d: ", i ); 418 QPDFDBG( printf ( " - POLY %d: ", i ));
421 // for ( int ii = 0; ii < len; ii++ ) 419 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
422 // qDebug ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )); 420 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
423 // qDebug ( "\n" ); 421 QPDFDBG( printf ( "\n" ));
424 422
425 m_painter-> drawPolyline ( points, j, len ); 423 m_painter-> drawPolyline ( points, j, len );
426 } 424 }
@@ -456,7 +454,7 @@ void QOutputDev::doFill ( GfxState *state, bool winding )
456 // transform points 454 // transform points
457 int n = convertPath ( state, points, lengths ); 455 int n = convertPath ( state, points, lengths );
458 456
459 //qDebug ( "FILLING: %d POLYS\n", n ); 457 QPDFDBG( printf ( "FILLING: %d POLYS\n", n ));
460 458
461 QPen oldpen = m_painter-> pen ( ); 459 QPen oldpen = m_painter-> pen ( );
462 m_painter-> setPen ( QPen ( NoPen )); 460 m_painter-> setPen ( QPen ( NoPen ));
@@ -467,10 +465,10 @@ void QOutputDev::doFill ( GfxState *state, bool winding )
467 int len = lengths [i]; 465 int len = lengths [i];
468 466
469 if ( len >= 3 ) { 467 if ( len >= 3 ) {
470 // qDebug ( " - POLY %d: ", i ); 468 QPDFDBG( printf ( " - POLY %d: ", i ));
471 // for ( int ii = 0; ii < len; ii++ ) 469 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
472 // qDebug ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )); 470 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
473 // qDebug ( "\n" ); 471 QPDFDBG( printf ( "\n" ));
474 472
475 m_painter-> drawPolygon ( points, winding, j, len ); 473 m_painter-> drawPolygon ( points, winding, j, len );
476 } 474 }
@@ -501,7 +499,7 @@ void QOutputDev::doClip ( GfxState *state, bool winding )
501 499
502 QRegion region; 500 QRegion region;
503 501
504 //qDebug ( "CLIPPING: %d POLYS\n", n ); 502 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n ));
505 503
506 // draw each subpath 504 // draw each subpath
507 int j = 0; 505 int j = 0;
@@ -512,10 +510,9 @@ void QOutputDev::doClip ( GfxState *state, bool winding )
512 QPointArray dummy; 510 QPointArray dummy;
513 dummy. setRawData ( points. data ( ) + j, len ); 511 dummy. setRawData ( points. data ( ) + j, len );
514 512
515 // qDebug ( " - POLY %d: ", i ); 513 QPDFDBG( printf ( " - POLY %d: ", i ));
516 // for ( int ii = 0; ii < len; ii++ ) 514 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
517 // qDebug ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )); 515 QPDFDBG( printf ( "\n" ));
518 // qDebug ( "\n" );
519 516
520 region |= QRegion ( dummy, winding ); 517 region |= QRegion ( dummy, winding );
521 518
@@ -581,8 +578,8 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
581 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 ); 578 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 );
582 579
583 QPointArray tmp; 580 QPointArray tmp;
584 tmp. setPoints ( 4, q_rnd ( x0 ), q_rnd ( y0 ), q_rnd ( x1 ), q_rnd ( y1 ), 581 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ),
585 q_rnd ( x2 ), q_rnd ( y2 ), q_rnd ( x3 ), q_rnd ( y3 )); 582 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 ));
586 583
587#if QT_VERSION < 300 584#if QT_VERSION < 300
588 tmp = tmp. quadBezier ( ); 585 tmp = tmp. quadBezier ( );
@@ -601,7 +598,7 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
601 else { 598 else {
602 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 599 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
603 600
604 points. putPoints ( points. count ( ), 1, q_rnd ( x1 ), q_rnd ( y1 )); 601 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 ));
605 ++i; 602 ++i;
606 } 603 }
607 } 604 }
@@ -625,9 +622,9 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
625{ 622{
626 fp_t x1, y1, dx1, dy1; 623 fp_t x1, y1, dx1, dy1;
627 624
625 if ( uLen > 0 )
628 m_text-> addChar ( state, x, y, dx, dy, u, uLen ); 626 m_text-> addChar ( state, x, y, dx, dy, u, uLen );
629 627
630
631 // check for invisible text -- this is used by Acrobat Capture 628 // check for invisible text -- this is used by Acrobat Capture
632 if (( state-> getRender ( ) & 3 ) == 3 ) { 629 if (( state-> getRender ( ) & 3 ) == 3 ) {
633 return; 630 return;
@@ -651,7 +648,7 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
651 } 648 }
652 else { 649 else {
653 str [i] = ' '; 650 str [i] = ' ';
654 // qDebug ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )); 651 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )));
655 } 652 }
656 } 653 }
657 654
@@ -677,7 +674,7 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
677 674
678 cerr << endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; 675 cerr << endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl;
679 676
680 QWMatrix mat ( q_rnd ( m11 / fsize ), q_rnd ( m12 / fsize ), -q_rnd ( m21 / fsize ), -q_rnd ( m22 / fsize ), q_rnd ( x1 ), q_rnd ( y1 )); 677 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 ));
681 678
682 m_painter-> setWorldMatrix ( mat ); 679 m_painter-> setWorldMatrix ( mat );
683 680
@@ -696,9 +693,9 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
696 } 693 }
697 694
698 if ( fsize > 5 ) 695 if ( fsize > 5 )
699 m_painter-> drawText ( q_rnd ( x1 ), q_rnd ( y1 ), str ); 696 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str );
700 else 697 else
701 m_painter-> fillRect ( q_rnd ( x1 ), q_rnd ( y1 ), q_rnd ( QMAX( fp_t(1), dx1 )), q_rnd ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); 698 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( ));
702 699
703 m_painter-> setPen ( oldpen ); 700 m_painter-> setPen ( oldpen );
704 701
@@ -707,7 +704,7 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
707 m_painter-> setWorldMatrix ( oldmat ); 704 m_painter-> setWorldMatrix ( oldmat );
708 #endif 705 #endif
709 706
710 // qDebug ( "DRAW TEXT: \"%s\" at (%d/%d)\n", str. local8Bit ( ). data ( ), q_rnd ( x1 ), q_rnd ( y1 )); 707 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 )));
711 } 708 }
712 else if ( code != 0 ) { 709 else if ( code != 0 ) {
713 // some PDF files use CID 0, which is .notdef, so just ignore it 710 // some PDF files use CID 0, which is .notdef, so just ignore it
@@ -739,13 +736,13 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
739 736
740 GfxRGB rgb; 737 GfxRGB rgb;
741 state-> getFillRGB ( &rgb ); 738 state-> getFillRGB ( &rgb );
742 uint val = ( q_rnd ( rgb. r * 255 ) & 0xff ) << 16 | ( q_rnd ( rgb. g * 255 ) & 0xff ) << 8 | ( q_rnd ( rgb. b * 255 ) & 0xff ); 739 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
743 740
744 741
745 QImage img ( width, height, 32 ); 742 QImage img ( width, height, 32 );
746 img. setAlphaBuffer ( true ); 743 img. setAlphaBuffer ( true );
747 744
748 //qDebug ( "IMAGE MASK (%dx%d)\n", width, height ); 745 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height ));
749 746
750 // initialize the image stream 747 // initialize the image stream
751 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); 748 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 );
@@ -800,14 +797,14 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
800 797
801#else 798#else
802 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 799 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
803 qDebug ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ); 800 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
804 } 801 }
805 else { 802 else {
806 int x = q_rnd ( ctm [4] ); 803 int x = lrint ( ctm [4] );
807 int y = q_rnd ( ctm [5] ); 804 int y = lrint ( ctm [5] );
808 805
809 int w = q_rnd ( ctm [0] ); 806 int w = lrint ( ctm [0] );
810 int h = q_rnd ( ctm [3] ); 807 int h = lrint ( ctm [3] );
811 808
812 if ( w < 0 ) { 809 if ( w < 0 ) {
813 x += w; 810 x += w;
@@ -818,7 +815,7 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
818 h = -h; 815 h = -h;
819 } 816 }
820 817
821 // qDebug ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ); 818 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ));
822 819
823 img = img. smoothScale ( w, h ); 820 img = img. smoothScale ( w, h );
824 qApp-> processEvents ( ); 821 qApp-> processEvents ( );
@@ -863,7 +860,7 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
863 if ( maskColors ) 860 if ( maskColors )
864 img. setAlphaBuffer ( true ); 861 img. setAlphaBuffer ( true );
865 862
866 //qDebug ( "IMAGE (%dx%d)\n", width, height ); 863 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height ));
867 864
868 // initialize the image stream 865 // initialize the image stream
869 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); 866 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits );
@@ -888,7 +885,7 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
888 imgStr-> getPixel ( pixBuf ); 885 imgStr-> getPixel ( pixBuf );
889 colorMap-> getRGB ( pixBuf, &rgb ); 886 colorMap-> getRGB ( pixBuf, &rgb );
890 887
891 uint val = ( q_rnd ( rgb. r * 255 ) & 0xff ) << 16 | ( q_rnd ( rgb. g * 255 ) & 0xff ) << 8 | ( q_rnd ( rgb. b * 255 ) & 0xff ); 888 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
892 889
893 if ( maskColors ) { 890 if ( maskColors ) {
894 for ( int k = 0; k < nComps; ++k ) { 891 for ( int k = 0; k < nComps; ++k ) {
@@ -930,14 +927,14 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
930#else // QT_NO_TRANSFORMATIONS 927#else // QT_NO_TRANSFORMATIONS
931 928
932 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 929 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
933 qDebug ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ); 930 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
934 } 931 }
935 else { 932 else {
936 int x = q_rnd ( ctm [4] ); 933 int x = lrint ( ctm [4] );
937 int y = q_rnd ( ctm [5] ); 934 int y = lrint ( ctm [5] );
938 935
939 int w = q_rnd ( ctm [0] ); 936 int w = lrint ( ctm [0] );
940 int h = q_rnd ( ctm [3] ); 937 int h = lrint ( ctm [3] );
941 938
942 if ( w < 0 ) { 939 if ( w < 0 ) {
943 x += w; 940 x += w;
@@ -948,7 +945,7 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
948 h = -h; 945 h = -h;
949 } 946 }
950 947
951 // qDebug ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ); 948 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ));
952 949
953 img = img. smoothScale ( w, h ); 950 img = img. smoothScale ( w, h );
954 qApp-> processEvents ( ); 951 qApp-> processEvents ( );
@@ -990,10 +987,10 @@ bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h,
990 fp_t y2 = (fp_t) t + h - 1; 987 fp_t y2 = (fp_t) t + h - 1;
991 988
992 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) { 989 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) {
993 l = q_rnd ( x1 ); 990 l = lrint ( x1 );
994 t = q_rnd ( y1 ); 991 t = lrint ( y1 );
995 w = q_rnd ( x2 ) - l + 1; 992 w = lrint ( x2 ) - l + 1;
996 h = q_rnd ( y2 ) - t + 1; 993 h = lrint ( y2 ) - t + 1;
997 found = true; 994 found = true;
998 } 995 }
999 delete [] s; 996 delete [] s;
@@ -1010,10 +1007,10 @@ GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *
1010 fp_t yMax1 = (double) *yMax; 1007 fp_t yMax1 = (double) *yMax;
1011 1008
1012 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) { 1009 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) {
1013 *xMin = q_rnd ( xMin1 ); 1010 *xMin = lrint ( xMin1 );
1014 *xMax = q_rnd ( xMax1 ); 1011 *xMax = lrint ( xMax1 );
1015 *yMin = q_rnd ( yMin1 ); 1012 *yMin = lrint ( yMin1 );
1016 *yMax = q_rnd ( yMax1 ); 1013 *yMax = lrint ( yMax1 );
1017 found = true; 1014 found = true;
1018 } 1015 }
1019 return found; 1016 return found;
diff --git a/noncore/unsupported/qpdf/fixed.h b/noncore/unsupported/qpdf/fixed.h
index 111b95e..c912954 100644
--- a/noncore/unsupported/qpdf/fixed.h
+++ b/noncore/unsupported/qpdf/fixed.h
@@ -120,6 +120,10 @@ private:
120 friend bool operator >= <> ( int i, const fixed &f ); 120 friend bool operator >= <> ( int i, const fixed &f );
121 friend bool operator == <> ( int i, const fixed &f ); 121 friend bool operator == <> ( int i, const fixed &f );
122 friend bool operator != <> ( int i, const fixed &f ); 122 friend bool operator != <> ( int i, const fixed &f );
123
124 friend long int lrint ( const fixed &f );
125 friend fixed sqrt ( const fixed &f );
126 friend fixed fabs ( const fixed &f );
123#endif 127#endif
124}; 128};
125 129
@@ -149,15 +153,31 @@ template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f )
149template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; } 153template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; }
150template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; } 154template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; }
151 155
152 156template <unsigned int SH> inline long int lrint ( const fixed<SH> &f )
153template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f )
154{ 157{
155 return fixed<SH> ( double( sqrt ( double( f )))); 158 return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 )));
156} 159}
157 160
158template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f ) 161template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f )
159{ 162{
160 return ( f < 0 ) ? -f : f; 163 return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f;
164}
165
166// roughly from QPE / qmath.h
167template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f )
168{
169 if ( f. m_f <= 0 )
170 return fixed<SH> ( 0, true );
171
172 fixed<SH>::fix_t a0 = 0;
173 fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation
174
175 do {
176 a0 = a1;
177 a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1;
178 } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 );
179
180 return fixed<SH> ( a1, true );
161} 181}
162 182
163template <unsigned int SH> inline ostream &operator << ( ostream &o, const fixed<SH> &f ) 183template <unsigned int SH> inline ostream &operator << ( ostream &o, const fixed<SH> &f )
diff --git a/noncore/unsupported/qpdf/qpdf.pro b/noncore/unsupported/qpdf/qpdf.pro
index 6ba4f49..0c2e38b 100644
--- a/noncore/unsupported/qpdf/qpdf.pro
+++ b/noncore/unsupported/qpdf/qpdf.pro
@@ -52,7 +52,7 @@ INCLUDEPATH += . \
52 ../goo \ 52 ../goo \
53 goo 53 goo
54 54
55LIBS += -L $(OPIEDIR)/lib -lqpe -lstdc++ 55LIBS += -L $(OPIEDIR)/lib -lqpe
56 56
57DESTDIR = $(OPIEDIR)/bin 57DESTDIR = $(OPIEDIR)/bin
58TARGET = qpdf 58TARGET = qpdf