void TestImageModifierStack(void)
{
	BeginTests();

	CImage					cImage;
	CImageModifierStack		cStack;
	BOOL					bResult;
	CImageRGBToGrey*		pcGrey;
	CImageHeightToNormals*	pcNormals;
	CImageResampler*		pcSmall;
	CImage					cBak;

	bResult = ReadImage(&cBak, "Input/Adelle.png");
	AssertBool(TRUE, bResult);

	cImage.Copy(&cBak);
	cStack.Init(&cImage);

	pcGrey = cStack.AddModifier<CImageRGBToGrey>();
	pcGrey->Init(RGBTGS_UseRed);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleGrey.raw");
	AssertFileMemory("Input/AdelleGrey.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	pcNormals = cStack.AddModifier<CImageHeightToNormals>();
	pcNormals->Init(IMAGE_DIFFUSE_GREY);
	cImage.Copy(&cBak);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleNormal.raw");
	AssertFileMemory("Input/AdelleNormal.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	pcSmall = cStack.AddModifier<CImageResampler>();
	pcSmall->Init(IR_NearestNeighbour, 21, 16);
	cImage.Copy(&cBak);
	cStack.ApplyAll();

	WriteImage(&cImage, "Output/AdelleSmall.raw");
	AssertFileMemory("Input/AdelleSmall.raw", cImage.GetData(), cImage.GetByteSize());
	AssertInt(3, cStack.NumModifiers());

	cStack.Kill();
	cImage.Kill();

	cBak.Kill();

	TestStatistics();
}
void TestImageDividerGenerateFromBorderWithTransparent(void)
{

	CImageDivider	cImageDivider;
	CImage			cImage;
	CImageCelMask*	pcRectangle;
	unsigned int	uiTransparent;
	CImage			cMask;

	ReadImage(&cImage, "Input\\cel6.png");

	uiTransparent = 0x000000;
	cImageDivider.Init(&cImage, (SImageColour*)&uiTransparent);
	cImageDivider.GenerateFromBorder(&cMask);
	AssertInt(2, cImageDivider.GetDestImageCels()->NumElements());
	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(0);
	AssertInt(4, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(4, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(18, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(28, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(1);
	AssertInt(9, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(18, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(11, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(25, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	WriteImage(&cMask, "Output\\cel6.raw");
	AssertFileMemory("input\\cel6.raw", cMask.mcChannels.GetData(), cMask.GetByteSize());

	cImageDivider.Kill();
	cMask.Kill();
	cImage.Kill();
}
Ejemplo n.º 3
0
void TestImageReaderRAD(void)
{
	CImage			cImage;
	BOOL			bResult;

	bResult = ReadImage(&cImage, "Input\\readrad.rad");
	AssertBool(TRUE, bResult);
	WriteImage(&cImage, "Output\\readrad.raw");
	AssertFileMemory("input\\readrad.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	//Read raw is a special case.  Because the size and the channels aren't known the image must be initialised before hand.
	cImage.Init(32, 48, PT_uchar, IMAGE_DIFFUSE_RED, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_BLUE, CHANNEL_ZERO);
	bResult = ReadImage(&cImage, "Input\\readrad.raw");
	AssertBool(TRUE, bResult);
	WriteImage(&cImage, "Output\\readraw.raw");
	AssertFileMemory("input\\readraw.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();
}
Ejemplo n.º 4
0
void TestImageReaderTGA(void)
{
	CImage			cImage;

	ReadImage(&cImage, "Input\\tar32un.tga");
	WriteImage(&cImage, "Output\\tar32un.raw");
	AssertFileMemory("input\\tar32un.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\tar24un.tga");
	WriteImage(&cImage, "Output\\tar24un.raw");
	AssertFileMemory("input\\tar24un.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\tar16un.tga");
	WriteImage(&cImage, "Output\\tar16un.raw");
	AssertFileMemory("input\\tar16un.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();
}
Ejemplo n.º 5
0
void TestImageSwizzle(void)
{
	BeginTests();

	CImage					cImage;
	CImageModifierStack		cStack;
	CImageRGBToGrey*		pcRGBToGrey;
	CImageChannelRename*	pcChannelRename;
	CImageChannelAdd*		pcChannelAdd;
	CImageDrawBox*			pcDrawBox;
	CImageColourRGB			cRGB;

	ReadImage(&cImage, "Input\\swizzel.png");

	cStack.Init(&cImage);
	
	pcRGBToGrey = cStack.AddModifier<CImageRGBToGrey>();
	pcRGBToGrey->Init(RGBTGS_OnlyIfChannelsSame);

	pcChannelRename = cStack.AddModifier<CImageChannelRename>();
	pcChannelRename->Init(IMAGE_DIFFUSE_GREY, IMAGE_OPACITY);

	pcChannelAdd = cStack.AddModifier<CImageChannelAdd>();
	pcChannelAdd->Init(IMAGE_DIFFUSE_RED, PT_uchar);
	pcChannelAdd->AddChannel(IMAGE_DIFFUSE_GREEN);
	pcChannelAdd->AddChannel(IMAGE_DIFFUSE_BLUE);

	pcDrawBox = cStack.AddModifier<CImageDrawBox>();
	
	cRGB.Init(1.0f, 1.0f, 1.0f);
	pcDrawBox->Init(NULL, &cRGB);

	cStack.ApplyAll();
	cStack.Kill();

	WriteImage(&cImage, "Output\\swizzle.raw");
	AssertFileMemory("input\\swizzle.raw", cImage.GetData(), cImage.GetByteSize());

	cImage.Kill();

	TestStatistics();
}
void TestImageGreyToRGB(void)
{
	BeginTests();

	CImage				cImage;
	CImageGreyToRGB		cGreyToRGB;

	ReadImage(&cImage, "Input/basn0g08.png");

	cGreyToRGB.Init();
	cGreyToRGB.Modify(&cImage);
	cGreyToRGB.Kill();

	WriteImage(&cImage, "Output/GreyToRGB.raw");
	AssertFileMemory("input/GreyToRGB.raw", cImage.GetData(), cImage.GetByteSize());

	cGreyToRGB.Kill();
	cImage.Kill();

	TestStatistics();
}
void TestImageDividerGenerateFromBorder(void)
{

	CImageDivider	cImageDivider;
	CImage			cImage;
	CImage			cMask;
	CImageCelMask*	pcRectangle;

	ReadImage(&cImage, "Input\\splitter.png");

	cImageDivider.Init(&cImage);
	cImageDivider.GenerateFromBorder(&cMask);
	AssertInt(20, cImageDivider.GetDestImageCels()->NumElements());
	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(0);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(1);
	AssertInt(15, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(17);
	AssertInt(21, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(39, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(3, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(3, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	WriteImage(&cMask, "Output\\splitter.raw");
	AssertFileMemory("input\\splitter.raw", cMask.mcChannels.GetData(), cMask.GetByteSize());

	cImageDivider.Kill();
	cMask.Kill();
	cImage.Kill();
}
Ejemplo n.º 8
0
void TestImageReaderPNG(void)
{
	CImage			cImage;

	ReadImage(&cImage, "Input\\basn0g01.png");
	WriteImage(&cImage, "Output\\basn0g01.raw");
	AssertFileMemory("input\\basn0g01.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn0g02.png");
	WriteImage(&cImage, "Output\\basn0g02.raw");
	AssertFileMemory("input\\basn0g02.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn0g04.png");
	WriteImage(&cImage, "Output\\basn0g04.raw");
	AssertFileMemory("input\\basn0g04.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn0g08.png");
	WriteImage(&cImage, "Output\\basn0g08.raw");
	AssertFileMemory("input\\basn0g08.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn0g16.png");
	WriteImage(&cImage, "Output\\basn0g16.raw");
	AssertFileMemory("input\\basn0g16.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn2c08.png");
	WriteImage(&cImage, "Output\\basn2c08.raw");
	AssertFileMemory("input\\basn2c08.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn2c16.png");
	WriteImage(&cImage, "Output\\basn2c16.raw");
	AssertFileMemory("input\\basn2c16.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn4a08.png");
	AssertInt(32, cImage.GetWidth());
	AssertInt(32, cImage.GetHeight());
	AssertInt(2048, cImage.GetByteSize());
	WriteImage(&cImage, "Output\\basn4a08.raw");
	AssertFileMemory("input\\basn4a08.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn4a16.png");
	WriteImage(&cImage, "Output\\basn4a16.raw");
	AssertFileMemory("input\\basn4a16.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn6a08.png");
	WriteImage(&cImage, "Output\\basn6a08.raw");
	AssertFileMemory("input\\basn6a08.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();

	ReadImage(&cImage, "Input\\basn6a16.png");
	WriteImage(&cImage, "Output\\basn6a16.raw");
	AssertFileMemory("input\\basn6a16.raw", cImage.GetData(), cImage.GetByteSize());
	cImage.Kill();
}