BOOL CImageCelsSourceXML::ImportCels(CMarkupTag* pcCelsTag, char* szFileName) { STagIterator sIter; CSubImageXML cSubImageXML; CMarkupTag* pcCelTag; CArraySubImage acSubImages; CSubImage* pcSubImage; BOOL bResult; CImageCelSourceSubImages cSubImagesSource; CImageCelsSource cCelsSource; CChars szGroupName; CFileUtil cFileUtil; Ptr<CImageCelGroup> pcGroup; acSubImages.Init(); pcCelTag = pcCelsTag->GetTag("Cel", &sIter); while (pcCelTag) { pcSubImage = acSubImages.Add(); bResult = cSubImageXML.Import(pcCelTag, pcSubImage); if (!bResult) { acSubImages.Kill(); return FALSE; } pcCelTag = pcCelsTag->GetNextTag(&sIter); } cSubImagesSource.Init(&acSubImages); szGroupName.Init(szFileName); cFileUtil.RemovePath(&szGroupName); cCelsSource.Init(); cCelsSource.AddDiskFileSource(szFileName, szGroupName.Text(), &cSubImagesSource); cCelsSource.Load(); mpcWorld->AddImages(cCelsSource.GetImages()); pcGroup = ONMalloc(CImageCelGroup, szGroupName.Text()); mpcWorld->AddGroup(pcGroup); pcGroup->AddCels(cCelsSource.GetImageCels()); szGroupName.Kill(); cSubImagesSource.Kill(); cCelsSource.Kill(); acSubImages.Kill(); return TRUE; }
void TestImageCombinerMask(void) { CImageCelSourceBorders cBorder; CImageCombiner cCombiner; Ptr<CImage> pcImage; CImageCelsSource cSource; SImageColour sColour; ObjectsInit(); sColour.c[0] = 0; sColour.c[1] = 0; sColour.c[2] = 0; sColour.c[3] = 0; cBorder.Init(&sColour); cSource.Init(); cSource.AddDiskFileSource("Input\\cel4.png", "Cel 4", &cBorder); cSource.AddDiskFileSource("Input\\cel6.png", "Cel 6", &cBorder); cSource.Load(); cCombiner.Init(ICL_Best, ICS_Arbitrary, ICC_FromCels); cCombiner.AddCels(cSource.GetCels()); pcImage = cCombiner.Combine(); WriteImage(&pcImage, "Output\\CombineMask.png"); WriteImage(&pcImage, "Output\\CombineMask.raw"); AssertFileMemory("input\\CombineMask.raw", pcImage->mcChannels.GetData(), pcImage->GetByteSize()); pcImage->Kill(); cCombiner.Kill(); cSource.Kill(); ObjectsKill(); }