mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-30 16:44:55 +01:00
Improve printing quality again
This commit is contained in:
parent
aef1b3b346
commit
e6f77735ba
1 changed files with 8 additions and 2 deletions
10
print.c
10
print.c
|
@ -111,7 +111,9 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
|
||||||
const gdouble width = gtk_print_context_get_width(context);
|
const gdouble width = gtk_print_context_get_width(context);
|
||||||
const gdouble height = gtk_print_context_get_height(context);
|
const gdouble height = gtk_print_context_get_height(context);
|
||||||
|
|
||||||
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
|
const double page_height = zathura_page_get_height(page);
|
||||||
|
const double page_width = zathura_page_get_width(page);
|
||||||
|
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
gtk_print_operation_cancel(print_operation);
|
gtk_print_operation_cancel(print_operation);
|
||||||
return;
|
return;
|
||||||
|
@ -127,7 +129,7 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
|
||||||
/* white background */
|
/* white background */
|
||||||
cairo_save(temp_cairo);
|
cairo_save(temp_cairo);
|
||||||
cairo_set_source_rgb(temp_cairo, 1, 1, 1);
|
cairo_set_source_rgb(temp_cairo, 1, 1, 1);
|
||||||
cairo_rectangle(temp_cairo, 0, 0, width, height);
|
cairo_rectangle(temp_cairo, 0, 0, page_width, page_height);
|
||||||
cairo_fill(temp_cairo);
|
cairo_fill(temp_cairo);
|
||||||
cairo_restore(temp_cairo);
|
cairo_restore(temp_cairo);
|
||||||
|
|
||||||
|
@ -137,6 +139,10 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
|
||||||
zathura_page_render(page, temp_cairo, true);
|
zathura_page_render(page, temp_cairo, true);
|
||||||
render_unlock(zathura->sync.render_thread);
|
render_unlock(zathura->sync.render_thread);
|
||||||
|
|
||||||
|
/* rescale */
|
||||||
|
const gdouble scale = MIN(width / page_width, height / page_height);
|
||||||
|
cairo_scale(cairo, scale, scale);
|
||||||
|
|
||||||
/* copy temporary surface */
|
/* copy temporary surface */
|
||||||
cairo_set_source_surface(cairo, surface, 0.0, 0.0);
|
cairo_set_source_surface(cairo, surface, 0.0, 0.0);
|
||||||
cairo_paint(cairo);
|
cairo_paint(cairo);
|
||||||
|
|
Loading…
Reference in a new issue