summaryrefslogtreecommitdiffstats
path: root/tests/test-covers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-covers.c')
-rw-r--r--tests/test-covers.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/tests/test-covers.c b/tests/test-covers.c
index e7e1fca..a119cc9 100644
--- a/tests/test-covers.c
+++ b/tests/test-covers.c
@@ -36,14 +36,25 @@ ipod_image_to_gdk_pixbuf (Itdb_Image *image)
{
GdkPixbuf *result;
guchar *pixels;
+ int row_stride;
+
+ if (image->type == ITDB_IMAGE_FULL_SCREEN) {
+ row_stride = 140;
+ } else if (image->type == ITDB_IMAGE_NOW_PLAYING) {
+ row_stride = 56;
+ } else {
+ return NULL;
+ }
pixels = itdb_image_get_rgb_data (image);
if (pixels == NULL) {
return NULL;
}
+
result = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE,
8, image->width, image->height,
- image->width * 3,
+ /*image->width * 3, */
+ row_stride * 3,
(GdkPixbufDestroyNotify)g_free,
NULL);
return result;
@@ -59,28 +70,31 @@ save_itdb_image (Itdb_Image *image, const char *filename)
if (thumb != NULL) {
gdk_pixbuf_save (thumb, filename, "png", NULL, NULL);
gdk_pixbuf_unref (thumb);
- g_print ("Saved %s\n", filename);
+/* g_print ("Saved %s\n", filename); */
}
}
static void
save_song_thumbnails (Itdb_Track *song)
{
- if (song->full_size_thumbnail != NULL) {
+ GList *it;
+
+ for (it = song->thumbnails; it != NULL; it = it->next) {
+ Itdb_Image *image;
gchar *filename;
-
- filename = g_strdup_printf ("/tmp/fullsize%016llx.png",
- song->dbid);
- save_itdb_image (song->full_size_thumbnail,filename);
- g_free (filename);
- }
- if (song->now_playing_thumbnail != NULL) {
- gchar *filename;
-
- filename = g_strdup_printf ("/tmp/nowplaying%016llx.png",
- song->dbid);
- save_itdb_image (song->now_playing_thumbnail, filename);
- g_free (filename);
+ image = (Itdb_Image *)it->data;
+ filename = NULL;
+ if (image->type == ITDB_IMAGE_FULL_SCREEN) {
+ filename = g_strdup_printf ("/tmp/fullsize%016llx.png",
+ song->dbid);
+ } else if (image->type == ITDB_IMAGE_NOW_PLAYING) {
+ filename = g_strdup_printf ("/tmp/nowplaying%016llx.png",
+ song->dbid);
+ }
+ if (filename != NULL) {
+ save_itdb_image (image, filename);
+ g_free (filename);
+ }
}
}