Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2005-08-25 06:34:20 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-08-25 06:34:20 (GMT)
commit9a1a3b315f05568f6e28f64f685338dc120d5491 (patch)
treeaf6de51724acab978387377c9d7c724ba1323867 /backend
parentebe3e0a897cc51ccfb4f35619c600962900d709e (diff)
Redo rotation (again). prepare for 0.4.0
Thu Aug 25 02:32:32 2005 Jonathan Blandford <jrb@redhat.com> * backend/ev-document-misc.c: (ev_document_misc_get_thumbnail_frame): * backend/ev-document-misc.h: * configure.ac: * pdf/ev-poppler.cc: * shell/Makefile.am: * shell/ev-sidebar-thumbnails.c: (add_range), (ev_sidebar_thumbnails_set_loading_icon), (ev_sidebar_thumbnails_refresh), (ev_sidebar_thumbnails_set_document): * shell/ev-sidebar-thumbnails.h: * shell/ev-view.c: (ev_view_motion_notify_event), (ev_view_set_property), (ev_view_get_property), (ev_view_class_init), (ev_view_set_rotation): * shell/ev-window.c: (ev_window_cmd_edit_rotate_left), (ev_window_cmd_edit_rotate_right), (ev_window_rotation_changed_cb), (ev_window_init): * tiff/tiff-document.c: (tiff_document_thumbnails_get_thumbnail): Redo rotation (again). prepare for 0.4.0
Diffstat (limited to 'backend')
-rw-r--r--backend/ev-document-misc.c51
-rw-r--r--backend/ev-document-misc.h1
2 files changed, 34 insertions, 18 deletions
diff --git a/backend/ev-document-misc.c b/backend/ev-document-misc.c
index 0626e13..c1fb32c 100644
--- a/backend/ev-document-misc.c
+++ b/backend/ev-document-misc.c
@@ -12,54 +12,69 @@
GdkPixbuf *
ev_document_misc_get_thumbnail_frame (int width,
int height,
+ int rotation,
GdkPixbuf *source_pixbuf)
{
GdkPixbuf *retval;
guchar *data;
gint rowstride;
int i;
+ int width_r, height_r;
+
+ rotation = rotation % 360;
+
if (source_pixbuf)
g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);
if (source_pixbuf) {
- width = gdk_pixbuf_get_width (source_pixbuf);
- height = gdk_pixbuf_get_height (source_pixbuf);
+ width_r = gdk_pixbuf_get_width (source_pixbuf);
+ height_r = gdk_pixbuf_get_height (source_pixbuf);
+ } else {
+ if (rotation == 0 || rotation == 180) {
+ width_r = width;
+ height_r = height;
+ } else if (rotation == 90 || rotation == 270) {
+ width_r = height;
+ height_r = width;
+ } else {
+ g_assert_not_reached ();
+ }
}
/* make sure no one is passing us garbage */
- g_assert (width >= 0 && height >= 0);
+ g_assert (width_r >= 0 && height_r >= 0);
retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
TRUE, 8,
- width + 4,
- height + 4);
+ width_r + 4,
+ height_r + 4);
/* make it black and fill in the middle */
data = gdk_pixbuf_get_pixels (retval);
rowstride = gdk_pixbuf_get_rowstride (retval);
gdk_pixbuf_fill (retval, 0x000000ff);
- for (i = 1; i < height + 1; i++)
- memset (data + (rowstride * i) + 4, 0xffffffff, width * 4);
+ for (i = 1; i < height_r + 1; i++)
+ memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4);
/* copy the source pixbuf */
if (source_pixbuf)
gdk_pixbuf_copy_area (source_pixbuf, 0, 0,
- width,
- height,
+ width_r,
+ height_r,
retval,
1, 1);
/* Add the corner */
- data [(width + 2) * 4 + 3] = 0;
- data [(width + 3) * 4 + 3] = 0;
- data [(width + 2) * 4 + (rowstride * 1) + 3] = 0;
- data [(width + 3) * 4 + (rowstride * 1) + 3] = 0;
-
- data [(height + 2) * rowstride + 3] = 0;
- data [(height + 3) * rowstride + 3] = 0;
- data [(height + 2) * rowstride + 4 + 3] = 0;
- data [(height + 3) * rowstride + 4 + 3] = 0;
+ data [(width_r + 2) * 4 + 3] = 0;
+ data [(width_r + 3) * 4 + 3] = 0;
+ data [(width_r + 2) * 4 + (rowstride * 1) + 3] = 0;
+ data [(width_r + 3) * 4 + (rowstride * 1) + 3] = 0;
+
+ data [(height_r + 2) * rowstride + 3] = 0;
+ data [(height_r + 3) * rowstride + 3] = 0;
+ data [(height_r + 2) * rowstride + 4 + 3] = 0;
+ data [(height_r + 3) * rowstride + 4 + 3] = 0;
return retval;
}
diff --git a/backend/ev-document-misc.h b/backend/ev-document-misc.h
index 05d7f63..a101f70 100644
--- a/backend/ev-document-misc.h
+++ b/backend/ev-document-misc.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
GdkPixbuf *ev_document_misc_get_thumbnail_frame (int width,
int height,
+ int rotation,
GdkPixbuf *source_pixbuf);
void ev_document_misc_get_page_border_size (gint page_width,
gint page_height,