示例#1
0
// ****************************************************************************
//
//  Function Name:	RGraphicInterfaceImp::Load( )
//
//  Description:		Read in the data into the associated Graphic.from
//							old Print Shop collection format
//
//  Returns:			Nothing
//
//  Exceptions:		kMemory, Disk Errors
//
// ****************************************************************************
//
void RGraphicInterfaceImp::Load( RStorage& storage, EGraphicType graphicType )
{
	RPsd3Graphic* pGraphic = RPsd3Graphic::CreateNewGraphic( graphicType );

	uBYTE*  pGraphicData ;
	uLONG   uGraphicDataSize ;	
	BOOLEAN fMonochrome ;

	const int kMonochromeOffset = 16 ;

	storage.SeekRelative( kMonochromeOffset ) ;
	storage >> fMonochrome ;

	storage.SeekRelative( 3 ) ;   // Gets us to graphic size
	storage >> uGraphicDataSize ;

	uLONG uThumbnailSize ;			// Skip past the thumbnail
	storage >> uThumbnailSize ;
	storage.SeekRelative( uThumbnailSize ) ;

	pGraphicData = storage.GetStorageStream()->GetBuffer( uGraphicDataSize ) ;
	pGraphic->Load( pGraphicData, uGraphicDataSize, fMonochrome ) ;

	m_pGraphicDocument->SetGraphic( dynamic_cast<RGraphic*>( pGraphic ) );
}
示例#2
0
// ****************************************************************************
//
//  Function Name:	RMergeData::ReadTabDelimitedString( )
//
//  Description:		Read a string that is tab delimited from the storage.
//							Eat the delimeter character also (eof, cr/lf, tab).
//
//  Returns:			Nothing
//
//  Exceptions:		Any File Exception, will not send through on kEndOfFile
//
// ****************************************************************************
//
RMergeData::EDataDelimiter RMergeData::ReadTabDelimitedString( RStorage& storage, RMBCString& string )
	{
	EDataDelimiter	delimiter	= kTab;

	try
		{
		uBYTE			ubChar( 0 );
		RCharacter	character;

		//	First, make sure the string is empty
		string.Empty( );

		//	Loop until I hit a EOF, TAB, CR, or LF
		while ( 1 )
			{
			storage >> ubChar;
			if ( (ubChar == '\t') || (ubChar == '\r') || (ubChar == '\n') )
				break;

			//	Check for multi-Byte
			character = ubChar;

			if ( character.IsLead( ) )
				{
				UntestedCode( );
				uBYTE	lead	= ubChar;
				uBYTE	trail;
				storage >> trail;
				character = RCharacter( lead, trail );
				}

			string += character;
			}

			//	If I found a CR or a LF, make sure the other is not also present.
			if ( (ubChar == '\r') || (ubChar == '\n') )
				{
				storage >> ubChar;
				//	If character is NOT a CR or LF, rewind one character
				if ( !((ubChar == '\r') || (ubChar == '\n')) )
					storage.SeekRelative( -1 );
				delimiter = kEOL;
				}
示例#3
0
// ****************************************************************************
//
//  Function Name:	RGraphicInterfaceImp::LoadFromPretzelCollection( )
//
//  Description:		Read in the data into the associated Graphic.from
//							Print Shop library-of-one format
//
//  Returns:			Nothing
//
//  Exceptions:		kMemory, Disk Errors
//
// ****************************************************************************
//
void RGraphicInterfaceImp::LoadFromPretzelCollection( RStorage& storage, EGraphicType graphicType )
{
// save current compiler struct packing setting, set to 1 (each member on byte boundary)
#pragma pack( push, 1 )
	struct DS_LIBHEAD
	{
		char		FileIdentifier[16];	// file verification---NOT NULL TERMINATED!
		char		LibraryName[32];		// Name of library---NOT NULL TERMINATED!
		short		FileID;					// unique file identifier
		short		Machine;					// machine signature
		char		Type;						// type of file---this is often inaccurate so do not use
		char		Subtype;					// type of graphics in file (we no longer use)
		short		Count;					// number of graphics in file
		short		LayoutClassSize;		// size of class info array (layout only)
		short		LayoutCount;			// number of layouts in file (layout only)
		char		DriverName[8];			// driver on which bitmaps were made (DOS platform only)
		char		CreatedByBB;			// library was created by Broderbund
		char		unused;
		long		magicNumber;			// new for version 3.0---confirms library is 3.x
		char		versionLo;				// new for version 3.0
		char		versionHi;				// new for version 3.0
		long		keywordOffset;			// new for version 3.0---reads in keywords until end of file
		char		reserved[48];			// remainder of 128 bytes
	};
	struct DS_GRAPHICINFO
	{
		char	Name[32];			// name of graphic---NOT NULL TERMINATED!
		long	GraphiclD;			// unique graphic identifier
		long	GraphicSize;		// graphic size
		long	BitmapSize;			// bitmap size
		char	GraphicCompress;	// compression scheme for graphics
		char	BitmapCompress;	// compression scheme for bitmaps
		char	MonoFlag;			// True if monochrome graphic
		char	Screening;			// default screening value, 0-100
		char	BackdropType;		// backdrop subtypes
		char	reserved;
		short	ProjectCode;		// project use code
	};
// restore compiler struct packing setting
#pragma pack( pop )

	uLONG uGraphicSize;
	const int kGraphicSizeOffset = sizeof(DS_LIBHEAD) + 36;
	storage.SeekRelative( kGraphicSizeOffset );
	storage >> uGraphicSize;

	BOOLEAN fMonochrome;
	const int kMonochromeOffset = 6;
	storage.SeekRelative( kMonochromeOffset );
	storage >> fMonochrome;

	const int kSkipRemainder = 5;
	storage.SeekRelative( kSkipRemainder );

	uBYTE* pGraphicData = storage.GetStorageStream()->GetBuffer( uGraphicSize );

	RPsd3Graphic* pGraphic = RPsd3Graphic::CreateNewGraphic( graphicType );
	pGraphic->Load( pGraphicData, uGraphicSize, fMonochrome );

	m_pGraphicDocument->SetGraphic( dynamic_cast<RGraphic*>( pGraphic ) );
}