⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faxfile.h

📁 fax engine 传真引擎 relay fax 的开源项目 商业软件使用 高质量 高可靠
💻 H
字号:
/*****************************************************************************
* RelayFax Open Source Project
* Copyright 1996-2004 Alt-N Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the RelayFax Open 
* Source License.  A copy of this license is available in file LICENSE 
* in the top-level directory of the distribution.
*
* RelayFax is a registered trademark of Alt-N Technologies, Ltd.
*
* Individual files and/or contributed packages may be copyright by
* other parties and subject to additional restrictions.
*****************************************************************************/

#ifndef FAXFILE_H 
#define FAXFILE_H

#include "CommPort.h"
#include "ECMBuffer.h"

#include "tiffio.h"
#include "memfile.h"

class CFaxFile  
{
public:

	CFaxFile();
	virtual ~CFaxFile();

	void SetFileName( LPCSTR szFilename ) { m_sFaxFile.assign( szFilename ); };

	void SelectEncoding( int nEncoding );

	int ReadFirstHeader(void);
	bool ReadPage( bool bUseECM, int nClass1Speed, WORD wMinLineChars, bool bClassTwoZero = false, bool bClassTwo = false );
	bool ReadNextHeader(void);
	bool ReadBadFrames( int nClass1Speed );
	void Close(void);

	void SetImageRes( bool bHiRes );
	void SetImageWidth( int nWidth );
	void SetImageLength( int nLength );
	void IncrementImageLength( int n = 1 );
	void SetImageCompression( int nCompression );
	void SetT4Options( int nOptions );
	void SetECMFrameSize( int nSize ) { m_nECMFrameSize = nSize; }
	void IncrementPageCount(void) { m_PageCount++; };

	bool WriteFileHeader(void);
	bool WriteBuffer( unsigned char* szBuffer, unsigned int nBytes, bool bFlipBytes = true );
	bool WriteECMBuffer( unsigned char* szBuffer, unsigned int nBytes );
	bool WriteIFD(void);
	int WriteIfd (void);
	bool IsECMBlockGood( int nFrameCount ) { return m_ECMBuffer.IsECMBlockGood(nFrameCount); };
	void NextECMBlock(void);
	void RedoECMBlock(void);
	void AddFCDHeader(void);
	void AddRCPFrames(void);
	void AddByte( unsigned char b, bool bCalcFCS );
	void AddBit( unsigned char bit );
	void AddFlag( void );

	void Clear(void);

	unsigned char* GetSeqMap(void) { return m_ECMBuffer.GetSeqMap(); };
	char* GetPageData( void ) { return (char*)m_PageBuffer; };
	unsigned int GetPageBytes(void) { return m_PageBufferSize; };
	unsigned int GetPageCount(void) { return m_PageCount; };
	bool GetPartialPage(void) { return m_bPartialPage; };
	unsigned int GetFrameCount(void) { return m_ECMBuffer.GetHighestSeq(); };
	unsigned int GetBlockCount(void) { return m_nBlockCount; };
	int GetSendEncoding(void) { return m_nSendEncoding; };
	void SetSendEncoding( int nEnc ) { m_nSendEncoding = nEnc; };
	bool MorePages(void) { return TIFFLastDirectory( m_tiff ) == 0; };

	unsigned int GetTotalPageSize( void ) { return m_MemFile.GetDataLen(); };


	int GetECMFrameSize( void ) { return m_nECMFrameSize; }
	bool IsHiRes(void);

	static BYTE s_LeadZero[256];
	static BYTE s_TrailZero[256];
	static unsigned char s_FlipTable[];

protected:

	static const int s_WTree [][2];
	static const int s_BTree [][2];
	static const int s_TwoTree [][2];

	string m_sFaxFile;

	uint16 bitspersample;
	uint32 width, length, rowsperstrip;
	uint16 fillorder;
	uint32 g3opts;
	uint16 compression;
	float xres, yres;

	unsigned char* m_PageBuffer;
	unsigned char* m_PagePtr;
	unsigned int m_PageBufferSize;
	unsigned int m_PageCount;
	TIFF* m_tiff;
	unsigned long int lastifd;
	bool m_bFoundStartOfPage;
	bool m_bFoundStartOfFrame;
	bool m_bFoundEndOfPage;
	unsigned long nZcnt;
	unsigned long nRTCCnt;
	unsigned long nBitCntr;
	unsigned long nOctet;
	BYTE nZeroBitDeleteCntr;
	bool m_bFlagFound;
	bool m_bPartialPage;
	unsigned int m_nPartialPagePos;
	unsigned int m_nBlockCount;

	CECMBuffer m_ECMBuffer;
	int m_nECMFrameSize;

	void reverse(void *pointer,int countdown);

	int ReadIfd(void);


	bool ProcessECMFrame( void );
	void CountGroup3TiffLines(void);
	void CountGroup4TiffLines(void);

	int m_nSendEncoding;
	bool m_bGotData;

	CMemFile m_MemFile;

	bool m_bFileHasData;
};


#endif // FAXFILE_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -