finish exposing scale_factor to cairo_renderer

This commit is contained in:
Dane Springmeyer 2012-07-05 14:54:58 -07:00
parent f7383b81fb
commit d8c719f05e
4 changed files with 15 additions and 11 deletions

View file

@ -150,12 +150,13 @@ void render_layer2(const mapnik::Map& map,
void render3(const mapnik::Map& map,
PycairoSurface* surface,
double scale_factor = 1.0,
unsigned offset_x = 0,
unsigned offset_y = 0)
{
python_unblock_auto_block b;
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,scale_factor,offset_x,offset_y);
ren.apply();
}
@ -169,12 +170,13 @@ void render4(const mapnik::Map& map, PycairoSurface* surface)
void render5(const mapnik::Map& map,
PycairoContext* context,
double scale_factor = 1.0,
unsigned offset_x = 0,
unsigned offset_y = 0)
{
python_unblock_auto_block b;
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
mapnik::cairo_renderer<Cairo::Context> ren(map,c,offset_x, offset_y);
mapnik::cairo_renderer<Cairo::Context> ren(map,c,scale_factor,offset_x, offset_y);
ren.apply();
}
@ -207,7 +209,7 @@ void render_to_file1(const mapnik::Map& map,
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format);
mapnik::save_to_cairo_file(map,filename,format,1.0);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
@ -226,7 +228,7 @@ void render_to_file2(const mapnik::Map& map,const std::string& filename)
if (format == "pdf" || format == "svg" || format =="ps")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format);
mapnik::save_to_cairo_file(map,filename,format,1.0);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
@ -248,7 +250,7 @@ void render_to_file3(const mapnik::Map& map,
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format);
mapnik::save_to_cairo_file(map,filename,format,scale_factor);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif

View file

@ -570,7 +570,7 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
Cairo::RefPtr<Cairo::ImageSurface> image_surface =
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, map.width(),map.height());
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface);
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface, scaling_factor);
png_render.apply();
image_32 buf(image_surface);

View file

@ -60,7 +60,8 @@ public:
#if defined(HAVE_CAIRO)
MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map,
std::string const& filename,
std::string const& type);
std::string const& type,
double scale_factor);
#endif
template <typename T>

View file

@ -352,18 +352,19 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons
#if defined(HAVE_CAIRO)
// TODO - move to separate cairo_io.hpp
void save_to_cairo_file(mapnik::Map const& map, std::string const& filename)
void save_to_cairo_file(mapnik::Map const& map, std::string const& filename, double scale_factor)
{
boost::optional<std::string> type = type_from_filename(filename);
if (type)
{
save_to_cairo_file(map,filename,*type);
save_to_cairo_file(map,filename,*type,scale_factor);
}
}
void save_to_cairo_file(mapnik::Map const& map,
std::string const& filename,
std::string const& type)
std::string const& type,
double scale_factor)
{
std::ofstream file (filename.c_str(), std::ios::out|std::ios::trunc|std::ios::binary);
if (file)
@ -417,7 +418,7 @@ void save_to_cairo_file(mapnik::Map const& map,
*/
mapnik::cairo_renderer<Cairo::Context> ren(map, context);
mapnik::cairo_renderer<Cairo::Context> ren(map, context, scale_factor);
ren.apply();
if (type == "ARGB32" || type == "RGB24")