Qt 4.8
Public Functions | Public Variables | List of all members
QtopiaPrintEnginePrivate Class Reference

#include <qprintengine_qws_p.h>

Inheritance diagram for QtopiaPrintEnginePrivate:
QPaintEnginePrivate

Public Functions

void initialize ()
 
QPaintEnginepaintEngine ()
 
 QtopiaPrintEnginePrivate (QPrinter::PrinterMode m)
 
void writeG3BlackRun (int len)
 
void writeG3Code (int code, int bits)
 
void writeG3EOL ()
 
void writeG3FaxHeader ()
 
void writeG3FaxPage ()
 
int writeG3IFDEntry (int tag, int type, int count, int value)
 
void writeG3WhiteRun (int len)
 
 ~QtopiaPrintEnginePrivate ()
 
- Public Functions inherited from QPaintEnginePrivate
void drawBoxTextItem (const QPointF &p, const QTextItemInt &ti)
 
 QPaintEnginePrivate ()
 
void setSystemTransform (const QTransform &xform)
 
void setSystemViewport (const QRegion &region)
 
virtual void systemStateChanged ()
 
void transformSystemClip ()
 
virtual ~QPaintEnginePrivate ()
 

Public Variables

QPaintEngine_paintEngine
 
QtopiaPrintBuffer buffer
 
bool collateCopies
 
QPrinter::ColorMode colorMode
 
QString creator
 
QString docName
 
bool fullPage
 
int ifdPatch
 
QPrinter::PrinterMode mode
 
int numCopies
 
QPrinter::Orientation orientation
 
QString outputFileName
 
bool outputToFile
 
QImagepageImage
 
int pageNumber
 
QPrinter::PageOrder pageOrder
 
QPrinter::PaperSize paperSize
 
QPrinter::PaperSource paperSource
 
int partialBits
 
int partialByte
 
QString printerName
 
QPrinter::PrinterState printerState
 
QString printProgram
 
int resolution
 
- Public Variables inherited from QPaintEnginePrivate
QWidgetcurrentClipWidget
 
uint hasSystemTransform: 1
 
uint hasSystemViewport: 1
 
QPaintDevicepdev
 
QPaintEngineq_ptr
 
QRegion systemClip
 
QRect systemRect
 
QTransform systemTransform
 
QRegion systemViewport
 

Detailed Description

Definition at line 137 of file qprintengine_qws_p.h.

Constructors and Destructors

◆ QtopiaPrintEnginePrivate()

QtopiaPrintEnginePrivate::QtopiaPrintEnginePrivate ( QPrinter::PrinterMode  m)
inline

Definition at line 141 of file qprintengine_qws_p.h.

141  :
142  mode(m),
150  _paintEngine(0),
151  numCopies(1),
152  outputToFile(false),
153  fullPage(false),
154  collateCopies(false),
155  pageNumber(0),
156  pageImage(0),
157  partialByte(0),
158  partialBits(0)
159  {
160  }
#define QT_QWS_PRINTER_DEFAULT_DPI
QPrinter::PaperSize paperSize
QPrinter::Orientation orientation
QPrinter::PaperSource paperSource
QPrinter::ColorMode colorMode
QPrinter::PrinterMode mode
QPrinter::PrinterState printerState
QPrinter::PageOrder pageOrder

◆ ~QtopiaPrintEnginePrivate()

QtopiaPrintEnginePrivate::~QtopiaPrintEnginePrivate ( )

Definition at line 378 of file qprintengine_qws.cpp.

379 {
380  if ( pageImage )
381  delete pageImage;
382 }

Functions

◆ initialize()

void QtopiaPrintEnginePrivate::initialize ( )

Definition at line 384 of file qprintengine_qws.cpp.

385 {
386  _paintEngine = 0;
387 }

◆ paintEngine()

QPaintEngine * QtopiaPrintEnginePrivate::paintEngine ( )

Definition at line 389 of file qprintengine_qws.cpp.

