FaxFile.h
上传用户:glass0516
上传日期:2010-01-11
资源大小:104k
文件大小:4k
源码类别:

传真(Fax)编程

开发平台:

Visual C++

  1. /*****************************************************************************
  2. * RelayFax Open Source Project
  3. * Copyright 1996-2004 Alt-N Technologies, Ltd.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted only as authorized by the RelayFax Open 
  8. * Source License.  A copy of this license is available in file LICENSE 
  9. * in the top-level directory of the distribution.
  10. *
  11. * RelayFax is a registered trademark of Alt-N Technologies, Ltd.
  12. *
  13. * Individual files and/or contributed packages may be copyright by
  14. * other parties and subject to additional restrictions.
  15. *****************************************************************************/
  16. #ifndef FAXFILE_H 
  17. #define FAXFILE_H
  18. #include "CommPort.h"
  19. #include "ECMBuffer.h"
  20. #include "tiffio.h"
  21. #include "memfile.h"
  22. class CFaxFile  
  23. {
  24. public:
  25. CFaxFile();
  26. virtual ~CFaxFile();
  27. void SetFileName( LPCSTR szFilename ) { m_sFaxFile.assign( szFilename ); };
  28. void SelectEncoding( int nEncoding );
  29. int ReadFirstHeader(void);
  30. bool ReadPage( bool bUseECM, int nClass1Speed, WORD wMinLineChars, bool bClassTwoZero = false, bool bClassTwo = false );
  31. bool ReadNextHeader(void);
  32. bool ReadBadFrames( int nClass1Speed );
  33. void Close(void);
  34. void SetImageRes( bool bHiRes );
  35. void SetImageWidth( int nWidth );
  36. void SetImageLength( int nLength );
  37. void IncrementImageLength( int n = 1 );
  38. void SetImageCompression( int nCompression );
  39. void SetT4Options( int nOptions );
  40. void SetECMFrameSize( int nSize ) { m_nECMFrameSize = nSize; }
  41. void IncrementPageCount(void) { m_PageCount++; };
  42. bool WriteFileHeader(void);
  43. bool WriteBuffer( unsigned char* szBuffer, unsigned int nBytes, bool bFlipBytes = true );
  44. bool WriteECMBuffer( unsigned char* szBuffer, unsigned int nBytes );
  45. bool WriteIFD(void);
  46. int WriteIfd (void);
  47. bool IsECMBlockGood( int nFrameCount ) { return m_ECMBuffer.IsECMBlockGood(nFrameCount); };
  48. void NextECMBlock(void);
  49. void RedoECMBlock(void);
  50. void AddFCDHeader(void);
  51. void AddRCPFrames(void);
  52. void AddByte( unsigned char b, bool bCalcFCS );
  53. void AddBit( unsigned char bit );
  54. void AddFlag( void );
  55. void Clear(void);
  56. unsigned char* GetSeqMap(void) { return m_ECMBuffer.GetSeqMap(); };
  57. char* GetPageData( void ) { return (char*)m_PageBuffer; };
  58. unsigned int GetPageBytes(void) { return m_PageBufferSize; };
  59. unsigned int GetPageCount(void) { return m_PageCount; };
  60. bool GetPartialPage(void) { return m_bPartialPage; };
  61. unsigned int GetFrameCount(void) { return m_ECMBuffer.GetHighestSeq(); };
  62. unsigned int GetBlockCount(void) { return m_nBlockCount; };
  63. int GetSendEncoding(void) { return m_nSendEncoding; };
  64. void SetSendEncoding( int nEnc ) { m_nSendEncoding = nEnc; };
  65. bool MorePages(void) { return TIFFLastDirectory( m_tiff ) == 0; };
  66. unsigned int GetTotalPageSize( void ) { return m_MemFile.GetDataLen(); };
  67. int GetECMFrameSize( void ) { return m_nECMFrameSize; }
  68. bool IsHiRes(void);
  69. static BYTE s_LeadZero[256];
  70. static BYTE s_TrailZero[256];
  71. static unsigned char s_FlipTable[];
  72. protected:
  73. static const int s_WTree [][2];
  74. static const int s_BTree [][2];
  75. static const int s_TwoTree [][2];
  76. string m_sFaxFile;
  77. uint16 bitspersample;
  78. uint32 width, length, rowsperstrip;
  79. uint16 fillorder;
  80. uint32 g3opts;
  81. uint16 compression;
  82. float xres, yres;
  83. unsigned char* m_PageBuffer;
  84. unsigned char* m_PagePtr;
  85. unsigned int m_PageBufferSize;
  86. unsigned int m_PageCount;
  87. TIFF* m_tiff;
  88. unsigned long int lastifd;
  89. bool m_bFoundStartOfPage;
  90. bool m_bFoundStartOfFrame;
  91. bool m_bFoundEndOfPage;
  92. unsigned long nZcnt;
  93. unsigned long nRTCCnt;
  94. unsigned long nBitCntr;
  95. unsigned long nOctet;
  96. BYTE nZeroBitDeleteCntr;
  97. bool m_bFlagFound;
  98. bool m_bPartialPage;
  99. unsigned int m_nPartialPagePos;
  100. unsigned int m_nBlockCount;
  101. CECMBuffer m_ECMBuffer;
  102. int m_nECMFrameSize;
  103. void reverse(void *pointer,int countdown);
  104. int ReadIfd(void);
  105. bool ProcessECMFrame( void );
  106. void CountGroup3TiffLines(void);
  107. void CountGroup4TiffLines(void);
  108. int m_nSendEncoding;
  109. bool m_bGotData;
  110. CMemFile m_MemFile;
  111. bool m_bFileHasData;
  112. };
  113. #endif // FAXFILE_H