--- trunk/tntnet/dynamic/temperaturegraph.ecpp 2007/12/02 20:26:43 126 +++ trunk/tntnet/dynamic/temperaturegraph.ecpp 2007/12/09 08:03:54 197 @@ -17,9 +17,11 @@ int id; <{ +reply.setHeader("Cache-Control", "no-cache, must-revalidate"); // Http/1.1 +reply.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); //date in the past GD::Image image; -image.CreateTrueColor( GD::Size(600,360)); +image.Create( GD::Size(600,360)); //Black color scheme //GD::TrueColor decoration(45,95,0); @@ -27,29 +29,30 @@ //GD::TrueColor line(255,0,0); //White color scheme -image.Fill( GD::Point(1,1), GD::TrueColor(255,255,255).Int() ); -GD::TrueColor decoration(60,60,60); -GD::TrueColor text(0,0,0); -GD::TrueColor line(255,0,0); +int white = image.ColorAllocate(255,255,255); +int decoration = image.ColorAllocate(60,60,60); +int text = image.ColorAllocate(0,0,0); +int line = image.ColorAllocate(255,0,0); +image.Fill( GD::Point(1,1), white ); -image.String(gdFontSmall, 250,5, "Temperature graph", text.Int()); -image.String(gdFontSmall, 200,18, "Latest 20 samples, in degrees Celcius", text.Int()); +image.String(gdFontSmall, 250,5, "Temperature graph", text); +image.String(gdFontSmall, 200,18, "Latest 20 samples, in degrees Celcius", text); for (int i=0; i<11; ++i) { std::stringstream marker; marker << (100- (i*10)); int y = (i*30) + 40; - image.Line( 30, y, 590, y, decoration.Int()); + image.Line( 30, y, 590, y, decoration); - image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int()); + image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text); } ///////////////////////////////////////////////// -tntdb::Connection conn = tntdb::connect(dburl); +tntdb::Connection conn = tntdb::connectCached(dburl); std::stringstream query; query << "SELECT temperature FROM ( "; @@ -69,11 +72,11 @@ int y = ((100-current) * 3) + 40; //image.FilledArc( GD::Point(x,y), GD::Size(3,3), 0, 360, line.Int(), gdPie); - image.FilledRectangle( GD::Point(x-1,y-1), GD::Point(x+1,y+1), line.Int() ); + image.FilledRectangle( GD::Point(x-1,y-1), GD::Point(x+1,y+1), line ); if (i>0) { - image.Line( GD::Point(x,y), previous, line.Int()); + image.Line( GD::Point(x,y), previous, line); } previous = GD::Point(x,y); @@ -84,7 +87,7 @@ // echo the image to the browser... reply.setContentType("image/png"); int size; -unsigned char* ptr = (unsigned char*) image.Png(&size); +unsigned char* ptr = (unsigned char*) image.Png(&size,1); for (int i=0; i