390 {
391  if (!_paintEngine)
393  return _paintEngine;
394 }
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...

◆ writeG3BlackRun()

void QtopiaPrintEnginePrivate::writeG3BlackRun ( int  len)

Definition at line 712 of file qprintengine_qws.cpp.

713 {
714  static struct {
715  unsigned short code;
716  unsigned short bits;
717  } blackCodes[64 + 27] = {
718  {0x0037, 10}, // 0
719  {0x0002, 3},
720  {0x0003, 2},
721  {0x0002, 2},
722  {0x0003, 3},
723  {0x0003, 4},
724  {0x0002, 4},
725  {0x0003, 5},
726  {0x0005, 6}, // 8
727  {0x0004, 6},
728  {0x0004, 7},
729  {0x0005, 7},
730  {0x0007, 7},
731  {0x0004, 8},
732  {0x0007, 8},
733  {0x0018, 9},
734  {0x0017, 10}, // 16
735  {0x0018, 10},
736  {0x0008, 10},
737  {0x0067, 11},
738  {0x0068, 11},
739  {0x006C, 11},
740  {0x0037, 11},
741  {0x0028, 11},
742  {0x0017, 11}, // 24
743  {0x0018, 11},
744  {0x00CA, 12},
745  {0x00CB, 12},
746  {0x00CC, 12},
747  {0x00CD, 12},
748  {0x0068, 12},
749  {0x0069, 12},
750  {0x006A, 12}, // 32
751  {0x006B, 12},
752  {0x00D2, 12},
753  {0x00D3, 12},
754  {0x00D4, 12},
755  {0x00D5, 12},
756  {0x00D6, 12},
757  {0x00D7, 12},
758  {0x006C, 12}, // 40
759  {0x006D, 12},
760  {0x00DA, 12},
761  {0x00DB, 12},
762  {0x0054, 12},
763  {0x0055, 12},
764  {0x0056, 12},
765  {0x0057, 12},
766  {0x0064, 12}, // 48
767  {0x0065, 12},
768  {0x0052, 12},
769  {0x0053, 12},
770  {0x0024, 12},
771  {0x0037, 12},
772  {0x0038, 12},
773  {0x0027, 12},
774  {0x0028, 12}, // 56
775  {0x0058, 12},
776  {0x0059, 12},
777  {0x002B, 12},
778  {0x002C, 12},
779  {0x005A, 12},
780  {0x0066, 12},
781  {0x0067, 12},
782  {0x000F, 10}, // Make up codes: 64
783  {0x00C8, 12}, // 128
784  {0x00C9, 12}, // 192
785  {0x005B, 12}, // 256
786  {0x0033, 12}, // 320
787  {0x0034, 12}, // 384
788  {0x0035, 12}, // 448
789  {0x006C, 13}, // 512
790  {0x006D, 13}, // 576
791  {0x004A, 13}, // 640
792  {0x004B, 13}, // 704
793  {0x004C, 13}, // 768
794  {0x004D, 13}, // 832
795  {0x0072, 13}, // 896
796  {0x0073, 13}, // 960
797  {0x0074, 13}, // 1024
798  {0x0075, 13}, // 1088
799  {0x0076, 13}, // 1152
800  {0x0077, 13}, // 1216
801  {0x0052, 13}, // 1280
802  {0x0053, 13}, // 1344
803  {0x0054, 13}, // 1408
804  {0x0055, 13}, // 1472
805  {0x005A, 13}, // 1536
806  {0x005B, 13}, // 1600
807  {0x0064, 13}, // 1664
808  {0x0065, 13}, // 1728
809  };
810  if ( len >= 64 ) {
811  int index = 63 + (len >> 6);
812  writeG3Code( blackCodes[index].code, blackCodes[index].bits );
813  len &= 63;
814  }
815  writeG3Code( blackCodes[len].code, blackCodes[len].bits );
816 }
quint16 index
void writeG3Code(int code, int bits)

