<%pre> #include "gd-cpp/gdpp.h" inline int validColor(int val) { if (val<0) return 0; if (val > 255) return 255; return val; } inline void decodeRGBString(const std::string& rgb, int& red, int& green, int& blue) { char *rend=0,*gend=0,*bend=0; int tmpred = strtol( rgb.substr(0,2).c_str(), &rend, 16); int tmpgreen = strtol( rgb.substr(2,2).c_str(), &rend, 16); int tmpblue = strtol( rgb.substr(4,2).c_str(), &rend, 16); if (*rend == 0 && *gend==0 && *bend==0) { red = tmpred; green = tmpgreen; blue = tmpblue; } } <{ int red = validColor(atoi(qparam.param("r").c_str())); int green = validColor(atoi(qparam.param("g").c_str())); int blue = validColor(atoi(qparam.param("b").c_str())); int bg_red = 255; int bg_green = 255; int bg_blue = 255; if (qparam.param("bg_r").size() >0) bg_red = validColor(atoi(qparam.param("bg_r").c_str())); if (qparam.param("bg_g").size() >0) bg_green = validColor(atoi(qparam.param("bg_g").c_str())); if (qparam.param("bg_b").size() >0) bg_blue = validColor(atoi(qparam.param("bg_b").c_str())); int size = 20; if (qparam.param("size").size() >0) size = atoi(qparam.param("size").c_str()); if (qparam.param("rgb").size() == 6) { decodeRGBString(qparam.param("rgb"), red, green, blue); } if (qparam.param("bg_rgb").size() == 6) { decodeRGBString(qparam.param("bg_rgb"), bg_red, bg_green, bg_blue); } GD::Image image; image.CreateTrueColor( GD::Size(70,70)); GD::TrueColor background(bg_red, bg_green, bg_blue); GD::TrueColor grey(128,128,128); GD::TrueColor black(10,10,10); GD::TrueColor status(red,green,blue); GD::TrueColor light(validColor(red+155),validColor(green+155),validColor(blue+155)); GD::TrueColor dark(validColor(red-75),validColor(green-75),validColor(blue-75)); image.FilledRectangle( GD::Point(0,0), GD::Point(69,69), background.Int()); image.FilledEllipse( 38,38,60,60, grey.Int()); image.FilledEllipse( 32,32,60,60, black.Int()); image.FilledEllipse( 31,31,50,50, status.Int()); image.FilledArc(31,31,40,40,0,90,dark.Int(), gdPie); image.FilledArc(31,31,40,40,180,270,light.Int(), gdPie); image.FilledEllipse(31,31,20,20,status.Int()); GD::Image out; out.CreateTrueColor(size,size); out.CopyResampled(image,0,0,0,0,size,size,70,70); reply.setContentType("image/png"); int img_size; unsigned char* ptr = (unsigned char*) out.Png(&img_size); for (int i=0; i