[brasero/gnome-2-26] Properly scale background images when printing
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Subject: [brasero/gnome-2-26] Properly scale background images when printing
- Date: Tue, 2 Jun 2009 14:14:36 -0400 (EDT)
commit 0e5ae49457c70956a9c094881fb3c92b9fc9ef32
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Tue Jun 2 19:45:01 2009 +0200
Properly scale background images when printing
Fix #582059 â?? Cover editor ignores background image style setting in printout
Fix #581639 â?? Cover editor shows background images scaled but on printing the images are not.
---
src/brasero-jacket-view.c | 79 +++++++++++++++++++++++++++++++++------------
1 files changed, 58 insertions(+), 21 deletions(-)
diff --git a/src/brasero-jacket-view.c b/src/brasero-jacket-view.c
index 622dc24..e46634c 100644
--- a/src/brasero-jacket-view.c
+++ b/src/brasero-jacket-view.c
@@ -277,6 +277,7 @@ static void
brasero_jacket_view_render (BraseroJacketView *self,
cairo_t *ctx,
PangoLayout *layout,
+ GdkPixbuf *scaled,
gdouble resolution_x,
gdouble resolution_y,
guint x,
@@ -316,14 +317,17 @@ brasero_jacket_view_render (BraseroJacketView *self,
cairo_paint (ctx);
}
- if (priv->scaled) {
+ if (scaled) {
+ /* The problem is the resolution here. The one for the screen
+ * may not be the one for the printer. So do not use our private
+ * scaled image. */
if (priv->image_style == BRASERO_JACKET_IMAGE_CENTER)
gdk_cairo_set_source_pixbuf (ctx,
- priv->scaled,
- x + (width - gdk_pixbuf_get_width (priv->scaled))/ 2.0,
- y + (height - gdk_pixbuf_get_height (priv->scaled)) / 2.0);
+ scaled,
+ x + (width - gdk_pixbuf_get_width (scaled))/ 2.0,
+ y + (height - gdk_pixbuf_get_height (scaled)) / 2.0);
else
- gdk_cairo_set_source_pixbuf (ctx, priv->scaled, x, y);
+ gdk_cairo_set_source_pixbuf (ctx, scaled, x, y);
if (priv->image_style == BRASERO_JACKET_IMAGE_TILE) {
cairo_pattern_t *pattern;
@@ -458,6 +462,31 @@ brasero_jacket_view_render_body (BraseroJacketView *self,
}
}
+static GdkPixbuf *
+brasero_jacket_view_scale_image (BraseroJacketView *self,
+ gdouble resolution_x,
+ gdouble resolution_y)
+{
+ BraseroJacketViewPrivate *priv;
+ guint width, height;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ height = resolution_y * COVER_HEIGHT_BACK_INCH;
+ width = resolution_x * COVER_WIDTH_BACK_INCH;
+ }
+ else {
+ height = resolution_y * COVER_HEIGHT_FRONT_INCH;
+ width = resolution_x * COVER_WIDTH_FRONT_INCH;
+ }
+
+ return gdk_pixbuf_scale_simple (priv->image,
+ width,
+ height,
+ GDK_INTERP_HYPER);
+}
+
guint
brasero_jacket_view_print (BraseroJacketView *self,
GtkPrintContext *context,
@@ -465,6 +494,7 @@ brasero_jacket_view_print (BraseroJacketView *self,
guint y)
{
cairo_t *ctx;
+ GdkPixbuf *scaled;
GdkRectangle rect;
PangoLayout *layout;
gdouble resolution_x;
@@ -490,10 +520,19 @@ brasero_jacket_view_print (BraseroJacketView *self,
rect.height = resolution_y * COVER_HEIGHT_FRONT_INCH;
}
+ /* Make sure we scale the image with the correct resolution */
+ if (priv->image_style == BRASERO_JACKET_IMAGE_STRETCH)
+ scaled = brasero_jacket_view_scale_image (self,
+ resolution_x,
+ resolution_y);
+ else
+ scaled = g_object_ref (priv->scaled);
+
layout = gtk_print_context_create_pango_layout (context);
brasero_jacket_view_render (self,
ctx,
layout,
+ scaled,
resolution_x,
resolution_y,
x,
@@ -511,6 +550,7 @@ brasero_jacket_view_print (BraseroJacketView *self,
FALSE);
g_object_unref (layout);
+ g_object_unref (scaled);
return rect.height;
}
@@ -523,6 +563,7 @@ brasero_jacket_view_snapshot (BraseroJacketView *self)
PangoLayout *layout;
GtkWidget *toplevel;
gdouble resolution;
+ GdkPixbuf *scaled;
GdkRectangle area;
cairo_t *ctx;
guint height;
@@ -552,12 +593,21 @@ brasero_jacket_view_snapshot (BraseroJacketView *self)
height);
ctx = cairo_create (surface);
+ /* make sure the image is scaled with the correct resolution */
+ if (priv->image_style == BRASERO_JACKET_IMAGE_STRETCH)
+ scaled = brasero_jacket_view_scale_image (self,
+ resolution,
+ resolution);
+ else
+ scaled = g_object_ref (priv->scaled);
+
area = GTK_WIDGET (self)->allocation;
area.x = 0;
area.y = 0;
brasero_jacket_view_render (self,
ctx,
layout,
+ scaled,
resolution,
resolution,
0,
@@ -957,8 +1007,6 @@ brasero_jacket_view_update_image (BraseroJacketView *self)
priv->scaled = priv->image;
}
else if (priv->image_style == BRASERO_JACKET_IMAGE_STRETCH) {
- guint width;
- guint height;
guint resolution;
GtkWidget *toplevel;
@@ -967,20 +1015,7 @@ brasero_jacket_view_update_image (BraseroJacketView *self)
return;
resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
-
- if (priv->side == BRASERO_JACKET_BACK) {
- height = resolution * COVER_HEIGHT_BACK_INCH;
- width = resolution * COVER_WIDTH_BACK_INCH;
- }
- else {
- height = resolution * COVER_HEIGHT_FRONT_INCH;
- width = resolution * COVER_WIDTH_FRONT_INCH;
- }
-
- priv->scaled = gdk_pixbuf_scale_simple (priv->image,
- width,
- height,
- GDK_INTERP_HYPER);
+ priv->scaled = brasero_jacket_view_scale_image (self, resolution, resolution);
}
brasero_jacket_view_update_edit_image (self);
@@ -1244,6 +1279,7 @@ brasero_jacket_view_expose (GtkWidget *widget,
brasero_jacket_view_render (BRASERO_JACKET_VIEW (widget),
ctx,
layout,
+ priv->scaled,
resolution,
resolution,
x,
@@ -1283,6 +1319,7 @@ brasero_jacket_view_expose (GtkWidget *widget,
brasero_jacket_view_render (BRASERO_JACKET_VIEW (widget),
ctx,
layout,
+ priv->scaled,
resolution,
resolution,
x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]