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-01-06 23:56:14 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-01-06 23:56:14 (GMT)
commit2aadab6feb778de1be1a92f20ba60e44de571199 (patch)
treea5773d36548293d25e98053c8b04f8dc1df9932d /backend
parentb322dbd94ce1ef24aa1d40e18cc18d66c9c85ef0 (diff)
fill in the thumbnail with white. New interface to get the size of a page.
Thu Jan 6 18:48:11 2005 Jonathan Blandford <jrb@redhat.com> * backend/ev-document-misc.c (ev_document_misc_get_thumbnail_frame): fill in the thumbnail with white. * backend/ev-document-thumbnails.h: New interface to get the size of a page.
Diffstat (limited to 'backend')
-rw-r--r--backend/ev-document-misc.c17
-rw-r--r--backend/ev-document-thumbnails.c29
-rw-r--r--backend/ev-document-thumbnails.h43
3 files changed, 65 insertions, 24 deletions
diff --git a/backend/ev-document-misc.c b/backend/ev-document-misc.c
index ca818b7..d7d4beb 100644
--- a/backend/ev-document-misc.c
+++ b/backend/ev-document-misc.c
@@ -1,10 +1,13 @@
#include "ev-document-misc.h"
+#include <string.h>
/* Returns a new GdkPixbuf that is suitable for placing in the thumbnail view.
* It is four pixels wider and taller than the source. If source_pixbuf is not
* NULL, then it will fill the return pixbuf with the contents of
- * source_pixbuf. */
+ * source_pixbuf.
+ */
+
GdkPixbuf *
ev_document_misc_get_thumbnail_frame (int width,
int height,
@@ -13,6 +16,7 @@ ev_document_misc_get_thumbnail_frame (int width,
GdkPixbuf *retval;
guchar *data;
gint rowstride;
+ int i;
if (source_pixbuf)
g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);
@@ -29,7 +33,16 @@ ev_document_misc_get_thumbnail_frame (int width,
TRUE, 8,
width + 4,
height + 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);
+
+ /* copy the source pixbuf */
if (source_pixbuf)
gdk_pixbuf_copy_area (source_pixbuf, 0, 0,
width,
@@ -37,8 +50,6 @@ ev_document_misc_get_thumbnail_frame (int width,
retval,
1, 1);
/* Add the corner */
- data = gdk_pixbuf_get_pixels (retval);
- rowstride = gdk_pixbuf_get_rowstride (retval);
data [(width + 2) * 4 + 3] = 0;
data [(width + 3) * 4 + 3] = 0;
data [(width + 2) * 4 + (rowstride * 1) + 3] = 0;
diff --git a/backend/ev-document-thumbnails.c b/backend/ev-document-thumbnails.c
index e9c53ab..ce2f218 100644
--- a/backend/ev-document-thumbnails.c
+++ b/backend/ev-document-thumbnails.c
@@ -47,9 +47,30 @@ ev_document_thumbnails_get_type (void)
GdkPixbuf *
ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
- gint width)
+ gint suggested_width)
{
- EvDocumentThumbnailsIface *iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
-
- return iface->get_thumbnail (document, page, width);
+ EvDocumentThumbnailsIface *iface;
+
+ g_return_val_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document), NULL);
+
+ iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
+ return iface->get_thumbnail (document, page, suggested_width);
+}
+
+void
+ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height)
+{
+ EvDocumentThumbnailsIface *iface;
+
+ g_return_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document));
+ g_return_if_fail (width != NULL);
+ g_return_if_fail (height != NULL);
+
+ iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
+ iface->get_dimensions (document, page, suggested_width, width, height);
}
+
diff --git a/backend/ev-document-thumbnails.h b/backend/ev-document-thumbnails.h
index fdc1e80..52ed6c5 100644
--- a/backend/ev-document-thumbnails.h
+++ b/backend/ev-document-thumbnails.h
@@ -25,31 +25,40 @@
G_BEGIN_DECLS
-#define EV_TYPE_DOCUMENT_THUMBNAILS (ev_document_thumbnails_get_type ())
-#define EV_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnails))
-#define EV_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
-#define EV_IS_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_THUMBNAILS))
-#define EV_IS_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_TYPE_DOCUMENT_THUMBNAILS (ev_document_thumbnails_get_type ())
+#define EV_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnails))
+#define EV_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
+#define EV_IS_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_IS_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_THUMBNAILS))
#define EV_DOCUMENT_THUMBNAILS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
-typedef struct _EvDocumentThumbnails EvDocumentThumbnails;
-typedef struct _EvDocumentThumbnailsIface EvDocumentThumbnailsIface;
+typedef struct _EvDocumentThumbnails EvDocumentThumbnails;
+typedef struct _EvDocumentThumbnailsIface EvDocumentThumbnailsIface;
struct _EvDocumentThumbnailsIface
{
- GTypeInterface base_iface;
+ GTypeInterface base_iface;
- /* Methods */
- GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
- gint page,
- gint width);
+ /* Methods */
+ GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
+ gint page,
+ gint width);
+ void (* get_dimensions) (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height);
};
-GType ev_document_thumbnails_get_type (void);
-
-GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- gint width);
+GType ev_document_thumbnails_get_type (void);
+GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width);
+void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height);
G_END_DECLS