Revision: 1668
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1668&view=rev
Author: phantom_sf
Date: 2007-08-03 14:52:49 -0700 (Fri, 03 Aug 2007)
Log Message:
-----------
2007-08-03 P.G. Richardson <phantom_sf at users.sourceforge.net>
* src/display_coverart.h: added DEFAULT_IMG_SIZE
* src/display_coverart.c: improvements to image dimension setting
algorithms for both x and y. Using ITDB_THUMB_COVER_LARGE for
the preferred image means the coverart can be too big in the
coverart display window. Thus, introduces a default maximum and
algorithm to set it.
Modified Paths:
--------------
gtkpod/trunk/ChangeLog_detailed
gtkpod/trunk/src/display_coverart.c
gtkpod/trunk/src/display_coverart.h
Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed 2007-08-02 19:16:40 UTC (rev 1667)
+++ gtkpod/trunk/ChangeLog_detailed 2007-08-03 21:52:49 UTC (rev 1668)
@@ -1,3 +1,12 @@
+2007-08-03 P.G. Richardson <phantom_sf at users.sourceforge.net>
+
+ * src/display_coverart.h: added DEFAULT_IMG_SIZE
+ * src/display_coverart.c: improvements to image dimension setting
+ algorithms for both x and y. Using ITDB_THUMB_COVER_LARGE for
+ the preferred image means the coverart can be too big in the
+ coverart display window. Thus, introduces a default maximum and
+ algorithm to set it.
+
2007-08-02 Todd Zullinger <tmzullinger at users.sourceforge.net>
* data/gtkpod.glade:
Modified: gtkpod/trunk/src/display_coverart.c
===================================================================
--- gtkpod/trunk/src/display_coverart.c 2007-08-02 19:16:40 UTC (rev 1667)
+++ gtkpod/trunk/src/display_coverart.c 2007-08-03 21:52:49 UTC (rev 1668)
@@ -329,7 +329,7 @@
if (album->albumart == NULL)
{
track = g_list_nth_data (album->tracks, 0);
- album->albumart = coverart_get_track_thumb (track,
track->itdb->device, 0);
+ album->albumart = coverart_get_track_thumb (track,
track->itdb->device, DEFAULT_IMG_SIZE);
}
/* Set the x, y, height and width of the CD cover */
@@ -579,12 +579,15 @@
* pixbuf referenced by the provided track or the pixbuf of the
* default file if track has no cover art.
*/
-GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint
default_img_size)
+GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint
default_size)
{
- GdkPixbuf *pixbuf = NULL;
+ GdkPixbuf *pixbuf = NULL;
+ GdkPixbuf *image = NULL;
Thumb *thumb;
ExtraTrackData *etd;
-
+ gint w, h;
+ float ratio;
+
etd = track->userdata;
g_return_val_if_fail (etd, NULL);
@@ -592,13 +595,44 @@
ITDB_THUMB_COVER_LARGE);
if (thumb)
{
- pixbuf = itdb_thumb_get_gdk_pixbuf (device, thumb);
+ image = itdb_thumb_get_gdk_pixbuf (device, thumb);
+ w = gdk_pixbuf_get_width (image);
+ h = gdk_pixbuf_get_height (image);
+ if (default_size > 0 && (w > default_size || h > default_size))
+ {
+ /* need to scale the image back down to size */
+ if (w == h)
+ {
+ w = default_size;
+ h = default_size;
+ }
+ else if (h > w)
+ {
+ ratio = h / w;
+ h = default_size;
+ w = (gint) (default_size / ratio);
+ }
+ else
+ {
+ ratio = w / h;
+ w = default_size;
+ h = (gint) (default_size / ratio);
+ }
+
+ pixbuf = gdk_pixbuf_scale_simple(image, w, h,
GDK_INTERP_NEAREST);
+ gdk_pixbuf_unref (image);
+ }
+ else
+ {
+ pixbuf = gdk_pixbuf_scale_simple(image,
DEFAULT_IMG_SIZE, DEFAULT_IMG_SIZE, GDK_INTERP_NEAREST);
+ gdk_pixbuf_unref (image);
+ }
}
if (pixbuf == NULL)
{
/* Could not get a viable thumbnail so get default pixbuf */
- pixbuf = coverart_get_default_track_thumb (default_img_size);
+ pixbuf = coverart_get_default_track_thumb (default_size);
}
return pixbuf;
@@ -1020,13 +1054,18 @@
{
gdouble x = 0, y = 0;
gdouble small_img_width, small_img_height;
- gdouble display_width = 0, display_diff = 0, display_ratio = 0;
+ gdouble display_width = 0, display_height = 0;
+ gdouble display_diff = 0, display_ratio = 0;
gint temp_index = 0;
small_img_width = img_width * 0.75;
small_img_height = img_height * 0.75;
+ /* WIDTH is the width of the display_coverart window
+ * BORDER is the 10 pixel frame around the images
+ */
display_width = (WIDTH / 2) - (BORDER * 2);
+
display_diff = display_width - small_img_width;
/* Set the x location of the cover image */
@@ -1055,23 +1094,27 @@
break;
}
- /* Set the y location of the cover image */
+ /* Set the y location of the cover image. The y location must be
determined by
+ * height of the cover image so that the hightlight and shadow fit in
correctly.
+ */
+ display_height = HEIGHT - (BORDER * 2);
+
switch(cover_index) {
case 0:
case 8:
- y = BORDER;
+ y = display_height - (small_img_height + (BORDER * 15));
break;
case 1:
case 7:
- y = BORDER * 3;
+ y = display_height - (small_img_height + (BORDER * 12));
break;
case 2:
case 6:
- y = BORDER * 5;
+ y = display_height - (small_img_height + (BORDER * 9));
break;
case 3:
case 5:
- y = BORDER * 7;
+ y = display_height - (small_img_height + (BORDER * 6));
break;
case IMG_MAIN:
/* The Main Image CD Cover Image */
Modified: gtkpod/trunk/src/display_coverart.h
===================================================================
--- gtkpod/trunk/src/display_coverart.h 2007-08-02 19:16:40 UTC (rev 1667)
+++ gtkpod/trunk/src/display_coverart.h 2007-08-03 21:52:49 UTC (rev 1668)
@@ -37,6 +37,7 @@
#define IMG_PREV 2
#define IMG_TOTAL 9
#define BORDER 10
+#define DEFAULT_IMG_SIZE 140
#define COVERART_REMOVE_SIGNAL 1
#define COVERART_CREATE_SIGNAL 2
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2