TEST(doubleDecorator, CodecLibrary) { setUp(); std::ifstream inFile("basic.bmp", std::ios::binary); CHECK_EQUAL(0, !inFile); HBitmapDecoder decoder = theCodecLibrary->createDecoder(inFile); HBitmapIterator iterator = decoder->createIterator(); CHECK(iterator.get()); CHECK_EQUAL(100, iterator->getBitmapHeight()); CHECK_EQUAL(100, iterator->getBitmapWidth()); HBitmapIterator colorInvertIterator(new ColorInversionDecorator(iterator)); HBitmapIterator darkenColorInvertIterator(new BrightnessDecorator(colorInvertIterator, -50)); HBitmapEncoder encoder = theCodecLibrary->createEncoder(msBmp, darkenColorInvertIterator); std::ofstream outFile("output_darkInverted.bmp", std::ios::binary); encoder->encodeToStream(outFile); // TODO: file compare input/output tearDown(); }
TEST(BitmapSizeTest, BitmapIterator) { std::ifstream bitmapStream("basic.bmp", std::ios::binary); CHECK(bitmapStream.is_open()); WindowsBitmapDecoder decoder(bitmapStream); HBitmapIterator bitmapIter = decoder.createIterator(); CHECK_EQUAL(100, bitmapIter->getBitmapWidth()); CHECK_EQUAL(100, bitmapIter->getBitmapHeight()); }
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); }
TEST(windowsBitmapDecodeEncode, CodecLibrary) { setUp(); std::ifstream inFile("basic.bmp", std::ios::binary); CHECK_EQUAL(0, !inFile); HBitmapDecoder decoder = theCodecLibrary->createDecoder(inFile); HBitmapIterator iterator = decoder->createIterator(); CHECK(iterator.get()); CHECK_EQUAL(100, iterator->getBitmapHeight()); CHECK_EQUAL(100, iterator->getBitmapWidth()); HBitmapEncoder encoder = theCodecLibrary->createEncoder(msBmp, iterator); std::ofstream outFile("output_basicCopy.bmp", std::ios::binary); encoder->encodeToStream(outFile); // TODO: file compare input/output tearDown(); }
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); }