TuttleOFX  1
fill.tests.cpp
Go to the documentation of this file.
00001 #include <boost/test/included/unit_test.hpp>
00002 
00003 #include <fill.hpp>
00004 
00005 using boost::unit_test::test_suite;
00006 using namespace boost::gil;
00007 
00008 //g++ fill.tests.cpp -I /home/scott/project/boost_1_36_0 -I .
00009 
00010 struct test1
00011 {
00012         void operator()()
00013         {
00014                 int width = 200;
00015                 int height = 200;
00016                 unsigned char* buffer = new unsigned char[width * height * 3];
00017                 memset(buffer, 255, width * height * 3);        
00018                 rgb8_view_t view = interleaved_view(width,height,(rgb8_pixel_t*)buffer,width*3);
00019 
00020                 layer::fill<rgb8_view_t> fill(rgb8_view_t::value_type(0,255,0));
00021                 layer::fill_horizontal<rgb8_view_t> horz(fill,20,40,0,100);
00022                 horz(view);
00023                 
00024                 FILE* fd = fopen("fill.ppm", "wb");
00025                 fprintf(fd, "P6\n# CREATOR: reportbase\n%d %d\n255\n", width, height);
00026                 fwrite(buffer, 1, width*height*3, fd);
00027                 fclose(fd);
00028                 delete [] buffer;
00029         }
00030 };
00031 
00032 test_suite* init_unit_test_suite( int argc, char** argv)
00033 {
00034         test_suite* test= BOOST_TEST_SUITE( "fill tests" );
00035         test->add( BOOST_TEST_CASE(test1()), 0);
00036         return test;
00037 }