[longomatch] Scale thumbnails to the max width and size



commit 36659ca8191086f635834ab77d2f41356302d859
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Aug 11 12:25:18 2012 +0200

    Scale thumbnails to the max width and size

 LongoMatch.Core/Store/PixbufTimeNode.cs |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Core/Store/PixbufTimeNode.cs b/LongoMatch.Core/Store/PixbufTimeNode.cs
index b9feb25..c21aec2 100644
--- a/LongoMatch.Core/Store/PixbufTimeNode.cs
+++ b/LongoMatch.Core/Store/PixbufTimeNode.cs
@@ -34,8 +34,7 @@ namespace LongoMatch.Store
 	public class PixbufTimeNode : TimeNode
 	{
 		private byte[] thumbnailBuf;
-		private const int MAX_WIDTH=100;
-		private const int MAX_HEIGHT=75;
+		
 		#region Contructors
 		public PixbufTimeNode() {
 		}
@@ -51,7 +50,15 @@ namespace LongoMatch.Store
 					return Image.Deserialize(thumbnailBuf);
 				else return null;
 			} set {
-				thumbnailBuf = value == null ? null: value.Serialize();
+				if (value == null)
+					thumbnailBuf = null;
+				else {
+					if (value.Height > Constants.THUMBNAIL_MAX_HEIGHT ||
+					    value.Width > Constants.THUMBNAIL_MAX_WIDTH) {
+						value.Scale(Constants.THUMBNAIL_MAX_WIDTH, Constants.THUMBNAIL_MAX_HEIGHT);
+					}
+					thumbnailBuf = value.Serialize();
+				}
 			}
 		}
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]