コード例 #1
0
void CFilterColorizeEntry::MarkImage (void)

//	MarkImage
//
//	Mark all images

	{
	if (m_pSource)
		m_pSource->MarkImage();
	}
コード例 #2
0
void CFilterColorizeEntry::InitSelector (int iVariant, CCompositeImageSelector *retSelector)

//	InitSelector
//
//	For now we just initialize a single entry

	{
	if (m_pSource)
		m_pSource->InitSelector(iVariant, retSelector);
	}
コード例 #3
0
void CFilterColorizeEntry::InitSelector (CCompositeImageSelector *retSelector)

//	InitSelector
//
//	Initializes the selector

	{
	if (m_pSource)
		m_pSource->InitSelector(retSelector);
	}
コード例 #4
0
ファイル: CCompositeImageDesc.cpp プロジェクト: bmer/Mammoth
ALERROR CCompositeImageDesc::InitEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CIDCounter &IDGen, IImageEntry **retpEntry)

//	InitEntryFromXML
//
//	Initializes the desc from XML

	{
	ALERROR error;

	IImageEntry *pEntry;
	if (strEquals(pDesc->GetTag(), IMAGE_COMPOSITE_TAG) || strEquals(pDesc->GetTag(), COMPOSITE_TAG))
		pEntry = new CCompositeEntry;
	else if (strEquals(pDesc->GetTag(), IMAGE_EFFECT_TAG) || strEquals(pDesc->GetTag(), EFFECT_TAG))
		pEntry = new CEffectEntry;
	else if (strEquals(pDesc->GetTag(), TABLE_TAG) || strEquals(pDesc->GetTag(), IMAGE_VARIANTS_TAG))
		pEntry = new CTableEntry;
	else if (strEquals(pDesc->GetTag(), FILTER_COLORIZE_TAG))
		pEntry = new CFilterColorizeEntry;
	else if (strEquals(pDesc->GetTag(), LOCATION_CRITERIA_TABLE_TAG))
		pEntry = new CLocationCriteriaTableEntry;

	//	Otherwise, assume that this is either a plain image or an arbitrary tag with
	//	content elements representing the actual image composition.

	else
		{
		if (pDesc->GetContentElementCount() == 0)
			pEntry = new CImageEntry;
		else
			return InitEntryFromXML(Ctx, pDesc->GetContentElement(0), IDGen, retpEntry);
		}

	//	Init

	if (error = pEntry->InitFromXML(Ctx, IDGen, pDesc))
		return error;

	*retpEntry = pEntry;

	return NOERROR;
	}
コード例 #5
0
bool CFilterColorizeEntry::IsConstant (void)

//	IsConstant
//
//	Returns TRUE if this is a constant entry

	{
	if (m_pSource == NULL)
		return true;

	return m_pSource->IsConstant();
	}
コード例 #6
0
int CFilterColorizeEntry::GetMaxLifetime (void) const

//	GetMaxLifetime
//
//	Returns the maximum lifetime

	{
	if (m_pSource == NULL)
		return 0;

	return m_pSource->GetMaxLifetime();
	}
コード例 #7
0
ALERROR CCompositeImageDesc::InitEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CIDCounter &IDGen, IImageEntry **retpEntry)

//	InitEntryFromXML
//
//	Initializes the desc from XML

	{
	ALERROR error;

	IImageEntry *pEntry;
	if (strEquals(pDesc->GetTag(), IMAGE_TAG))
		{
		if (pDesc->GetContentElementCount() == 0)
			pEntry = new CImageEntry;
		else
			return InitEntryFromXML(Ctx, pDesc->GetContentElement(0), IDGen, retpEntry);
		}
	else if (strEquals(pDesc->GetTag(), IMAGE_COMPOSITE_TAG) || strEquals(pDesc->GetTag(), COMPOSITE_TAG))
		pEntry = new CCompositeEntry;
	else if (strEquals(pDesc->GetTag(), TABLE_TAG) || strEquals(pDesc->GetTag(), IMAGE_VARIANTS_TAG))
		pEntry = new CTableEntry;
	else if (strEquals(pDesc->GetTag(), FILTER_COLORIZE_TAG))
		pEntry = new CFilterColorizeEntry;
	else
		{
		Ctx.sError = strPatternSubst(CONSTLIT("Unknown image tag: %s"), pDesc->GetTag());
		return ERR_FAIL;
		}

	//	Init

	if (error = pEntry->InitFromXML(Ctx, IDGen, pDesc))
		return error;

	*retpEntry = pEntry;

	return NOERROR;
	}