◆ writeG3Code()

void QtopiaPrintEnginePrivate::writeG3Code ( int  code,
int  bits 
)

Definition at line 596 of file qprintengine_qws.cpp.

597 {
598  partialByte = ( ( partialByte << bits ) | code );
599  partialBits += bits;
600  while ( partialBits >= 8 ) {
601  partialBits -= 8;
602  buffer.append( (char)( partialByte >> partialBits ) );
603  }
604 }
void append(char value)

◆ writeG3EOL()

void QtopiaPrintEnginePrivate::writeG3EOL ( )

Definition at line 818 of file qprintengine_qws.cpp.

819 {
820  int bitToPad;
821  if ( partialBits <= 4 ) {
822  bitToPad = 4 - partialBits;
823  } else {
824  bitToPad = 8 - partialBits + 4;
825  }
826 
827  partialByte = ((partialByte << (bitToPad + 12)) | 0x0001);
828  partialBits += bitToPad + 12;
829 
830  while ( partialBits >= 8 ) {
831  partialBits -= 8;
832  buffer.append( (char)(partialByte >> partialBits ) );
833  }
834 // writeG3Code( 0x0001, 12 );
835 }
void append(char value)

◆ writeG3FaxHeader()

void QtopiaPrintEnginePrivate::writeG3FaxHeader ( )

Definition at line 396 of file qprintengine_qws.cpp.

397 {
398  // Write the TIFF file magic number (little-endian TIFF).
399  buffer.append( (char)'I' );
400  buffer.append( (char)'I' );
401  buffer.append( (char)42 );
402  buffer.append( (char)0 );
403 
404  // Leave a place-holder for the IFD offset of the first page.
405  ifdPatch = buffer.size();
406  buffer.append( (int)0 );
407 }
void append(char value)

◆ writeG3FaxPage()

void QtopiaPrintEnginePrivate::writeG3FaxPage ( )

Definition at line 443 of file qprintengine_qws.cpp.

