[banshee] [ArtworkManager] Maintain aspect ratio (bgo#613359)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [ArtworkManager] Maintain aspect ratio (bgo#613359)
- Date: Wed, 14 Apr 2010 08:46:32 +0000 (UTC)
commit ef0119cef7386d36894b6def6f9876dbf6fbd673
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Wed Apr 14 18:30:00 2010 +1000
[ArtworkManager] Maintain aspect ratio (bgo#613359)
Make the album art square when scaling only if width and height
difference is within 20%.
This fixes a common problem when non-square album art (e.g. from
tape cassettes) is scaled to an ugly-looking square image while
still scaling near-square covers.
.../Banshee.Collection.Gui/ArtworkManager.cs | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index c4af06a..c6abfa8 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -182,7 +182,18 @@ namespace Banshee.Collection.Gui
if (orig_exists && size >= 10) {
try {
Pixbuf pixbuf = new Pixbuf (orig_path);
- Pixbuf scaled_pixbuf = pixbuf.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
+
+ // Make it square if width and height difference is within 20%
+ const double max_ratio = 1.2;
+ double ratio = (double)pixbuf.Height / pixbuf.Width;
+ int width = size, height = size;
+ if (ratio > max_ratio) {
+ width = (int)Math.Round (size / ratio);
+ }else if (ratio < 1d / max_ratio) {
+ height = (int)Math.Round (size / ratio);
+ }
+
+ Pixbuf scaled_pixbuf = pixbuf.ScaleSimple (width, height, Gdk.InterpType.Bilinear);
if (IsCachedSize (size)) {
Directory.Create (System.IO.Path.GetDirectoryName (path));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]