コード例 #8
0
ALERROR CFilterColorizeEntry::OnDesignLoadComplete (SDesignLoadCtx &Ctx)

//	OnDesignLoadComplete
//
//	Bind design

	{
	ALERROR error;

	if (m_pSource == NULL)
		return NOERROR;

	if (error = m_pSource->OnDesignLoadComplete(Ctx))
		return error;

	return NOERROR;
	}
コード例 #9
0
void InitStationTypeImage (SEntryDesc &Entry, CStationType *pStationType)
	{
	struct SSatImageDesc
		{
		const CObjectImageArray *pImage;
		CCompositeImageSelector Selector;
		int xOffset;
		int yOffset;
		};

	int i;

	SSelectorInitCtx InitCtx;
	pStationType->SetImageSelector(InitCtx, &Entry.Selector);
	const CObjectImageArray *pMainImage = &pStationType->GetImage(Entry.Selector, CCompositeImageModifiers());

	//	If we have no satellites, then we can just return the single station 
	//	image.

	CXMLElement *pSatellites = pStationType->GetSatellitesDesc();
	if (pSatellites == NULL)
		{
		Entry.pImage = pMainImage;
		return;
		}

	//	Figure out the extents of the image

	RECT rcMainImage = pMainImage->GetImageRect();
	RECT rcBounds;
	rcBounds.left = -(RectWidth(rcMainImage) / 2);
	rcBounds.top = -(RectHeight(rcMainImage) / 2);
	rcBounds.right = rcBounds.left + RectWidth(rcMainImage);
	rcBounds.bottom = rcBounds.top + RectHeight(rcMainImage);

	//	Loop over all satellites and get metrics

	TArray<SSatImageDesc> SatImages;
	for (i = 0; i < pSatellites->GetContentElementCount(); i++)
		{
		CXMLElement *pSatDesc = pSatellites->GetContentElement(i);
		if (!pSatDesc->FindAttribute(SEGMENT_ATTRIB)
				|| !strEquals(STATION_TAG, pSatDesc->GetTag()))
			continue;

		//	Get the type of the satellite

		CStationType *pSatType = g_pUniverse->FindStationType(pSatDesc->GetAttributeInteger(TYPE_ATTRIB));
		if (pSatType == NULL)
			continue;

		//	Prepare the image for the satellite

		SSatImageDesc *pSatImage = SatImages.Insert();
		pSatType->SetImageSelector(InitCtx, &pSatImage->Selector);

		//	If we have an image variant, then set it

		int iVariant;
		if (pSatDesc->FindAttributeInteger(IMAGE_VARIANT_ATTRIB, &iVariant))
			{
			IImageEntry *pRoot = pSatType->GetImage().GetRoot();
			DWORD dwID = (pRoot ? pRoot->GetID() : DEFAULT_SELECTOR_ID);

			pSatImage->Selector.DeleteAll();
			pSatImage->Selector.AddVariant(dwID, iVariant);
			}

		pSatImage->pImage = &pSatType->GetImage(pSatImage->Selector, CCompositeImageModifiers());

		//	Now get the offset

		pSatImage->xOffset = pSatDesc->GetAttributeInteger(X_OFFSET_ATTRIB);
		pSatImage->yOffset = pSatDesc->GetAttributeInteger(Y_OFFSET_ATTRIB);

		//	Compute the satellite rect

		RECT rcSatImage = pSatImage->pImage->GetImageRect();
		RECT rcSatBounds;
		rcSatBounds.left = pSatImage->xOffset - (RectWidth(rcSatImage) / 2);
		rcSatBounds.top = -pSatImage->yOffset - (RectHeight(rcSatImage) / 2);
		rcSatBounds.right = rcSatBounds.left + RectWidth(rcSatImage);
		rcSatBounds.bottom = rcSatBounds.top + RectHeight(rcSatImage);

		//	Increase the size of the bounds

		rcBounds.left = Min(rcBounds.left, rcSatBounds.left);
		rcBounds.right = Max(rcBounds.right, rcSatBounds.right);
		rcBounds.top = Min(rcBounds.top, rcSatBounds.top);
		rcBounds.bottom = Max(rcBounds.bottom, rcSatBounds.bottom);
		}

	//	If no segments, then we just return the basic image

	if (SatImages.GetCount() == 0)
		{
		Entry.pImage = pMainImage;
		return;
		}

	//	Create an image that will hold the composite

	CG32bitImage *pCompositeImage = new CG32bitImage;
	pCompositeImage->Create(RectWidth(rcBounds), RectHeight(rcBounds), CG32bitImage::alpha8, CG32bitPixel::Null());
	int xCenter = -rcBounds.left;
	int yCenter = -rcBounds.top;

	//	Paint the main image

	pMainImage->PaintImage(*pCompositeImage, xCenter, yCenter, 0, Entry.iRotation, true);

	//	Paint all the satellites

	for (i = 0; i < SatImages.GetCount(); i++)
		SatImages[i].pImage->PaintImage(*pCompositeImage, xCenter + SatImages[i].xOffset, yCenter - SatImages[i].yOffset, 0, 0, true);

	//	Now create the proper image array

	RECT rcResult;
	rcResult.left = 0;
	rcResult.top = 0;
	rcResult.right = RectWidth(rcBounds);
	rcResult.bottom = RectHeight(rcBounds);

    int xOffset = (RectWidth(rcBounds) / 2) - xCenter;
    int yOffset = (RectHeight(rcBounds) / 2) - yCenter;

	Entry.pCompositeImageArray = new CObjectImageArray;
	Entry.pCompositeImageArray->Init(pCompositeImage, rcResult, 0, 0, true, xOffset, yOffset);

	//	Done

	Entry.pImage = Entry.pCompositeImageArray;
	}