444 {
445  // Pad the image file to a word boundary, just in case.
446  buffer.pad();
447 
448  // Back-patch the IFD link for the previous page.
450 
451  // Output the contents of the IFD for this page (these must be
452  // in ascending order of tag value).
453  buffer.append( (short)19 ); // Number of IFD entries.
462  int stripOffsets =
468  int stripBytes = writeG3IFDEntry
470  int xres =
472  int yres =
478  TIFF_SHORT_PAIR( pageNumber, 0 ) );
480 
481  // Leave a place-holder for the IFD offset of the next page.
482  ifdPatch = buffer.size();
483  buffer.append( (int)0 );
484 
485  // Output the X and Y resolutions, as rational values (usually 200/1).
486  buffer.patch( xres, buffer.size() );
487  buffer.append( (int)resolution );
488  buffer.append( (int)1 );
489  buffer.patch( yres, buffer.size() );
490  buffer.append( (int)resolution );
491  buffer.append( (int)1 );
492 
493  // We are now at the start of the image data - set the strip offset.
494  int start = buffer.size();
495  buffer.patch( stripOffsets, start );
496 
497  // Output the image data.
498  int width = pageImage->width();
499  QImage::Format imageFormat = pageImage->format();
500  for ( int y = 0; y < pageImage->height(); ++y ) {
501  unsigned char *scan = pageImage->scanLine(y);
502  int prev, pixel, len;
503  writeG3EOL();
504  prev = 0;
505  len = 0;
506 
507  uint currentColor = qRgb(255, 255, 255); // start with white
508 
509  for ( int x = 0; x < width && x < TIFF_FAX_WIDTH; ++x ) {
510  if ( imageFormat == QImage::Format_RGB32 ) {
511  // read color of the current pixel
512  uint *p = (uint *)scan + x;
513 
514  if ( *p == currentColor ) { // if it is the same color
515  len++; // imcrement length
516  } else { // otherwise write color into the buffer
517  if ( len > 0 ) {
518  if ( currentColor == qRgb(0, 0, 0) )
519  writeG3BlackRun( len );
520  else
521  writeG3WhiteRun( len );
522  }
523  // initialise length and color;
524  len = 1;
525  currentColor = *p;
526  }
527  } else if ( imageFormat == QImage::Format_Mono ) {
528  pixel = ((scan[x >> 3] & (1 << (x & 7))) != 0);
529  if ( pixel != prev ) {
530  if ( prev ) {
531  writeG3BlackRun( len );
532  } else {
533  writeG3WhiteRun( len );
534  }
535  prev = pixel;
536  len = 1;
537  } else {
538  ++len;
539  }
540  }
541  }
542 
543  if ( imageFormat == QImage::Format_RGB32 ) {
544  // Output the last run on the line, and pad to TIFF_FAX_WIDTH.
545  if ( len != 0 ) {
546  if ( currentColor == qRgb(0, 0, 0) )
547  writeG3BlackRun( len );
548  else
549  writeG3WhiteRun( len );
550  }
551  if ( width < TIFF_FAX_WIDTH )
552  writeG3WhiteRun( TIFF_FAX_WIDTH - width );
553  } else if ( imageFormat == QImage::Format_Mono ) {
554  if ( len != 0 ) {
555  if ( prev ) {
556  writeG3BlackRun( len );
557  if ( width < TIFF_FAX_WIDTH ) {
558  writeG3WhiteRun( TIFF_FAX_WIDTH - width );
559  }
560  } else {
561  if ( width < TIFF_FAX_WIDTH ) {
562  writeG3WhiteRun( len + ( TIFF_FAX_WIDTH - width ) );
563  } else {
564  writeG3WhiteRun( len );
565  }
566  }
567  }
568  }
569  }
570 
571  // Flush the last partial byte, which is padded with zero fill bits.
572  if ( partialBits > 0 ) {
573  buffer.append( (char)( partialByte << ( 8 - partialBits ) ) );
574  partialByte = 0;
575  partialBits = 0;
576  }
577 
578  // end of page add six EOLs
579  for ( int i = 0; i < 6; i++ )
580  writeG3EOL();
581 
582  // Update the byte count for the image data strip.
583  buffer.patch( stripBytes, buffer.size() - start );
584 }
#define TIFF_IFD_T4_OPTIONS
Format
The following image formats are available in Qt.
Definition: qimage.h:91
#define TIFF_FAX_WIDTH
#define TIFF_IFD_PHOTOMETRIC_INTERP
#define TIFF_IFD_X_RESOLUTION
#define TIFF_IFD_COMPRESSION
#define TIFF_IFD_FILL_ORDER
#define TIFF_IFD_PLANAR_CONFIG
#define TIFF_IFD_IMAGE_WIDTH
#define TIFF_TYPE_RATIONAL
#define TIFF_IFD_Y_RESOLUTION
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
#define TIFF_IFD_ROWS_PER_STRIP
#define TIFF_IFD_PAGE_NUMBER
unsigned int uint
Definition: qglobal.h:996
#define TIFF_IFD_SAMPLES_PER_PIXEL
#define TIFF_IFD_NEW_SUB_FILE_TYPE
#define TIFF_IFD_BITS_PER_SAMPLE
void append(char value)
#define TIFF_IFD_CLEAN_FAX_DATA
#define TIFF_IFD_ORIENTATION
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
#define TIFF_TYPE_SHORT
#define TIFF_SHORT_PAIR(a, b)
void patch(int posn, int value)
#define TIFF_IFD_RESOLUTION_UNIT
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
int writeG3IFDEntry(int tag, int type, int count, int value)
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
#define TIFF_IFD_STRIP_BYTE_COUNTS
#define TIFF_IFD_IMAGE_LENGTH
#define TIFF_TYPE_LONG
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
#define TIFF_IFD_STRIP_OFFSETS

◆ writeG3IFDEntry()

