TEST(UsingDecoratorIterators,GrayscaleDecorator) { std::shared_ptr<CodecLibrary> myCodecLibrary; myCodecLibrary.reset(new CodecLibrary); myCodecLibrary->registerEncoder(HBitmapEncoder(new WindowsBitmapEncoder)); myCodecLibrary->registerDecoder(HBitmapDecoder(new WindowsBitmapDecoder)); std::ifstream inFile("basic.bmp", std::ios::binary); HBitmapDecoder myDecoder = myCodecLibrary->createDecoder("image/x-ms-bmp",inFile); HBitmapIterator myIterator = myDecoder->createIterator(); HBitmapIterator myDecorator(new GrayscaleDecorator(myIterator)); HBitmapEncoder myEncoder = myCodecLibrary->createEncoder("image/x-ms-bmp", myDecorator); CHECK(myEncoder); std::ofstream outFile("Grayscale.bmp", std::ios::binary); myEncoder->writeToStream(outFile); CHECK(outFile); }
TEST(CodecLibrarySetup, CodecLibrary) { CodecLibrary myCodecLibrary; myCodecLibrary.registerEncoder(HBitmapEncoder(new WindowsBitmapEncoder)); myCodecLibrary.registerDecoder(HBitmapDecoder(new WindowsBitmapDecoder)); CHECK_EQUAL(1, myCodecLibrary.numberOfEncoders()); CHECK_EQUAL(1, myCodecLibrary.numberOfDecoders()); }
TEST(Decoder, CodecLibrary) { std::shared_ptr<CodecLibrary> myCodecLibrary; myCodecLibrary.reset(new CodecLibrary); myCodecLibrary->registerEncoder(HBitmapEncoder(new WindowsBitmapEncoder)); myCodecLibrary->registerDecoder(HBitmapDecoder(new WindowsBitmapDecoder)); std::ifstream inFile("basic.bmp", std::ios::binary); HBitmapDecoder myDecoder = myCodecLibrary->createDecoder("image/x-ms-bmp",inFile); CHECK(myDecoder); }
HBitmapDecoder WindowsBitmapDecoder::clone(std::istream& sourceStream) { return HBitmapDecoder(new WindowsBitmapDecoder(sourceStream)); }