summaryrefslogtreecommitdiffstats
path: root/src/db-image-parser.c
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2005-11-23 18:21:52 +0000
committerChristophe Fergeau <teuf@gnome.org>2005-11-23 18:21:52 +0000
commitdf739448ee81be2c415b2202c9b2d83c1cedf2de (patch)
treec32d396b78585c2673f4c2c3a54093923c93c6fe /src/db-image-parser.c
parent559cf826c24c86febec9c600107ffba9e161a4fb (diff)
downloadlibgpod-df739448ee81be2c415b2202c9b2d83c1cedf2de.tar.gz
libgpod-df739448ee81be2c415b2202c9b2d83c1cedf2de.tar.xz
libgpod-df739448ee81be2c415b2202c9b2d83c1cedf2de.zip
2005-11-23 Christophe Fergeau <teuf@gnome.org>
* src/db-artwork-debug.c: (get_utf16_string): * src/db-artwork-parser.c: (get_utf16_string), (parse_mhod_3), (parse_mhni), (ipod_supports_cover_art), (ipod_parse_artwork_db): * src/db-artwork-parser.h: * src/db-artwork-writer.c: (get_artwork_info), (write_mhod_type_3), (write_mhni), (write_mhod), (write_mhii), (write_mhif): * src/db-image-parser.c: (unpack_RGB_565), (image_type_from_corr_id), (ipod_image_new_from_mhni): * src/db-image-parser.h: * src/itdb.h: * src/ithumb-writer.c: (pack_RGB_565), (ithumb_writer_write_thumbnail), (ipod_image_get_ithmb_filename), (ithumb_writer_new), (ithumb_writer_free), (write_thumbnail), (itdb_write_ithumb_files): * tests/test-covers.c: (save_song_thumbnails): rework artwork code in an attempt to properly support artwork on all the iPod models git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1171 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src/db-image-parser.c')
-rw-r--r--src/db-image-parser.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/db-image-parser.c b/src/db-image-parser.c
index 0240654..d2f152c 100644
--- a/src/db-image-parser.c
+++ b/src/db-image-parser.c
@@ -47,9 +47,9 @@ unpack_RGB_565 (gushort *pixels, unsigned int bytes_len)
cur_pixel = GINT16_FROM_LE (pixels[i]);
/* Unpack pixels */
- result[3*i] = (pixels[i] & RED_MASK) >> RED_SHIFT;
- result[3*i+1] = (pixels[i] & GREEN_MASK) >> GREEN_SHIFT;
- result[3*i+2] = (pixels[i] & BLUE_MASK) >> BLUE_SHIFT;
+ result[3*i] = (cur_pixel & RED_MASK) >> RED_SHIFT;
+ result[3*i+1] = (cur_pixel & GREEN_MASK) >> GREEN_SHIFT;
+ result[3*i+2] = (cur_pixel & BLUE_MASK) >> BLUE_SHIFT;
/* Normalize color values so that they use a [0..255] range */
result[3*i] <<= (8 - RED_BITS);
@@ -131,46 +131,48 @@ itdb_image_get_rgb_data (Itdb_Image *image)
*/
}
-G_GNUC_INTERNAL char *
-ipod_image_get_ithmb_filename (const char *mount_point, gint correlation_id)
+static int
+image_type_from_corr_id (IpodDevice *ipod, int corr_id)
{
- char *paths[] = {"iPod_Control", "Artwork", NULL, NULL};
- char *filename;
+ const IpodArtworkFormat *formats;
- paths[2] = g_strdup_printf ("F%04u_1.ithmb", correlation_id);
- filename = itdb_resolve_path (mount_point, (const char **)paths);
- g_free (paths[2]);
- return filename;
+ if (ipod == NULL) {
+ return -1;
+ }
+
+ g_object_get (G_OBJECT (ipod), "artwork-formats", &formats, NULL);
+ if (formats == NULL) {
+ return -1;
+ }
+
+ while (formats->type != -1) {
+ if (formats->correlation_id == corr_id) {
+ return formats->type;
+ }
+ formats++;
+ }
+
+ return -1;
}
G_GNUC_INTERNAL Itdb_Image *
-ipod_image_new_from_mhni (MhniHeader *mhni, const char *mount_point)
+ipod_image_new_from_mhni (MhniHeader *mhni, Itdb_iTunesDB *db)
{
- Itdb_Image *img;
+ Itdb_Image *img;
img = g_new0 (Itdb_Image, 1);
if (img == NULL) {
return NULL;
}
- img->filename = ipod_image_get_ithmb_filename (mount_point,
- GINT_FROM_LE (mhni->correlation_id));
img->size = GUINT32_FROM_LE (mhni->image_size);
img->offset = GUINT32_FROM_LE (mhni->ithmb_offset);
img->width = GINT16_FROM_LE (mhni->image_width);
img->height = GINT16_FROM_LE (mhni->image_height);
- switch (mhni->correlation_id) {
- case IPOD_THUMBNAIL_FULL_SIZE_CORRELATION_ID:
- case IPOD_NANO_THUMBNAIL_FULL_SIZE_CORRELATION_ID:
- img->type = ITDB_IMAGE_FULL_SCREEN;
- break;
- case IPOD_THUMBNAIL_NOW_PLAYING_CORRELATION_ID:
- case IPOD_NANO_THUMBNAIL_NOW_PLAYING_CORRELATION_ID:
- img->type = ITDB_IMAGE_NOW_PLAYING;
- break;
- default:
- g_print ("Unrecognized image size: %ux%u\n",
- img->width, img->height);
+ img->type = image_type_from_corr_id (db->device, mhni->correlation_id);
+ if ((img->type != IPOD_COVER_SMALL) && (img->type != IPOD_COVER_LARGE)) {
+ g_warning ("Unexpected cover type in mhni: %ux%u (%d)\n",
+ img->width, img->height, mhni->correlation_id);
g_free (img);
return NULL;
}