Exemple #1
0
// ****************************************************************************
//
// Function Name:			RPsd3VerticalBannerGraphic::Initialize()
//
// Description:			Loads a graphic into memory based on parameters
//
// Returns:					TRUE if successful, FALSE otherwise
//
// Exceptions:				None
//
// ****************************************************************************
BOOLEAN RPsd3VerticalBannerGraphic::Initialize(const uBYTE* pGraphicData, BOOLEAN fAdjustLineWidth, BOOLEAN fMonochrome)
{		
	// Clear out any previous internal data
	Undefine();

	try
	{
		// Get the header and graphic offset
		RPsd3MultiPartGraphicHeader* pHeader = (RPsd3MultiPartGraphicHeader*) pGraphicData;
		sLONG sGraphicOffset = sizeof(RPsd3MultiPartGraphicHeader);

		// byte swap data on mac
#ifdef MAC
		tintSwapStructs( pHeader, sizeof(RPsd3MultiPartGraphicHeader), 1, 0x0000000155L ); 
#endif

		// Read in the left cap
		if (pHeader->m_PartsList & kTopCap)
		{
			const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
			RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;				
			if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome)) throw;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the graphic
			m_pTopCap = pGraphic;
		}

		// Read in the right cap
		if (pHeader->m_PartsList & kBottomCap)
		{
			const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
			RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;				
			if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome)) throw;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the graphic
			m_pBottomCap = pGraphic;
		}

		// Read in the top rail
		if (pHeader->m_PartsList & kLeftRail)
		{
			const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
			RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;				
			if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome)) throw;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the graphic
			m_pLeftRail = pGraphic;
		}
	
		// Read in the bottom rail
		if (pHeader->m_PartsList & kRightRail)
		{
			const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
			RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;				
			if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome)) throw;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the graphic
			m_pRightRail = pGraphic;
		}

		// Check for mirror left cap
		m_fMirrorCaps = FALSE;
		if (pHeader->m_Flip & kTopCap)
		{
			m_fMirrorCaps = TRUE;
			if (pHeader->m_PartsList & kBottomCap)
			{
				// The header said to mirror the caps, but we were given a right
				// cap, so use it
				m_fMirrorCaps = FALSE;
			}
		}
	}
	catch(...)
	{
		// Clean up
		Undefine();
		return FALSE;
	}
	
	return TRUE;
}
Exemple #2
0
// ****************************************************************************
//
// Function Name:			RPsd3RuledLineGraphic::Initialize()
//
// Description:			Loads a graphic into memory based on parameters
//
// Returns:					TRUE if successful, FALSE otherwise
//
// Exceptions:				None
//
// ****************************************************************************
BOOLEAN RPsd3RuledLineGraphic::Initialize(const uBYTE* pGraphicData, BOOLEAN fAdjustLineWidth, BOOLEAN fMonochrome)
{
	// Clean up the internals
	Undefine();

	// Read in parts from file data	
	//		a) Left cap
	//		b) Right cap
	//		c) Rail	
	RPsd3MultiPartGraphicHeader* pHeader = (RPsd3MultiPartGraphicHeader*) pGraphicData;
	sLONG sGraphicOffset = sizeof(RPsd3MultiPartGraphicHeader);

	// byte swap data on mac
#ifdef MAC
	tintSwapStructs( pHeader, sizeof(RPsd3MultiPartGraphicHeader), 1, 0x0000000155L ); 
#endif

	if (pHeader->m_PartsList & kPsd3RuledLineLeftCap)
	{
		const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
		RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;
		if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome))
		{
			delete pGraphic;			
			return FALSE;
		}
		else
		{
			m_pLeftCap = pGraphic;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the current graphic
		}
	}
	
	if (pHeader->m_PartsList & kPsd3RuledLineRightCap)
	{
		const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
		RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;
		if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome))
		{
			delete pGraphic;			
			return FALSE;
		}
		else
		{
			m_pRightCap = pGraphic;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the current graphic
		}
	}

	if (pHeader->m_PartsList & kPsd3RuledLineRail)
	{
		const uBYTE* pCurrentGraphic = pGraphicData + sGraphicOffset;
		RPsd3SingleGraphic* pGraphic = new RPsd3SingleGraphic;
		if (!pGraphic->Initialize(pCurrentGraphic, fAdjustLineWidth, fMonochrome))
		{
			delete pGraphic;			
			return FALSE;
		}
		else
		{
			m_pRail = pGraphic;
			sGraphicOffset += *((uLONG*)pCurrentGraphic); // The size of the current graphic
		}
	}

	// Check for mirror left cap
	if (pHeader->m_Flip & kPsd3RuledLineLeftCap)
	{
		m_fMirrorCaps = TRUE;
	}
	else
	{
		m_fMirrorCaps = FALSE;
	}

	return TRUE;
}