int QtopiaPrintEnginePrivate::writeG3IFDEntry ( int  tag,
int  type,
int  count,
int  value 
)

Definition at line 587 of file qprintengine_qws.cpp.

Referenced by writeG3FaxPage().

588 {
589  buffer.append( (short)tag );
590  buffer.append( (short)type );
591  buffer.append( count );
592  buffer.append( value );
593  return buffer.size() - 4; // Offset of the value for back-patching.
594 }
int type
Definition: qmetatype.cpp:239
void append(char value)

◆ writeG3WhiteRun()

void QtopiaPrintEnginePrivate::writeG3WhiteRun ( int  len)

Definition at line 606 of file qprintengine_qws.cpp.

607 {
608  static struct {
609  unsigned short code;
610  unsigned short bits;
611  } whiteCodes[64 + 27] = {
612  {0x0035, 8}, // 0
613  {0x0007, 6},
614  {0x0007, 4},
615  {0x0008, 4},
616  {0x000B, 4},
617  {0x000C, 4},
618  {0x000E, 4},
619  {0x000F, 4},
620  {0x0013, 5}, // 8
621  {0x0014, 5},
622  {0x0007, 5},
623  {0x0008, 5},
624  {0x0008, 6},
625  {0x0003, 6},
626  {0x0034, 6},
627  {0x0035, 6},
628  {0x002A, 6}, // 16
629  {0x002B, 6},
630  {0x0027, 7},
631  {0x000C, 7},
632  {0x0008, 7},
633  {0x0017, 7},
634  {0x0003, 7},
635  {0x0004, 7},
636  {0x0028, 7}, // 24
637  {0x002B, 7},
638  {0x0013, 7},
639  {0x0024, 7},
640  {0x0018, 7},
641  {0x0002, 8},
642  {0x0003, 8},
643  {0x001A, 8},
644  {0x001B, 8}, // 32
645  {0x0012, 8},
646  {0x0013, 8},
647  {0x0014, 8},
648  {0x0015, 8},
649  {0x0016, 8},
650  {0x0017, 8},
651  {0x0028, 8},
652  {0x0029, 8}, // 40
653  {0x002A, 8},
654  {0x002B, 8},
655  {0x002C, 8},
656  {0x002D, 8},
657  {0x0004, 8},
658  {0x0005, 8},
659  {0x000A, 8},
660  {0x000B, 8}, // 48
661  {0x0052, 8},
662  {0x0053, 8},
663  {0x0054, 8},
664  {0x0055, 8},
665  {0x0024, 8},
666  {0x0025, 8},
667  {0x0058, 8},
668  {0x0059, 8}, // 56
669  {0x005A, 8},
670  {0x005B, 8},
671  {0x004A, 8},
672  {0x004B, 8},
673  {0x0032, 8},
674  {0x0033, 8},
675  {0x0034, 8},
676  {0x001B, 5}, // Make up codes: 64
677  {0x0012, 5}, // 128
678  {0x0017, 6}, // 192
679  {0x0037, 7}, // 256
680  {0x0036, 8}, // 320
681  {0x0037, 8}, // 384
682  {0x0064, 8}, // 448
683  {0x0065, 8}, // 512
684  {0x0068, 8}, // 576
685  {0x0067, 8}, // 640
686  {0x00CC, 9}, // 704
687  {0x00CD, 9}, // 768
688  {0x00D2, 9}, // 832
689  {0x00D3, 9}, // 896
690  {0x00D4, 9}, // 960
691  {0x00D5, 9}, // 1024
692  {0x00D6, 9}, // 1088
693  {0x00D7, 9}, // 1152
694  {0x00D8, 9}, // 1216
695  {0x00D9, 9}, // 1280
696  {0x00DA, 9}, // 1344
697  {0x00DB, 9}, // 1408
698  {0x0098, 9}, // 1472
699  {0x0099, 9}, // 1536
700  {0x009A, 9}, // 1600
701  {0x0018, 6}, // 1664
702  {0x009B, 9}, // 1728
703  };
704  if ( len >= 64 ) {
705  int index = 63 + (len >> 6);
706  writeG3Code( whiteCodes[index].code, whiteCodes[index].bits );
707  len &= 63;
708  }
709  writeG3Code( whiteCodes[len].code, whiteCodes[len].bits );
710 }
quint16 index
void writeG3Code(int code, int bits)

