bool rasterpolys(const vector<Poly> &polys, const Vector2d &min, const Vector2d &max, double resolution, Cairo::RefPtr<Cairo::ImageSurface> &surface, Cairo::RefPtr<Cairo::Context> &context) { Vector2d diag = max - min; int width = (int)ceil(diag.x()/resolution); int height = (int)ceil(diag.y()/resolution); if (height <= 0 || width <= 0) return false; surface = Cairo::ImageSurface::create(Cairo::FORMAT_A8, width, height); //surface->set_device_offset(-min.x()/resolution, -min.y()/resolution); context = Cairo::Context::create (surface); context->set_fill_rule(Cairo::FILL_RULE_WINDING); context->set_antialias(Cairo::ANTIALIAS_DEFAULT); context->scale(1/resolution, 1/resolution); context->translate(-min.x(), -min.y()); context->set_source_rgb (0,0,0); //cerr << min << endl <<getMatrix(context) << endl; // draw boundary // context->begin_new_path(); // context->set_line_width(0.5); // context->move_to(min.x(),min.y()); // context->line_to(max.x(),min.y()); // context->line_to(max.x(),max.y()); // context->line_to(min.x(),max.y()); // // context->move_to(0,0); // // context->line_to(diag.x(),0); // // context->line_to(diag.x(),diag.y()); // // context->line_to(0,diag.y()); // context->close_path(); // context->stroke(); context->begin_new_path(); context->set_line_width(0); for (uint i=0; i<polys.size(); i++) { Vector2d v = polys[i][0]; context->move_to(v.x(),v.y()); for (uint j=0; j<polys[i].size(); j++) { Vector2d v = polys[i][j]; context->line_to(v.x(),v.y()); } } context->fill(); return true; }