TuttleOFX
1
|
00001 #ifndef _rounded_hpp_ 00002 #define _rounded_hpp_ 00003 00004 #include <boost/gil/gil_all.hpp> 00005 #include <blend.hpp> 00006 00007 namespace layer 00008 { 00009 00010 template <typename view_t> 00011 struct rounded 00012 { 00013 typedef typename view_t::value_type color_t; 00014 color_t backcolor; 00015 color_t frontcolor; 00016 color_t bordercolor; 00017 rounded(color_t backcolor, color_t frontcolor, color_t bordercolor) : 00018 backcolor(backcolor), frontcolor(frontcolor), bordercolor(bordercolor) {} 00019 00020 void operator()(view_t& view) 00021 { 00022 using namespace boost::gil; 00023 #define ___ 0 00024 00025 static unsigned char buffer2[] = { 00026 ___,___,___,___,___,___,___,___,___,___,___,___,___,255,230, 00027 ___,___,___,___,___,___,___,___,___,___,___,___,___,255,220, 00028 ___,___,___,___,___,___,___,___,___,___,___,___,___,255,170, 00029 ___,___,___,___,___,___,___,___,___,___,___,___,140,255,140, 00030 ___,___,___,___,___,___,___,___,___,___,___,___,180,255,110, 00031 ___,___,___,___,___,___,___,___,___,___,___,___,220,220,065, 00032 ___,___,___,___,___,___,___,___,___,___,___,180,255,150,___, 00033 ___,___,___,___,___,___,___,___,___,___,___,255,220,070,___, 00034 ___,___,___,___,___,___,___,___,___,___,255,255,170,___,___, 00035 ___,___,___,___,___,___,___,___,___,180,255,180,___,___,___, 00036 ___,___,___,___,___,___,___,___,255,255,190,060,___,___,___, 00037 ___,___,___,___,___,___,180,255,255,185,060,___,___,___,___, 00038 ___,___,___,140,180,220,255,215,170,___,___,___,___,___,___, 00039 255,255,255,255,255,215,165,100,___,___,___,___,___,___,___, 00040 230,200,170,140,110,065,___,___,___,___,___,___,___,___,___ 00041 }; 00042 00043 static unsigned char buffer3[] = { 00044 ___,___,___,___,___,___,___,___,___,___,255, 00045 ___,___,___,___,___,___,___,___,___,255,255, 00046 ___,___,___,___,___,___,___,___,___,255,255, 00047 ___,___,___,___,___,___,___,___,255,255,255, 00048 ___,___,___,___,___,___,___,___,255,255,255, 00049 ___,___,___,___,___,___,___,255,255,255,255, 00050 ___,___,___,___,___,___,255,255,255,255,255, 00051 ___,___,___,___,___,255,255,255,255,255,255, 00052 ___,___,___,___,255,255,255,255,255,255,255, 00053 ___,___,255,255,255,255,255,255,255,255,255, 00054 255,255,255,255,255,255,255,255,255,255,255 00055 }; 00056 00057 int width = 15; 00058 int height = 15; 00059 00060 boost::gil::fill_pixels(view,frontcolor); 00061 00062 for (int x = width; x < view.width()-width; ++x) 00063 { 00064 view(x,0) = bordercolor; 00065 view(x,1) = bordercolor; 00066 view(x,view.height()-1) = bordercolor; 00067 view(x,view.height()-2) = bordercolor; 00068 } 00069 00070 for (int y = height; y < view.height()-height; ++y) 00071 { 00072 view(0,y) = bordercolor; 00073 view(1,y) = bordercolor; 00074 view(view.width()-1,y) = bordercolor; 00075 view(view.width()-2,y) = bordercolor; 00076 } 00077 00078 width = 11; 00079 height = 11; 00080 gray8c_view_t grayview = interleaved_view(width,height, 00081 (gray8_pixel_t*)buffer3,sizeof(unsigned char)*width); 00082 00083 copy<alpha24_blend>(backcolor,rotated180_view(grayview), 00084 subimage_view(view,0,0,width,height)); 00085 copy<alpha24_blend>(backcolor,grayview, 00086 subimage_view(view,view.width()-width,view.height()-height,width,height)); 00087 copy<alpha24_blend>(backcolor,rotated90ccw_view(grayview), 00088 subimage_view(view,view.width()-width,0,width,height)); 00089 copy<alpha24_blend>(backcolor,rotated90cw_view(grayview), 00090 subimage_view(view,0,view.height()-height,width,height)); 00091 00092 width = 15; 00093 height = 15; 00094 grayview = interleaved_view(width,height, 00095 (gray8_pixel_t*)buffer2,sizeof(unsigned char)*width); 00096 00097 copy<alpha24_blend>(bordercolor,rotated180_view(grayview), 00098 subimage_view(view,0,0,width,height)); 00099 copy<alpha24_blend>(bordercolor,grayview, 00100 subimage_view(view,view.width()-width,view.height()-height,width,height)); 00101 copy<alpha24_blend>(bordercolor,rotated90ccw_view(grayview), 00102 subimage_view(view,view.width()-width,0,width,height)); 00103 copy<alpha24_blend>(bordercolor,rotated90cw_view(grayview), 00104 subimage_view(view,0,view.height()-height,width,height)); 00105 } 00106 }; 00107 00108 } 00109 00110 #endif