Properties

◆ _paintEngine

QPaintEngine* QtopiaPrintEnginePrivate::_paintEngine

Definition at line 183 of file qprintengine_qws_p.h.

◆ buffer

QtopiaPrintBuffer QtopiaPrintEnginePrivate::buffer

Definition at line 194 of file qprintengine_qws_p.h.

◆ collateCopies

bool QtopiaPrintEnginePrivate::collateCopies

Definition at line 188 of file qprintengine_qws_p.h.

◆ colorMode

QPrinter::ColorMode QtopiaPrintEnginePrivate::colorMode

Definition at line 179 of file qprintengine_qws_p.h.

◆ creator

QString QtopiaPrintEnginePrivate::creator

Definition at line 172 of file qprintengine_qws_p.h.

◆ docName

QString QtopiaPrintEnginePrivate::docName

Definition at line 171 of file qprintengine_qws_p.h.

◆ fullPage

bool QtopiaPrintEnginePrivate::fullPage

Definition at line 187 of file qprintengine_qws_p.h.

◆ ifdPatch

int QtopiaPrintEnginePrivate::ifdPatch

Definition at line 197 of file qprintengine_qws_p.h.

◆ mode

QPrinter::PrinterMode QtopiaPrintEnginePrivate::mode

Definition at line 166 of file qprintengine_qws_p.h.

◆ numCopies

int QtopiaPrintEnginePrivate::numCopies

Definition at line 184 of file qprintengine_qws_p.h.

◆ orientation

QPrinter::Orientation QtopiaPrintEnginePrivate::orientation

Definition at line 176 of file qprintengine_qws_p.h.

◆ outputFileName

QString QtopiaPrintEnginePrivate::outputFileName

Definition at line 169 of file qprintengine_qws_p.h.

◆ outputToFile

bool QtopiaPrintEnginePrivate::outputToFile

Definition at line 186 of file qprintengine_qws_p.h.

◆ pageImage

QImage* QtopiaPrintEnginePrivate::pageImage

Definition at line 192 of file qprintengine_qws_p.h.

◆ pageNumber

int QtopiaPrintEnginePrivate::pageNumber

Definition at line 190 of file qprintengine_qws_p.h.

◆ pageOrder

QPrinter::PageOrder QtopiaPrintEnginePrivate::pageOrder

Definition at line 178 of file qprintengine_qws_p.h.

◆ paperSize

QPrinter::PaperSize QtopiaPrintEnginePrivate::paperSize

Definition at line 177 of file qprintengine_qws_p.h.

◆ paperSource

QPrinter::PaperSource QtopiaPrintEnginePrivate::paperSource

Definition at line 180 of file qprintengine_qws_p.h.

◆ partialBits

int QtopiaPrintEnginePrivate::partialBits

Definition at line 199 of file qprintengine_qws_p.h.

◆ partialByte

int QtopiaPrintEnginePrivate::partialByte

Definition at line 198 of file qprintengine_qws_p.h.

◆ printerName

QString QtopiaPrintEnginePrivate::printerName

Definition at line 168 of file qprintengine_qws_p.h.

◆ printerState

QPrinter::PrinterState QtopiaPrintEnginePrivate::printerState

Definition at line 174 of file qprintengine_qws_p.h.

◆ printProgram

QString QtopiaPrintEnginePrivate::printProgram

Definition at line 170 of file qprintengine_qws_p.h.

◆ resolution

int QtopiaPrintEnginePrivate::resolution

Definition at line 182 of file qprintengine_qws_p.h.


The documentation for this class was generated from the following files: