#include <boost/gil/typedefs.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
#include <boost/assign/std/vector.hpp>
#include <utilgil.hpp>
#include <utilstl.hpp>

using namespace boost::gil;
using namespace boost::assign;

//GCC Build String
//g++ sample6.cpp -lpng -lz -I . -I ~/lib/boost -I ~/lib  

int main(int args, char** argv)
{
        rgb8_image_t img(200,200);
        boost::gil::fill_pixels(boost::gil::view(img),
                boost::gil::rgb8_pixel_t(170,170,170));

        static unsigned char buffer[] = {
                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,230,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,220,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,170,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,140,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,110,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,220,65,
                        255,255,255,255,255,255,255,255,255,255,255,255,255,150,0,
                        255,255,255,255,255,255,255,255,255,255,255,255,220,90,0,
                        255,255,255,255,255,255,255,255,255,255,255,255,170,0,0,
                        255,255,255,255,255,255,255,255,255,255,255,180,0,0,0,
                        255,255,255,255,255,255,255,255,255,255,190,60,0,0,0,
                        255,255,255,255,255,255,255,255,255,185,60,0,0,0,0,
                        255,255,255,255,255,255,255,215,170,0,0,0,0,0,0,
                        255,255,255,255,255,215,165,100,0,0,0,0,0,0,0,
                        230,200,170,140,110,65,0,0,0,0,0,0,0,0,0
                        };

        int width = 15;
        int height = 15;

        gray8c_view_t grayview = interleaved_view(width,height,
                (gray8_pixel_t*)buffer,sizeof(unsigned char)*width);

        rgb8_pixel_t clr(rgb8_pixel_t(0,0,255));
               
        fill_pixels(subimage_view(
                view(img),width,0,view(img).width()-width*2,view(img).height()),clr);
        fill_pixels(subimage_view(
                view(img),0,height,view(img).width(),view(img).height()-height*2),clr);

        copy_alpha_blended_pixels(clr,rotated180_view(grayview),
                subimage_view(view(img),0,0,width,height));
        copy_alpha_blended_pixels(clr,grayview,
                subimage_view(view(img),view(img).width()-width,view(img).height()-height,width,height));
        copy_alpha_blended_pixels(clr,rotated90ccw_view(grayview),
                subimage_view(view(img),view(img).width()-width,0,width,height));
        copy_alpha_blended_pixels(clr,rotated90cw_view(grayview),
                subimage_view(view(img),0,view(img).height()-height,width,height));
       
        png_write_view("sample6.png", view(img));
}