예제 #1
0
TEST(BitmapReadWrite, BitmapEncoderDecoder)
{
	// Read in the bitmap

	std::ifstream bitmapStream("basic.bmp", std::ios::binary);
	CHECK(bitmapStream.is_open());

	WindowsBitmapDecoder decoder(bitmapStream);
	HBitmapIterator bitmapIter = decoder.createIterator();

	// Write out the bitmap to a different file with its write() method

	std::ofstream outputStream("outputED.bmp", std::ios::binary);
	CHECK(outputStream.is_open());

	WindowsBitmapEncoder encoder(bitmapIter);
	encoder.encodeToStream(outputStream);
	outputStream.close();

	// Read that one back in and check sizes

	std::ifstream bitmapStream2("outputED.bmp", std::ios::binary);
	CHECK(bitmapStream2.is_open());

	WindowsBitmapDecoder decoder2(bitmapStream2);
	bitmapIter = decoder2.createIterator();

	int numberOfScanLines = 0;
	while (!bitmapIter->isEndOfImage())
	{
		int numberOfPixelsInScanLine = 0;
		while (!bitmapIter->isEndOfScanLine())
		{
			++numberOfPixelsInScanLine;
			bitmapIter->nextPixel();
		}
		CHECK_EQUAL(100, numberOfPixelsInScanLine);
		++numberOfScanLines;

		bitmapIter->nextScanLine();
	}
	CHECK_EQUAL(100, numberOfScanLines);
}
예제 #2
0
TEST(BitmapScanLinesTest, BitmapIterator)
{
	std::ifstream bitmapStream("basic.bmp", std::ios::binary);
	CHECK(bitmapStream.is_open());

	WindowsBitmapDecoder decoder(bitmapStream);
	HBitmapIterator bitmapIter = decoder.createIterator();

	int numberOfScanLines = 0;
	while (!bitmapIter->isEndOfImage())
	{
		int numberOfPixelsInScanLine = 0;
		while (!bitmapIter->isEndOfScanLine())
		{
			++numberOfPixelsInScanLine;
			bitmapIter->nextPixel();
		}
		CHECK_EQUAL(100, numberOfPixelsInScanLine);
		++numberOfScanLines;

		bitmapIter->nextScanLine();
	}
	CHECK_EQUAL(100, numberOfScanLines);
}