summaryrefslogtreecommitdiff
path: root/libspectre/spectre-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'libspectre/spectre-device.c')
-rw-r--r--libspectre/spectre-device.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/libspectre/spectre-device.c b/libspectre/spectre-device.c
index 8fb7f93..a527d86 100644
--- a/libspectre/spectre-device.c
+++ b/libspectre/spectre-device.c
@@ -181,12 +181,10 @@ spectre_device_render (SpectreDevice *device,
char *fmt;
char *text_alpha, *graph_alpha;
char *size = NULL;
- char *resolution;
+ char *resolution, *set;
char *dsp_format, *dsp_handle;
char *width_points = NULL;
char *height_points = NULL;
- int scaled_width;
- int scaled_height;
gs = spectre_gs_new ();
if (!gs)
@@ -206,14 +204,8 @@ spectre_device_render (SpectreDevice *device,
return SPECTRE_STATUS_RENDER_ERROR;
}
- if (rc->orientation == SPECTRE_ORIENTATION_PORTRAIT ||
- rc->orientation == SPECTRE_ORIENTATION_REVERSE_PORTRAIT) {
- scaled_width = (int) ((width * rc->x_scale) + 0.5);
- scaled_height = (int) ((height * rc->y_scale) + 0.5);
- } else {
- scaled_width = (int) ((height * rc->y_scale) + 0.5);
- scaled_height = (int) ((width * rc->x_scale) + 0.5);
- }
+ width = (int) ((width * rc->x_scale) + 0.5);
+ height = (int) ((height * rc->y_scale) + 0.5);
if (rc->use_platform_fonts == FALSE)
n_args++;
@@ -232,19 +224,10 @@ spectre_device_render (SpectreDevice *device,
rc->text_alpha_bits);
args[arg++] = graph_alpha = _spectre_strdup_printf ("-dGraphicsAlphaBits=%d",
rc->graphic_alpha_bits);
- args[arg++] = size =_spectre_strdup_printf ("-g%dx%d", scaled_width, scaled_height);
-
- if (rc->orientation == SPECTRE_ORIENTATION_PORTRAIT ||
- rc->orientation == SPECTRE_ORIENTATION_REVERSE_PORTRAIT) {
- args[arg++] = resolution = _spectre_strdup_printf ("-r%fx%f",
- rc->x_scale * rc->x_dpi,
- rc->y_scale * rc->y_dpi);
- } else {
- args[arg++] = resolution = _spectre_strdup_printf ("-r%fx%f",
- rc->y_scale * rc->y_dpi,
- rc->x_scale * rc->x_dpi);
- }
-
+ args[arg++] = size =_spectre_strdup_printf ("-g%dx%d", width, height);
+ args[arg++] = resolution = _spectre_strdup_printf ("-r%fx%f",
+ rc->x_scale * rc->x_dpi,
+ rc->y_scale * rc->y_dpi);
args[arg++] = dsp_format = _spectre_strdup_printf ("-dDisplayFormat=%d",
DISPLAY_COLORS_RGB |
DISPLAY_DEPTH_8 |
@@ -271,18 +254,10 @@ spectre_device_render (SpectreDevice *device,
args[arg++] = "-dNOPLATFONTS";
if (rc->width != -1 && rc->height != -1) {
- if (rc->orientation == SPECTRE_ORIENTATION_PORTRAIT ||
- rc->orientation == SPECTRE_ORIENTATION_REVERSE_PORTRAIT) {
- args[arg++] = width_points = _spectre_strdup_printf ("-dDEVICEWIDTHPOINTS=%d",
- rc->width);
- args[arg++] = height_points = _spectre_strdup_printf ("-dDEVICEHEIGHTPOINTS=%d",
- rc->height);
- } else {
- args[arg++] = width_points = _spectre_strdup_printf ("-dDEVICEWIDTHPOINTS=%d",
- rc->height);
- args[arg++] = height_points = _spectre_strdup_printf ("-dDEVICEHEIGHTPOINTS=%d",
- rc->width);
- }
+ args[arg++] = width_points = _spectre_strdup_printf ("-dDEVICEWIDTHPOINTS=%d",
+ rc->width);
+ args[arg++] = height_points = _spectre_strdup_printf ("-dDEVICEHEIGHTPOINTS=%d",
+ rc->height);
args[arg++] = "-dFIXEDMEDIA";
}
@@ -301,7 +276,16 @@ spectre_device_render (SpectreDevice *device,
return SPECTRE_STATUS_RENDER_ERROR;
}
- if (!spectre_gs_send_page (gs, device->doc, page, x, y, width, height, spectre_render_context_get_rotation (rc))) {
+ set = _spectre_strdup_printf ("<< /Orientation %d >> setpagedevice .locksafe",
+ rc->orientation);
+ if (!spectre_gs_send_string (gs, set)) {
+ free (set);
+ spectre_gs_free (gs);
+ return SPECTRE_STATUS_RENDER_ERROR;
+ }
+ free (set);
+
+ if (!spectre_gs_send_page (gs, device->doc, page, x, y)) {
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}