コード例 #10
0
void CFilterColorizeEntry::GetImage (const CCompositeImageSelector &Selector, CObjectImageArray *retImage)

//	GetImage
//
//	Fills in the image

	{
	//	Null case

	if (m_pSource == NULL)
		{
		*retImage = EMPTY_IMAGE;
		return;
		}

	//	Get the source image (which we want to colorize)

	CObjectImageArray Source;
	m_pSource->GetImage(Selector, &Source);
	const RECT &rcSource = Source.GetImageRect();
	CG16bitImage &SourceImage = Source.GetImage(NULL_STR);
	int cxWidth = RectWidth(rcSource);
	int cyHeight = RectHeight(rcSource);
	if (Source.IsEmpty() || cxWidth == 0 || cyHeight == 0)
		{
		*retImage = EMPTY_IMAGE;
		return;
		}

	//	Create the destination image

	CG16bitImage *pDest = new CG16bitImage;
	pDest->CreateBlank(cxWidth, cyHeight, SourceImage.HasAlpha());
	if (!SourceImage.HasAlpha())
		pDest->SetTransparentColor();

	//	Blt the to the destination with colorization

	CopyBltColorize(*pDest,
			0,
			0,
			cxWidth,
			cyHeight,
			SourceImage,
			rcSource.left,
			rcSource.top,
			m_dwHue,
			m_dwSaturation);

	//	Initialize an image

	RECT rcFinalRect;
	rcFinalRect.left = 0;
	rcFinalRect.top = 0;
	rcFinalRect.right = cxWidth;
	rcFinalRect.bottom = cyHeight;

	CObjectImageArray Comp;
	Comp.Init(pDest, rcFinalRect, 0, 0, true);

	//	Done

	retImage->TakeHandoff(Comp);
	}