[maemo-commits] [maemo-commits] r13099 - projects/haf/tags/hildon-thumbnail/0.12/thumbs
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Aug 10 13:13:37 EEST 2007
- Previous message: [maemo-commits] r13098 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r13100 - projects/haf/tags/hildon-thumbnail/0.12/thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2007-08-10 13:13:36 +0300 (Fri, 10 Aug 2007) New Revision: 13099 Modified: projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c Log: fix a bug + make it more generic Modified: projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c =================================================================== --- projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c 2007-08-10 10:01:05 UTC (rev 13098) +++ projects/haf/tags/hildon-thumbnail/0.12/thumbs/thumber-gdk-pixbuf.c 2007-08-10 10:13:36 UTC (rev 13099) @@ -134,6 +134,8 @@ } } +#define BLK 4 + GdkPixbuf *create_thumb(const gchar *local_file, const gchar *mime_type, guint width, guint height, HildonThumbnailFlags flags, gchar ***opt_keys, gchar ***opt_values, GError **error) @@ -141,9 +143,9 @@ if((flags & HILDON_THUMBNAIL_FLAG_CROP)) { GdkPixbuf *pixbuf, *result = NULL; GdkPixbufLoader *loader; - guchar buffer[2048]; /* size must be dividable by 4 */ + guchar buffer[2048]; /* size must be dividable by BLK */ FILE *f; - size_t items_read = sizeof(buffer) / 4; + size_t items_read = sizeof(buffer) / BLK; size_t desired_max_area; f = fopen(local_file, "r"); @@ -154,10 +156,17 @@ g_signal_connect(loader, "size-prepared", G_CALLBACK(size_prepared), GINT_TO_POINTER(desired_max_area)); - while (!oom && items_read >= sizeof(buffer) / 4) + while (!oom && items_read >= sizeof(buffer) / BLK) { - items_read = fread(buffer, 4, sizeof(buffer) / 4, f); - if (!gdk_pixbuf_loader_write(loader, buffer, items_read, error)) + int nbytes; + /* read BLK bytes at a time as much as possible */ + items_read = fread(buffer, BLK, sizeof(buffer) / BLK, f); + if (items_read < 1) + nbytes = fread(buffer, 1, sizeof(buffer), f); + else + nbytes = items_read * BLK; + + if (!gdk_pixbuf_loader_write(loader, buffer, nbytes, error)) { /* We have to call close before unreffing */ gdk_pixbuf_loader_close(loader, NULL); goto cleanup;
- Previous message: [maemo-commits] r13098 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
- Next message: [maemo-commits] r13100 - projects/haf/tags/hildon-thumbnail/0.12/thumbs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]